Try to be smart about how we update cases/units for receiving batch row
e.g. if you receive 1 CS (@ 12/CS) and then subtract 4 EA then you should wind up with 8 EA for the row
This commit is contained in:
parent
2983ff7ba0
commit
147c65afe6
|
@ -699,12 +699,15 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
mode = update_form.validated['mode']
|
||||
cases = update_form.validated['cases']
|
||||
units = update_form.validated['units']
|
||||
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)
|
||||
|
||||
# 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)
|
||||
if getattr(row, 'cases_{}'.format(mode)) != new_cases:
|
||||
setattr(row, 'cases_{}'.format(mode), new_cases)
|
||||
if getattr(row, 'units_{}'.format(mode)) != new_units:
|
||||
setattr(row, 'units_{}'.format(mode), new_units)
|
||||
|
||||
# if mode in ('damaged', 'expired', 'mispick'):
|
||||
if mode in ('damaged', 'expired'):
|
||||
|
|
Loading…
Reference in a new issue