Add support for new credit_total field for purchase credits

This commit is contained in:
Lance Edgar 2018-06-27 15:20:20 -05:00
parent b66af5903b
commit da10c6503c
2 changed files with 10 additions and 2 deletions

View file

@ -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