From 1daf4022fbe0489b35b867e41eb90e56891363f6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 19 Dec 2023 13:08:27 -0600 Subject: [PATCH] Flag invoice case quantity diffs for receiving, when applicable --- rattail/batch/purchase.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rattail/batch/purchase.py b/rattail/batch/purchase.py index 99c72943..06fd6c4a 100644 --- a/rattail/batch/purchase.py +++ b/rattail/batch/purchase.py @@ -2111,11 +2111,27 @@ class PurchaseBatchHandler(BatchHandler): if batch.order_quantities_known and ( self.get_units_shipped(row) != self.get_units_accounted_for(row)): row.status_code = row.STATUS_ORDERED_RECEIVED_DIFFER + elif case_quantity_differs: cost = row.product.cost_for_vendor(batch.vendor) row.status_code = row.STATUS_CASE_QUANTITY_DIFFERS row.status_text = "batch has {} but master cost has {}".format( repr(row.case_quantity), repr(cost.case_size)) + + # the canonical "case size" for the row will always + # match the master cost record on file, but the + # invoice may have a different value. there will be + # false alarms e.g. for 6-pack soda, so we only flag + # these if *totals* also do not match, *and* if the + # case UOM is being received + elif (row.invoice_case_size is not None + and row.invoice_case_size != row.case_quantity + and row.invoice_total is not None + and row.invoice_total_calculated != row.invoice_total + and (row.cases_ordered or row.cases_shipped)): + row.status_code = row.STATUS_CASE_QUANTITY_DIFFERS + row.status_text = f"master has {row.case_quantity} but invoice has {row.invoice_case_size}" + # TODO: is this right? should out of stock just be a filter for # the user to specify, or should it affect status? elif row.out_of_stock: