diff --git a/tailbone/templates/custorders/create.mako b/tailbone/templates/custorders/create.mako index 88c902e9..866312c9 100644 --- a/tailbone/templates/custorders/create.mako +++ b/tailbone/templates/custorders/create.mako @@ -698,6 +698,21 @@ } }, + setProductUnitChoices(choices) { + this.productUnitChoices = choices + + let found = false + for (let uom of choices) { + if (this.productUOM == uom.key) { + found = true + break + } + } + if (!found) { + this.productUOM = choices[0].key + } + }, + fetchProductByUPC() { let params = { action: 'find_product_by_upc', @@ -714,6 +729,7 @@ this.productUUID = response.data.uuid this.productUPC = response.data.upc_pretty this.productDisplay = response.data.full_description + this.setProductUnitChoices(response.data.uom_choices) } }) }, @@ -728,18 +744,7 @@ this.submitBatchData(params, response => { this.productUPC = response.data.upc_pretty this.productDisplay = response.data.full_description - this.productUnitChoices = response.data.uom_choices - - let found = false - for (let uom of this.productUnitChoices) { - if (this.productUOM == uom.key) { - found = true - break - } - } - if (!found) { - this.productUOM = this.productUnitChoices[0].key - } + this.setProductUnitChoices(response.data.uom_choices) }) } else { this.clearProduct() diff --git a/tailbone/views/custorders/orders.py b/tailbone/views/custorders/orders.py index 420ac892..68ae24c1 100644 --- a/tailbone/views/custorders/orders.py +++ b/tailbone/views/custorders/orders.py @@ -363,13 +363,18 @@ class CustomerOrdersView(MasterView): unit_uom = self.enum.UNIT_OF_MEASURE_POUND if data['product_weighed'] else self.enum.UNIT_OF_MEASURE_EACH if row.order_uom == self.enum.UNIT_OF_MEASURE_CASE: + if row.case_quantity is None: + case_qty = unit_qty = '??' + else: + case_qty = data['case_quantity'] + unit_qty = pretty_quantity(row.order_quantity * row.case_quantity) data.update({ 'order_quantity_display': "{} {} (× {} {} = {} {})".format( data['order_quantity'], self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE], - data['case_quantity'], + case_qty, self.enum.UNIT_OF_MEASURE[unit_uom], - pretty_quantity(row.order_quantity * row.case_quantity), + unit_qty, self.enum.UNIT_OF_MEASURE[unit_uom]), }) else: