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