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.
This commit is contained in:
parent
f2d617bbce
commit
6212eead20
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user