diff --git a/tailbone/views/purchases/credits.py b/tailbone/views/purchases/credits.py index 9b4e0255..d812fbe7 100644 --- a/tailbone/views/purchases/credits.py +++ b/tailbone/views/purchases/credits.py @@ -58,7 +58,7 @@ class PurchaseCreditView(MasterView): 'size', 'cases_shorted', 'units_shorted', - 'invoice_total', + 'credit_total', 'credit_type', 'mispick_upc', 'date_received', @@ -83,7 +83,7 @@ class PurchaseCreditView(MasterView): # g.set_type('upc', 'gpc') g.set_type('cases_shorted', 'quantity') g.set_type('units_shorted', 'quantity') - g.set_type('invoice_total', 'currency') + g.set_type('credit_total', 'currency') g.set_label('invoice_number', "Invoice No.") g.set_label('upc', "UPC") diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index 7350cf79..36f71189 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -715,6 +715,14 @@ class ReceivingBatchView(PurchasingBatchView): credit.invoice_case_cost = row.invoice_case_cost credit.invoice_unit_cost = row.invoice_unit_cost credit.invoice_total = row.invoice_total + + # calculate credit total + # TODO: should this leverage case cost if present? + credit_units = self.handler.get_units(credit.cases_shorted, + credit.units_shorted, + credit.case_quantity) + credit.credit_total = credit_units * (credit.invoice_unit_cost or 0) + credit.product_discarded = discarded if credit_type == 'expired': credit.expiration_date = expiration_date