diff --git a/tailbone/views/purchasing/batch.py b/tailbone/views/purchasing/batch.py index 39106e13..117598b5 100644 --- a/tailbone/views/purchasing/batch.py +++ b/tailbone/views/purchasing/batch.py @@ -896,14 +896,23 @@ class PurchasingBatchView(BatchMasterView): batch = row.batch # first undo any totals previously in effect for the row - if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING and row.po_total: - batch.po_total -= row.po_total + if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING and row.po_total_calculated: + batch.po_total_calculated -= row.po_total_calculated elif batch.mode == self.enum.PURCHASE_BATCH_MODE_RECEIVING and row.invoice_total: + # TODO: pretty sure this should update the `_calculated` value instead? + # TODO: also, should update the value again after the super() call batch.invoice_total -= row.invoice_total row = super(PurchasingBatchView, self).save_edit_row_form(form) + # TODO: is this needed? # self.handler.refresh_row(row) + + # now apply new totals based on current row quantity + if batch.mode == self.enum.PURCHASE_BATCH_MODE_ORDERING and row.po_unit_cost is not None: + row.po_total_calculated = row.po_unit_cost * self.handler.get_units_ordered(row) + batch.po_total_calculated += row.po_total_calculated + return row # def redirect_after_create_row(self, row):