Stop trying to be smart about "best fit" cases/units for receiving

i.e. just record amounts as provided by the user.  sometimes it is necessary
for the user to avoid "cases" altogether if they detect the "case quantity" to
be incorrect
This commit is contained in:
Lance Edgar 2018-07-10 16:43:21 -05:00
parent 477a34cfa7
commit 16ab8b6ffa

View file

@ -702,22 +702,17 @@ class ReceivingBatchView(PurchasingBatchView):
cases = update_form.validated['cases']
units = update_form.validated['units']
# try to be smart about how we update cases and units for row
existing = getattr(self.handler, 'get_units_{}'.format(mode))(row)
proposed = existing + self.handler.get_units(cases, units, row.case_quantity)
new_cases, new_units = self.handler.calc_best_fit(proposed, row.case_quantity)
old_cases = getattr(row, 'cases_{}'.format(mode))
if new_cases and old_cases != new_cases:
setattr(row, 'cases_{}'.format(mode), new_cases)
elif old_cases and not new_cases:
setattr(row, 'cases_{}'.format(mode), None)
old_units = getattr(row, 'units_{}'.format(mode))
if new_units and old_units != new_units:
setattr(row, 'units_{}'.format(mode), new_units)
elif old_units and not new_units:
setattr(row, 'units_{}'.format(mode), None)
# add values as-is to existing case/unit amounts. note
# that this can sometimes give us negative values! e.g. if
# user scans 1 CS and then subtracts 2 EA, then we would
# have 1 / -2 for our counts. but we consider that to be
# expected, and other logic must allow for the possibility
if cases:
setattr(row, 'cases_{}'.format(mode),
(getattr(row, 'cases_{}'.format(mode)) or 0) + cases)
if units:
setattr(row, 'units_{}'.format(mode),
(getattr(row, 'units_{}'.format(mode)) or 0) + units)
# if mode in ('damaged', 'expired', 'mispick'):
if mode in ('damaged', 'expired'):