From cb1593ee530c929bb7871230807e9bcf6409edb3 Mon Sep 17 00:00:00 2001 From: JULLIEN Baptiste Date: Mon, 29 Apr 2024 21:03:08 +0200 Subject: [PATCH 1/2] feat(front): add delete and see button --- .../panel/products/reappro/+page.svelte | 233 +++++++++++++++++- 1 file changed, 222 insertions(+), 11 deletions(-) diff --git a/frontend/src/routes/panel/products/reappro/+page.svelte b/frontend/src/routes/panel/products/reappro/+page.svelte index a94a1ad..be309a4 100644 --- a/frontend/src/routes/panel/products/reappro/+page.svelte +++ b/frontend/src/routes/panel/products/reappro/+page.svelte @@ -1,5 +1,6 @@
@@ -605,15 +620,33 @@ Prix total TTC

+ +

+ Actions +

+ - {#each restoks as restok} + + {#if deletingRestock} + { + deletingRestock = false; + }} + confirm_callback={deleteRestockCallback} + /> + {/if} + {#each restocks as restock}
-

{restok.created_at}

+

{restock.created_at}

@@ -622,7 +655,7 @@
-

{restok.type}

+

{restock.type}

@@ -631,7 +664,7 @@
-

{restok.created_by_name}

+

{restock.created_by_name}

@@ -639,11 +672,189 @@

- {formatPrice(restok.total_cost_ttc)} + {formatPrice(restock.total_cost_ttc)}

+ +
+ + +
+ {/each} + {#if selectedRestock != undefined} + + + + + + + + + + + + + + {#each selectedRestock.items as item} + + + + + + + + + + + {/each} +
+ + Nom + + + + Prix coûtant HT + + + + Prix coûtant TTC + + + + Nombre de lots + + + + Nbr produits par lots + + + + Prix d'un lot HT + + + + TVA + + + + Prix d'un lot TTC + +
+
+
+

{item.item_name}

+
+
+
+
+
+

{formatPrice(item.bundle_cost_ht * item.amount_of_bundle)}

+
+
+
+
+
+

+ {formatPrice(item.bundle_cost_ttc * item.amount_of_bundle)} +

+
+
+
+
+
+

{item.amount_of_bundle}

+
+
+
+
+
+

{item.amount_per_bundle}

+
+
+
+
+
+

{formatPrice(item.bundle_cost_ht)}

+
+
+
+
+
+

{item.tva / 100}%

+
+
+
+
+
+

{formatPrice(item.bundle_cost_ttc)}

+
+
+
+ {/if} From ed1d6fe0f2f5da4a70d2c68f307e253ac7be9243 Mon Sep 17 00:00:00 2001 From: JULLIEN Baptiste Date: Mon, 29 Apr 2024 21:03:41 +0200 Subject: [PATCH 2/2] fix(api): getAllRestock was giving deleted restock --- backend/internal/db/mongo/restock_misc.go | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/backend/internal/db/mongo/restock_misc.go b/backend/internal/db/mongo/restock_misc.go index c1d7932..d24eed4 100644 --- a/backend/internal/db/mongo/restock_misc.go +++ b/backend/internal/db/mongo/restock_misc.go @@ -51,7 +51,18 @@ func (b *Backend) GetAllRestocks(ctx context.Context, page uint64, size uint64) ctx, cancel := b.TimeoutContext(ctx) defer cancel() - filter := bson.M{} + filter := bson.M{ + "$or": []bson.M{ + { + "deleted_at": bson.M{ + "$exists": false, + }, + }, + { + "deleted_at": nil, + }, + }, + } // Get "size" restocks from "page" using aggregation var restocks []*models.Restock @@ -72,7 +83,18 @@ func (b *Backend) CountAllRestocks(ctx context.Context) (uint64, error) { ctx, cancel := b.TimeoutContext(ctx) defer cancel() - filter := bson.M{} + filter := bson.M{ + "$or": []bson.M{ + { + "deleted_at": bson.M{ + "$exists": false, + }, + }, + { + "deleted_at": nil, + }, + }, + } count, err := b.db.Collection(RestocksCollection).CountDocuments(ctx, filter) if err != nil {