Fix: Raw Material Cost needed order

This commit is contained in:
Amritanshu Agrawal 2021-11-10 12:11:50 +05:30
parent bfdf70cdc4
commit cdc988c015
2 changed files with 5 additions and 7 deletions

View File

@ -285,12 +285,9 @@ def update_inventory(voucher: Voucher, vendor_id: uuid.UUID, inventories: List[I
db.flush() db.flush()
fix_single_batch_prices(item.batch_id, db) fix_single_batch_prices(item.batch_id, db)
else: else:
has_been_issued: int = ( has_been_issued: int = db.execute(
db.execute( select(func.count(Inventory.id)).where(Inventory.batch_id == item.batch.id, Inventory.id != item.id)
select(func.count(Inventory.id)).where(Inventory.batch_id == item.batch.id, Inventory.id != item.id) ).scalar_one()
)
.scalar_one()
)
if has_been_issued > 0: if has_been_issued > 0:
raise HTTPException( raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,

View File

@ -117,11 +117,12 @@ def build_report(
sale=sale, sale=sale,
rmc=rmc, rmc=rmc,
url=["/", "raw-material-cost", str(cost_centre.id)], url=["/", "raw-material-cost", str(cost_centre.id)],
order=0,
) )
) )
rmc = 0 if sales == 0 else issues / sales rmc = 0 if sales == 0 else issues / sales
return body, schemas.RawMaterialCostItem(name="Total", issue=issues, sale=sales, rmc=rmc) return body, schemas.RawMaterialCostItem(name="Total", issue=issues, sale=sales, rmc=rmc, order=0)
def build_report_id( def build_report_id(