Add initial/basic support for damaged/expired items in receiving batch

This commit is contained in:
Lance Edgar 2016-12-09 15:30:14 -06:00
parent dd08b71458
commit 1ab2a70e60
3 changed files with 36 additions and 9 deletions

View file

@ -69,6 +69,18 @@
$('#receiving-form').submit(); $('#receiving-form').submit();
}); });
$('#damaged').click(function() {
$(this).button('disable').button('option', 'label', "Working...");
$('#mode').val('damaged');
$('#receiving-form').submit();
});
$('#expired').click(function() {
$(this).button('disable').button('option', 'label', "Working...");
$('#mode').val('expired');
$('#receiving-form').submit();
});
$('#receiving-form').submit(function() { $('#receiving-form').submit(function() {
$(this).mask("Working..."); $(this).mask("Working...");
}); });
@ -138,8 +150,8 @@
<div class="buttons"> <div class="buttons">
<button type="button" id="received">Received</button> <button type="button" id="received">Received</button>
<button type="button" id="damaged" disabled="disabled">Damaged</button> <button type="button" id="damaged">Damaged</button>
<button type="button" id="expired" disabled="disabled">Expired</button> <button type="button" id="expired">Expired</button>
<button type="button" id="mispick" disabled="disabled">Mispick</button> <button type="button" id="mispick" disabled="disabled">Mispick</button>
</div> </div>

View file

@ -54,8 +54,8 @@ class ReceivingForm(forms.Schema):
allow_extra_fields = True allow_extra_fields = True
filter_extra_fields = True filter_extra_fields = True
mode = fe.validators.OneOf([ mode = fe.validators.OneOf([
'received', 'received', 'damaged', 'expired',
# 'damaged', 'expired', 'mispick', # 'mispick',
]) ])
product = forms.validators.ValidProduct() product = forms.validators.ValidProduct()
cases = fe.validators.Int() cases = fe.validators.Int()
@ -364,6 +364,7 @@ class PurchaseBatchView(BatchMasterView):
super(PurchaseBatchView, self)._preconfigure_row_fieldset(fs) super(PurchaseBatchView, self)._preconfigure_row_fieldset(fs)
fs.upc.set(label="UPC") fs.upc.set(label="UPC")
fs.brand_name.set(label="Brand") fs.brand_name.set(label="Brand")
fs.case_quantity.set(readonly=True)
fs.po_unit_cost.set(label="PO Unit Cost") fs.po_unit_cost.set(label="PO Unit Cost")
fs.po_total.set(label="PO Total", renderer=forms.renderers.CurrencyFieldRenderer) fs.po_total.set(label="PO Total", renderer=forms.renderers.CurrencyFieldRenderer)
fs.invoice_total.set(renderer=forms.renderers.CurrencyFieldRenderer) fs.invoice_total.set(renderer=forms.renderers.CurrencyFieldRenderer)
@ -405,6 +406,10 @@ class PurchaseBatchView(BatchMasterView):
fs.units_ordered, fs.units_ordered,
fs.cases_received, fs.cases_received,
fs.units_received, fs.units_received,
fs.cases_damaged,
fs.units_damaged,
fs.cases_expired,
fs.units_expired,
fs.po_total, fs.po_total,
fs.invoice_total, fs.invoice_total,
fs.status_code, fs.status_code,
@ -428,6 +433,7 @@ class PurchaseBatchView(BatchMasterView):
fs.product.set(readonly=True) fs.product.set(readonly=True)
del fs.po_total del fs.po_total
del fs.invoice_total del fs.invoice_total
del fs.status_code
elif self.viewing: elif self.viewing:
del fs.item_lookup del fs.item_lookup
@ -627,7 +633,6 @@ class PurchaseBatchView(BatchMasterView):
form = forms.SimpleForm(self.request, schema=ReceivingForm) form = forms.SimpleForm(self.request, schema=ReceivingForm)
if form.validate(): if form.validate():
assert form.data['mode'] == 'received' # TODO
product = form.data['product'] product = form.data['product']
rows = [row for row in batch.active_rows() if row.product is product] rows = [row for row in batch.active_rows() if row.product is product]
@ -640,10 +645,16 @@ class PurchaseBatchView(BatchMasterView):
row = model.PurchaseBatchRow() row = model.PurchaseBatchRow()
row.product = product row.product = product
if form.data['cases']: mode = form.data['mode']
row.cases_received = (row.cases_received or 0) + form.data['cases'] if mode in ('received', 'damaged', 'expired'):
if form.data['units']: if form.data['cases']:
row.units_received = (row.units_received or 0) + form.data['units'] setattr(row, 'cases_{}'.format(mode),
(getattr(row, 'cases_{}'.format(mode)) or 0) + form.data['cases'])
if form.data['units']:
setattr(row, 'units_{}'.format(mode),
(getattr(row, 'units_{}'.format(mode)) or 0) + form.data['units'])
else:
assert False # TODO (mispick)
if not row.uuid: if not row.uuid:
batch.add_row(row) batch.add_row(row)

View file

@ -248,6 +248,10 @@ class PurchaseView(MasterView):
fs.units_ordered, fs.units_ordered,
fs.cases_received, fs.cases_received,
fs.units_received, fs.units_received,
fs.cases_damaged,
fs.units_damaged,
fs.cases_expired,
fs.units_expired,
fs.po_unit_cost, fs.po_unit_cost,
fs.po_total, fs.po_total,
fs.invoice_unit_cost, fs.invoice_unit_cost,