diff --git a/tailbone/templates/purchases/batches/receive_form.mako b/tailbone/templates/purchases/batches/receive_form.mako index 0a76c390..f757bd66 100644 --- a/tailbone/templates/purchases/batches/receive_form.mako +++ b/tailbone/templates/purchases/batches/receive_form.mako @@ -69,6 +69,18 @@ $('#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() { $(this).mask("Working..."); }); @@ -138,8 +150,8 @@
diff --git a/tailbone/views/purchases/batch.py b/tailbone/views/purchases/batch.py index f7f346b0..820f1558 100644 --- a/tailbone/views/purchases/batch.py +++ b/tailbone/views/purchases/batch.py @@ -54,8 +54,8 @@ class ReceivingForm(forms.Schema): allow_extra_fields = True filter_extra_fields = True mode = fe.validators.OneOf([ - 'received', - # 'damaged', 'expired', 'mispick', + 'received', 'damaged', 'expired', + # 'mispick', ]) product = forms.validators.ValidProduct() cases = fe.validators.Int() @@ -364,6 +364,7 @@ class PurchaseBatchView(BatchMasterView): super(PurchaseBatchView, self)._preconfigure_row_fieldset(fs) fs.upc.set(label="UPC") fs.brand_name.set(label="Brand") + fs.case_quantity.set(readonly=True) fs.po_unit_cost.set(label="PO Unit Cost") fs.po_total.set(label="PO Total", renderer=forms.renderers.CurrencyFieldRenderer) fs.invoice_total.set(renderer=forms.renderers.CurrencyFieldRenderer) @@ -405,6 +406,10 @@ class PurchaseBatchView(BatchMasterView): fs.units_ordered, fs.cases_received, fs.units_received, + fs.cases_damaged, + fs.units_damaged, + fs.cases_expired, + fs.units_expired, fs.po_total, fs.invoice_total, fs.status_code, @@ -428,6 +433,7 @@ class PurchaseBatchView(BatchMasterView): fs.product.set(readonly=True) del fs.po_total del fs.invoice_total + del fs.status_code elif self.viewing: del fs.item_lookup @@ -627,7 +633,6 @@ class PurchaseBatchView(BatchMasterView): form = forms.SimpleForm(self.request, schema=ReceivingForm) if form.validate(): - assert form.data['mode'] == 'received' # TODO product = form.data['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.product = product - if form.data['cases']: - row.cases_received = (row.cases_received or 0) + form.data['cases'] - if form.data['units']: - row.units_received = (row.units_received or 0) + form.data['units'] + mode = form.data['mode'] + if mode in ('received', 'damaged', 'expired'): + if form.data['cases']: + 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: batch.add_row(row) diff --git a/tailbone/views/purchases/core.py b/tailbone/views/purchases/core.py index a63d7231..bf431724 100644 --- a/tailbone/views/purchases/core.py +++ b/tailbone/views/purchases/core.py @@ -248,6 +248,10 @@ class PurchaseView(MasterView): fs.units_ordered, fs.cases_received, fs.units_received, + fs.cases_damaged, + fs.units_damaged, + fs.cases_expired, + fs.units_expired, fs.po_unit_cost, fs.po_total, fs.invoice_unit_cost,