From 6212eead204885d5b76685e28f642dfba1410483 Mon Sep 17 00:00:00 2001 From: tanshu Date: Tue, 21 Sep 2021 07:01:36 +0530 Subject: [PATCH] Fix: Update purchase was wrong. It would stop after the first product as break would exit the loop instead of going to the next iteration. It was actually not needed and was a holdover from the previous loop in loop code. --- brewman/brewman/routers/purchase.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/brewman/brewman/routers/purchase.py b/brewman/brewman/routers/purchase.py index f49998b0..ea4dd275 100644 --- a/brewman/brewman/routers/purchase.py +++ b/brewman/brewman/routers/purchase.py @@ -226,7 +226,7 @@ def update_inventory(voucher: Voucher, vendor_id: uuid.UUID, new_inventories: Li item = voucher.inventories[it - 1] index = next((idx for (idx, d) in enumerate(new_inventories) if d.id_ == item.id), None) if index is not None: - new_inventory = new_inventories[index] + new_inventory = new_inventories.pop(index) product = db.execute(select(Product).where(Product.id == new_inventory.product.id_)).scalar_one() rc_price = rate_contract_price(product.id, vendor_id, voucher.date, db) if rc_price is not None and rc_price != new_inventory.rate: @@ -258,9 +258,7 @@ def update_inventory(voucher: Voucher, vendor_id: uuid.UUID, new_inventories: Li item.tax = new_inventory.tax item.batch.tax = new_inventory.tax product.price = new_inventory.rate - new_inventories.remove(new_inventory) # TODO: Update all references of the batch with the new rates - break else: has_been_issued = db.execute( select(func.count(Inventory.id)).where(Inventory.batch_id == item.batch.id, Inventory.id != item.id)