From da10c6503cf68a7a89e14944dac4f54773ff281b Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 27 Jun 2018 15:20:20 -0500 Subject: [PATCH] Add support for new `credit_total` field for purchase credits --- tailbone/views/purchases/credits.py | 4 ++-- tailbone/views/purchasing/receiving.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) 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