% if use_buefy:
+ @click="autoReceiveShowDialog = true"
+ icon-pack="fas"
+ icon-left="check">
Auto-Receive All Items
% else:
@@ -334,7 +348,7 @@
:disabled="autoReceiveSubmitting"
@click="autoReceiveSubmitting = true"
icon-pack="fas"
- icon-left="arrow-circle-right">
+ icon-left="check">
{{ autoReceiveSubmitting ? "Working, please wait..." : "Auto-Receive All Items" }}
${h.end_form()}
@@ -352,6 +366,10 @@
ThisPageData.autoReceiveShowDialog = false
ThisPageData.autoReceiveSubmitting = false
+ % if po_vs_invoice_breakdown_grid is not Undefined:
+ ThisPageData.poVsInvoiceBreakdownData = ${json.dumps(po_vs_invoice_breakdown_grid.get_buefy_data()['data'])|n}
+ % endif
+
%def>
diff --git a/tailbone/templates/receiving/view_row.mako b/tailbone/templates/receiving/view_row.mako
index d1c35c5b..bee71475 100644
--- a/tailbone/templates/receiving/view_row.mako
+++ b/tailbone/templates/receiving/view_row.mako
@@ -5,9 +5,37 @@
${parent.extra_styles()}
%def>
@@ -30,9 +58,20 @@
<%def name="page_content()">
% if use_buefy:
-
- ${form.render_field_readonly('sequence')}
- ${form.render_field_readonly('status_code')}
+
@@ -42,18 +81,23 @@
- % if not row.product:
+ % if row.product:
+ ${form.render_field_readonly('upc')}
+ ${form.render_field_readonly('product')}
+ % else:
${form.render_field_readonly('item_entry')}
+ ${form.render_field_readonly('upc')}
+ ${form.render_field_readonly('brand_name')}
+ ${form.render_field_readonly('description')}
+ ${form.render_field_readonly('size')}
% endif
- ${form.render_field_readonly('upc')}
- ${form.render_field_readonly('product')}
${form.render_field_readonly('vendor_code')}
${form.render_field_readonly('case_quantity')}
${form.render_field_readonly('catalog_unit_cost')}
% if image_url:
- ${h.image(image_url, "Product Image")}
+ ${h.image(image_url, "Product Image", width=150, height=150)}
% endif
@@ -64,88 +108,351 @@
Quantities
- ${form.render_field_readonly('ordered')}
- ${form.render_field_readonly('shipped')}
- ${form.render_field_readonly('received')}
- ${form.render_field_readonly('damaged')}
- ${form.render_field_readonly('expired')}
- ${form.render_field_readonly('mispick')}
+
-
-
-
-
-
-
-
-
- Purchase Order
-
-
- ${form.render_field_readonly('po_line_number')}
- ${form.render_field_readonly('po_unit_cost')}
- ${form.render_field_readonly('po_total')}
-
-
-
-
-
- Invoice
-
-
- ${form.render_field_readonly('invoice_line_number')}
- ${form.render_field_readonly('invoice_unit_cost')}
- % if master.has_perm('edit_row'):
-
-
-
+ % if master.has_perm('edit_row') and master.row_editable(row):
+
+
+ Account for Product
+
+
+ Declare Credit
+
% endif
- ${form.render_field_readonly('invoice_cost_confirmed')}
-
-
- Confirm Unit Cost
-
-
- ${form.render_field_readonly('invoice_total')}
- ${form.render_field_readonly('invoice_total_calculated')}
+
+
+
+
+
+
+
+
+
+ This is for declaring that you have encountered some
+ amount of the product. Ideally you will just
+ "receive" it normally, but you can indicate a "credit"
+ state if there is something amiss.
+
+
+
+
+
+
+ {{ rowData.case_quantity }}
+
+
+
+
+
+
+
+
+
+
+ {{ mode }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Units
+
+
+ Cases
+
+
+
+
+
+ = {{ accountForProductTotalUnits }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is for converting
+ some amount you already
+ received , and now declaring there is something
+ wrong with it.
+
+
+
+
+
+
+ {{ rowData.received }}
+
+
+
+
+
+
+
+
+
+
+ {{ typ }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Units
+
+
+ Cases
+
+
+
+
+
+ = {{ declareCreditTotalUnits }}
+
+
+
+
+
+
+
+
+
+
+
Credits
- ${form.render_field_readonly('credits')}
+ ${form.render_field_value('credits')}
+
+
+
+
+
+
+
+
+ If you un-declare this credit, the quantity below will
+ be added back to the
+ Received tally.
+
+
+
+ {{ removeCreditRow.credit_type }}
+
+
+
+ {{ removeCreditRow.shorted }}
+
+
+
+
+
+
+
+
+
+
+ % if master.batch_handler.has_purchase_order(batch):
+
+ Purchase Order
+
+
+ ${form.render_field_readonly('po_line_number')}
+ ${form.render_field_readonly('po_unit_cost')}
+ ${form.render_field_readonly('po_case_size')}
+ ${form.render_field_readonly('po_total')}
+
+
+
+ % endif
+
+ % if master.batch_handler.has_invoice_file(batch):
+
+ Invoice
+
+
+ ${form.render_field_readonly('invoice_line_number')}
+ ${form.render_field_readonly('invoice_unit_cost')}
+ ${form.render_field_readonly('invoice_case_size')}
+ ${form.render_field_readonly('invoice_total', label="Invoice Total")}
+
+
+
+ % endif
+
+
+
% else:
## legacy / not buefy
${parent.page_content()}
@@ -164,6 +471,211 @@
alert("TODO: not yet implemented")
}
+ ThisPageData.rowData = ${json.dumps(row_context)|n}
+ ThisPageData.possibleReceivingModes = ${json.dumps(possible_receiving_modes)|n}
+ ThisPageData.possibleCreditTypes = ${json.dumps(possible_credit_types)|n}
+
+ ThisPageData.accountForProductShowDialog = false
+ ThisPageData.accountForProductMode = null
+ ThisPageData.accountForProductQuantity = null
+ ThisPageData.accountForProductUOM = 'units'
+ ThisPageData.accountForProductExpiration = null
+ ThisPageData.accountForProductSubmitting = false
+
+ ThisPage.computed.accountForProductTotalUnits = function() {
+ return this.renderQuantity(this.accountForProductQuantity,
+ this.accountForProductUOM)
+ }
+
+ ThisPage.computed.accountForProductSubmitDisabled = function() {
+ if (!this.accountForProductMode) {
+ return true
+ }
+ if (this.accountForProductMode == 'expired' && !this.accountForProductExpiration) {
+ return true
+ }
+ if (!this.accountForProductQuantity) {
+ return true
+ }
+ if (this.accountForProductSubmitting) {
+ return true
+ }
+ return false
+ }
+
+ ThisPage.methods.accountForProductInit = function() {
+ this.accountForProductMode = 'received'
+ this.accountForProductExpiration = null
+ this.accountForProductQuantity = null
+ this.accountForProductUOM = 'units'
+ this.accountForProductShowDialog = true
+ }
+
+ ThisPage.methods.accountForProductUOMClicked = function(uom) {
+
+ // TODO: this does not seem to work as expected..even though
+ // the code appears to be correct
+ this.$nextTick(() => {
+ this.$refs.accountForProductQuantityInput.focus()
+ })
+ }
+
+ ThisPage.methods.accountForProductSubmit = function() {
+
+ let qty = parseFloat(this.accountForProductQuantity)
+ if (qty == NaN || !qty) {
+ this.$buefy.toast.open({
+ message: "You must enter a quantity.",
+ type: 'is-warning',
+ duration: 4000, // 4 seconds
+ })
+ return
+ }
+
+ if (this.accountForProductMode != 'received' && qty < 0) {
+ this.$buefy.toast.open({
+ message: "Negative amounts are only allowed for the \"received\" state.",
+ type: 'is-warning',
+ duration: 4000, // 4 seconds
+ })
+ return
+ }
+
+ this.accountForProductSubmitting = true
+ let url = '${url('{}.receive_row'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid)}'
+ let params = {
+ mode: this.accountForProductMode,
+ quantity: {cases: null, units: null},
+ expiration_date: this.accountForProductExpiration,
+ }
+
+ if (this.accountForProductUOM == 'cases') {
+ params.quantity.cases = this.accountForProductQuantity
+ } else {
+ params.quantity.units = this.accountForProductQuantity
+ }
+
+ this.submitForm(url, params, response => {
+ this.rowData = response.data.row
+ this.accountForProductSubmitting = false
+ this.accountForProductShowDialog = false
+ }, response => {
+ this.accountForProductSubmitting = false
+ })
+ }
+
+ ThisPageData.declareCreditShowDialog = false
+ ThisPageData.declareCreditType = null
+ ThisPageData.declareCreditExpiration = null
+ ThisPageData.declareCreditQuantity = null
+ ThisPageData.declareCreditUOM = 'units'
+ ThisPageData.declareCreditSubmitting = false
+
+ ThisPage.methods.renderQuantity = function(qty, uom) {
+ qty = parseFloat(qty)
+ if (qty == NaN) {
+ return "n/a"
+ }
+ if (uom == 'cases') {
+ qty *= this.rowData.case_quantity
+ }
+ if (qty == NaN) {
+ return "n/a"
+ }
+ if (qty == 1) {
+ return "1 unit"
+ }
+ if (qty == -1) {
+ return "-1 unit"
+ }
+ if (Math.round(qty) == qty) {
+ return qty.toString() + " units"
+ }
+ return qty.toFixed(4) + " units"
+ }
+
+ ThisPage.computed.declareCreditTotalUnits = function() {
+ return this.renderQuantity(this.declareCreditQuantity,
+ this.declareCreditUOM)
+ }
+
+ ThisPage.computed.declareCreditSubmitDisabled = function() {
+ if (!this.declareCreditType) {
+ return true
+ }
+ if (this.declareCreditType == 'expired' && !this.declareCreditExpiration) {
+ return true
+ }
+ if (!this.declareCreditQuantity) {
+ return true
+ }
+ if (this.declareCreditSubmitting) {
+ return true
+ }
+ return false
+ }
+
+ ThisPage.methods.declareCreditInit = function() {
+ this.declareCreditType = null
+ this.declareCreditExpiration = null
+ if (this.rowData.cases_received) {
+ this.declareCreditQuantity = this.rowData.cases_received
+ this.declareCreditUOM = 'cases'
+ } else {
+ this.declareCreditQuantity = this.rowData.units_received
+ this.declareCreditUOM = 'units'
+ }
+ this.declareCreditShowDialog = true
+ }
+
+ ThisPage.methods.declareCreditSubmit = function() {
+ this.declareCreditSubmitting = true
+ let url = '${url('{}.declare_credit'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid)}'
+ let params = {
+ credit_type: this.declareCreditType,
+ cases: null,
+ units: null,
+ expiration_date: this.declareCreditExpiration,
+ }
+
+ if (this.declareCreditUOM == 'cases') {
+ params.cases = this.declareCreditQuantity
+ } else {
+ params.units = this.declareCreditQuantity
+ }
+
+ this.submitForm(url, params, response => {
+ this.rowData = response.data.row
+ this.declareCreditSubmitting = false
+ this.declareCreditShowDialog = false
+ }, response => {
+ this.declareCreditSubmitting = false
+ })
+ }
+
+ ThisPageData.removeCreditShowDialog = false
+ ThisPageData.removeCreditRow = {}
+ ThisPageData.removeCreditSubmitting = false
+
+ ThisPage.methods.removeCreditInit = function(row) {
+ this.removeCreditRow = row
+ this.removeCreditShowDialog = true
+ }
+
+ ThisPage.methods.removeCreditSubmit = function() {
+ this.removeCreditSubmitting = true
+ let url = '${url('{}.undeclare_credit'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid)}'
+ let params = {
+ uuid: this.removeCreditRow.uuid,
+ }
+
+ this.submitForm(url, params, response => {
+ this.rowData = response.data.row
+ this.removeCreditSubmitting = false
+ this.removeCreditShowDialog = false
+ })
+ }
+
%def>
diff --git a/tailbone/templates/themes/falafel/base.mako b/tailbone/templates/themes/falafel/base.mako
index bf8f5ee7..2c2dd2ce 100644
--- a/tailbone/templates/themes/falafel/base.mako
+++ b/tailbone/templates/themes/falafel/base.mako
@@ -31,6 +31,8 @@
+ ${declare_formposter_mixin()}
+
${self.body()}
@@ -517,7 +519,6 @@
%def>
<%def name="declare_whole_page_vars()">
- ${declare_formposter_mixin()}
${h.javascript_link(request.static_url('tailbone:static/themes/falafel/js/tailbone.feedback.js') + '?ver={}'.format(tailbone.__version__))}