Fix PO unit cost calculation for ordering row, batch
This commit is contained in:
parent
8bb09f5739
commit
512084194d
|
@ -264,18 +264,21 @@ class OrderingBatchView(PurchasingBatchView):
|
||||||
row.removed = False
|
row.removed = False
|
||||||
batch.rowcount += 1
|
batch.rowcount += 1
|
||||||
self.handler.refresh_row(row)
|
self.handler.refresh_row(row)
|
||||||
|
if row.po_unit_cost:
|
||||||
|
row.po_total = row.po_unit_cost * self.handler.get_units_ordered(row)
|
||||||
|
batch.po_total = (batch.po_total or 0) + row.po_total
|
||||||
else:
|
else:
|
||||||
row.removed = True
|
row.removed = True
|
||||||
|
|
||||||
elif cases_ordered or units_ordered:
|
elif cases_ordered or units_ordered:
|
||||||
row = model.PurchaseBatchRow()
|
row = model.PurchaseBatchRow()
|
||||||
row.sequence = max([0] + [r.sequence for r in batch.data_rows]) + 1
|
|
||||||
row.product = product
|
row.product = product
|
||||||
batch.data_rows.append(row)
|
|
||||||
row.cases_ordered = cases_ordered or None
|
row.cases_ordered = cases_ordered or None
|
||||||
row.units_ordered = units_ordered or None
|
row.units_ordered = units_ordered or None
|
||||||
self.handler.refresh_row(row)
|
self.handler.add_row(batch, row)
|
||||||
batch.rowcount = (batch.rowcount or 0) + 1
|
if row.po_unit_cost:
|
||||||
|
row.po_total = row.po_unit_cost * self.handler.get_units_ordered(row)
|
||||||
|
batch.po_total = (batch.po_total or 0) + row.po_total
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'row_cases_ordered': '' if not row or row.removed else int(row.cases_ordered or 0),
|
'row_cases_ordered': '' if not row or row.removed else int(row.cases_ordered or 0),
|
||||||
|
|
Loading…
Reference in a new issue