Add way to prevent "case" entries for inventory adjustment batch

This commit is contained in:
Lance Edgar 2018-05-23 14:48:17 -05:00
parent 57c2a7981f
commit 54bfafdbfe
4 changed files with 80 additions and 30 deletions

View file

@ -9,14 +9,20 @@
<script type="text/javascript">
function assert_quantity() {
% if allow_cases:
if ($('#cases').val() && parseFloat($('#cases').val())) {
return true;
}
% endif
if ($('#units').val() && parseFloat($('#units').val())) {
return true;
}
alert("Please provide case and/or unit quantity");
% if allow_cases:
$('#cases').select().focus();
% else:
$('#units').select().focus();
% endif
return false;
}
@ -24,7 +30,9 @@
$('#product-info p').text(msg);
$('#product-info img').hide();
$('#upc').focus().select();
% if allow_cases:
$('.field-wrapper.cases input').prop('disabled', true);
% endif
$('.field-wrapper.units input').prop('disabled', true);
$('.buttons button').button('disable');
}
@ -65,7 +73,9 @@
$('#product-info .warning').hide();
$('.product-fields').hide();
// $('.receiving-fields').hide();
% if allow_cases:
$('.field-wrapper.cases input').prop('disabled', true);
% endif
$('.field-wrapper.units input').prop('disabled', true);
$('.buttons button').button('disable');
return true;
@ -102,13 +112,19 @@
$('.product-fields').show();
}
$('#product-info .warning.notordered').show();
% if allow_cases:
$('.field-wrapper.cases input').prop('disabled', false);
% endif
$('.field-wrapper.units input').prop('disabled', false);
$('.buttons button').button('enable');
if (data.product.type2) {
$('#units').focus().select();
} else {
% if allow_cases:
$('#cases').focus().select();
% else:
$('#units').focus().select();
% endif
}
// TODO: this is maybe useful if "new products" may be added via inventory batch
@ -147,7 +163,9 @@
});
$('#upc').focus();
% if allow_cases:
$('.field-wrapper.cases input').prop('disabled', true);
% endif
$('.field-wrapper.units input').prop('disabled', true);
$('.buttons button').button('disable');
@ -232,10 +250,12 @@
</div>
<div class="field-wrapper cases">
<label for="cases">Cases</label>
<div class="field">${h.text('cases', autocomplete='off')}</div>
</div>
% if allow_cases:
<div class="field-wrapper cases">
<label for="cases">Cases</label>
<div class="field">${h.text('cases', autocomplete='off')}</div>
</div>
% endif
<div class="field-wrapper units">
<label for="units">Units</label>

View file

@ -3,22 +3,19 @@
<%namespace file="/mobile/keypad.mako" import="keypad" />
## TODO: this is broken for actual page (header) title
<%def name="title()">${h.link_to("Inventory", url('mobile.batch.inventory'))} &raquo; ${h.link_to(instance.batch.id_str, url('mobile.batch.inventory.view', uuid=instance.batch_uuid))} &raquo; ${row.upc.pretty()}</%def>
<%def name="title()">${h.link_to("Inventory", url('mobile.batch.inventory'))} &raquo; ${h.link_to(batch.id_str, url('mobile.batch.inventory.view', uuid=batch.uuid))} &raquo; ${row.upc.pretty()}</%def>
<%
unit_uom = 'LB' if row.product and row.product.weighed else 'EA'
if row.cases:
if row.cases and allow_cases:
uom = 'CS'
elif row.units:
if row.product and row.product.weighed:
uom = 'LB'
else:
uom = 'EA'
elif row.case_quantity:
uom = unit_uom
elif row.case_quantity and allow_cases:
uom = 'CS'
else:
uom = 'EA'
uom = unit_uom
%>
<div class="ui-grid-a">
@ -46,20 +43,22 @@
${uom}
</p>
% if not row.batch.executed and not row.batch.complete:
% if not batch.executed and not batch.complete:
${h.form(request.current_route_url())}
${h.csrf_token(request)}
${h.hidden('row', value=row.uuid)}
% if allow_cases:
${h.hidden('cases')}
% endif
${h.hidden('units')}
${keypad(unit_uom, uom, quantity=row.cases or row.units or 1)}
${keypad(unit_uom, uom, quantity=(row.cases or row.units or 1) if allow_cases else (row.units or 1), allow_cases=allow_cases)}
<fieldset data-role="controlgroup" data-type="horizontal" class="inventory-actions">
<button type="button" class="ui-btn-inline ui-corner-all save">Save</button>
<button type="button" class="ui-btn-inline ui-corner-all delete" disabled="disabled">Delete</button>
${h.link_to("Cancel", url('mobile.batch.inventory.view', uuid=row.batch.uuid), class_='ui-btn ui-btn-inline ui-corner-all')}
${h.link_to("Cancel", url('mobile.batch.inventory.view', uuid=batch.uuid), class_='ui-btn ui-btn-inline ui-corner-all')}
</fieldset>
${h.end_form()}

View file

@ -1,6 +1,6 @@
## -*- coding: utf-8; -*-
<%def name="keypad(unit_uom, selected_uom, quantity=1)">
<%def name="keypad(unit_uom, selected_uom, quantity=1, allow_cases=True)">
<div class="quantity-keypad-thingy" data-changed="false">
<table>
@ -31,7 +31,9 @@
<fieldset data-role="controlgroup" data-type="horizontal">
<button type="button" class="ui-btn-active keypad-quantity">${h.pretty_quantity(quantity or 1)}</button>
<button type="button" disabled="disabled">&nbsp;</button>
% if allow_cases:
${h.radio('keypad-uom', value='CS', checked=selected_uom == 'CS', label="CS")}
% endif
${h.radio('keypad-uom', value=unit_uom, checked=selected_uom == unit_uom, label=unit_uom)}
</fieldset>