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)