Add "quick receive all" support for mobile receiving
i.e. quick receive button can now receive all/remainder of the ordered qty
This commit is contained in:
parent
d4b2cf9943
commit
56392ccdd0
|
@ -74,10 +74,11 @@ $(document).on('click', 'form.receiving-update .receiving-actions button', funct
|
||||||
$(document).on('click', 'form.receiving-update .quick-receive', function() {
|
$(document).on('click', 'form.receiving-update .quick-receive', function() {
|
||||||
var form = $(this).parents('form:first');
|
var form = $(this).parents('form:first');
|
||||||
form.find('[name="mode"]').val('received');
|
form.find('[name="mode"]').val('received');
|
||||||
|
var quantity = $(this).data('quantity');
|
||||||
if ($(this).data('uom') == 'CS') {
|
if ($(this).data('uom') == 'CS') {
|
||||||
form.find('[name="cases"]').val('1');
|
form.find('[name="cases"]').val(quantity);
|
||||||
} else {
|
} else {
|
||||||
form.find('[name="units"]').val('1');
|
form.find('[name="units"]').val(quantity);
|
||||||
}
|
}
|
||||||
form.find('input[name="quick_receive"]').val('true');
|
form.find('input[name="quick_receive"]').val('true');
|
||||||
form.submit();
|
form.submit();
|
||||||
|
|
|
@ -85,10 +85,14 @@
|
||||||
${h.hidden('cases')}
|
${h.hidden('cases')}
|
||||||
${h.hidden('units')}
|
${h.hidden('units')}
|
||||||
|
|
||||||
% if allow_cases:
|
% if quick_receive:
|
||||||
<button type="button" class="quick-receive" data-uom="CS">Receive 1 CS</button>
|
% if quick_receive_all:
|
||||||
|
<button type="button" class="quick-receive" data-quantity="${quick_receive_quantity}" data-uom="${quick_receive_uom}">${quick_receive_text}</button>
|
||||||
|
% elif allow_cases:
|
||||||
|
<button type="button" class="quick-receive" data-quantity="1" data-uom="CS">Receive 1 CS</button>
|
||||||
% else:
|
% else:
|
||||||
<button type="button" class="quick-receive" data-uom="${unit_uom}">Receive 1 ${unit_uom}</button>
|
<button type="button" class="quick-receive" data-quantity="1" data-uom="${unit_uom}">Receive 1 ${unit_uom}</button>
|
||||||
|
% endif
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
${keypad(unit_uom, uom, allow_cases=allow_cases)}
|
${keypad(unit_uom, uom, allow_cases=allow_cases)}
|
||||||
|
|
|
@ -1113,6 +1113,8 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
'form': form,
|
'form': form,
|
||||||
'allow_expired': self.handler.allow_expired_credits(),
|
'allow_expired': self.handler.allow_expired_credits(),
|
||||||
'allow_cases': self.handler.allow_cases(),
|
'allow_cases': self.handler.allow_cases(),
|
||||||
|
'quick_receive': self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive', default=True),
|
||||||
|
'quick_receive_all': self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive_all', default=False)
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.request.has_perm('{}.create_row'.format(permission_prefix)):
|
if self.request.has_perm('{}.create_row'.format(permission_prefix)):
|
||||||
|
@ -1165,6 +1167,32 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
# unit_uom can vary by product
|
# unit_uom can vary by product
|
||||||
context['unit_uom'] = 'LB' if row.product and row.product.weighed else 'EA'
|
context['unit_uom'] = 'LB' if row.product and row.product.weighed else 'EA'
|
||||||
|
|
||||||
|
if context['quick_receive'] and context['quick_receive_all']:
|
||||||
|
if context['allow_cases']:
|
||||||
|
context['quick_receive_uom'] = 'CS'
|
||||||
|
raise NotImplementedError("TODO: add CS support for quick_receive_all")
|
||||||
|
else:
|
||||||
|
context['quick_receive_uom'] = context['unit_uom']
|
||||||
|
accounted_for = self.handler.get_units_accounted_for(row)
|
||||||
|
remainder = self.handler.get_units_ordered(row) - accounted_for
|
||||||
|
|
||||||
|
if accounted_for:
|
||||||
|
# some product accounted for; button should receive "remainder" only
|
||||||
|
if remainder:
|
||||||
|
remainder = pretty_quantity(remainder)
|
||||||
|
context['quick_receive_quantity'] = remainder
|
||||||
|
context['quick_receive_text'] = "Receive Remainder ({} {})".format(remainder, context['unit_uom'])
|
||||||
|
else:
|
||||||
|
# unless there is no remainder, in which case disable it
|
||||||
|
context['quick_receive'] = False
|
||||||
|
|
||||||
|
else: # nothing yet accounted for, button should receive "all"
|
||||||
|
if not remainder:
|
||||||
|
raise ValueError("why is remainder empty?")
|
||||||
|
remainder = pretty_quantity(remainder)
|
||||||
|
context['quick_receive_quantity'] = remainder
|
||||||
|
context['quick_receive_text'] = "Receive ALL ({} {})".format(remainder, context['unit_uom'])
|
||||||
|
|
||||||
# effective uom can vary in a few ways...the basic default is 'CS' if
|
# effective uom can vary in a few ways...the basic default is 'CS' if
|
||||||
# self.default_uom_is_case is true, otherwise whatever unit_uom is.
|
# self.default_uom_is_case is true, otherwise whatever unit_uom is.
|
||||||
sticky_case = self.request.session.get('tailbone.mobile.receiving.sticky_uom_is_case')
|
sticky_case = self.request.session.get('tailbone.mobile.receiving.sticky_uom_is_case')
|
||||||
|
|
Loading…
Reference in a new issue