From d14250c0c7c6e609bd75a7d22e99ef6963d64f86 Mon Sep 17 00:00:00 2001 From: tanshu Date: Sat, 19 Jun 2021 08:19:48 +0530 Subject: [PATCH] Fix: Voucher Update would not filter out Zero quantity inventories. --- barker/barker/routers/voucher/save.py | 2 +- barker/barker/routers/voucher/update.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/barker/barker/routers/voucher/save.py b/barker/barker/routers/voucher/save.py index 6038669..9bb619d 100644 --- a/barker/barker/routers/voucher/save.py +++ b/barker/barker/routers/voucher/save.py @@ -110,7 +110,7 @@ def do_save( item.kots.append(kot) db.add(kot) for index, i in enumerate(k.inventories): - if i.quantity == 0: + if round(i.quantity, 2) == 0: continue total_quantity = round( sum(inv.quantity for ko in data.kots for inv in ko.inventories if inv.product.id_ == i.product.id_), diff --git a/barker/barker/routers/voucher/update.py b/barker/barker/routers/voucher/update.py index a39a086..492c9cf 100644 --- a/barker/barker/routers/voucher/update.py +++ b/barker/barker/routers/voucher/update.py @@ -110,6 +110,8 @@ def update_route( item.kots.append(kot) db.add(kot) for index, i in enumerate(k.inventories): + if round(i.quantity, 2) == 0: + continue product: ProductVersion = db.execute( select(ProductVersion).where( and_(