Fix some UOM bugs for new customer order

This commit is contained in:
Lance Edgar 2021-01-27 08:50:20 -06:00
parent 480d878db8
commit d1d64ec96c
2 changed files with 24 additions and 14 deletions

View file

@ -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() { fetchProductByUPC() {
let params = { let params = {
action: 'find_product_by_upc', action: 'find_product_by_upc',
@ -714,6 +729,7 @@
this.productUUID = response.data.uuid this.productUUID = response.data.uuid
this.productUPC = response.data.upc_pretty this.productUPC = response.data.upc_pretty
this.productDisplay = response.data.full_description this.productDisplay = response.data.full_description
this.setProductUnitChoices(response.data.uom_choices)
} }
}) })
}, },
@ -728,18 +744,7 @@
this.submitBatchData(params, response => { this.submitBatchData(params, response => {
this.productUPC = response.data.upc_pretty this.productUPC = response.data.upc_pretty
this.productDisplay = response.data.full_description this.productDisplay = response.data.full_description
this.productUnitChoices = response.data.uom_choices this.setProductUnitChoices(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
}
}) })
} else { } else {
this.clearProduct() this.clearProduct()

View file

@ -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 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.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({ data.update({
'order_quantity_display': "{} {} (× {} {} = {} {})".format( 'order_quantity_display': "{} {} (× {} {} = {} {})".format(
data['order_quantity'], data['order_quantity'],
self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE], self.enum.UNIT_OF_MEASURE[self.enum.UNIT_OF_MEASURE_CASE],
data['case_quantity'], case_qty,
self.enum.UNIT_OF_MEASURE[unit_uom], self.enum.UNIT_OF_MEASURE[unit_uom],
pretty_quantity(row.order_quantity * row.case_quantity), unit_qty,
self.enum.UNIT_OF_MEASURE[unit_uom]), self.enum.UNIT_OF_MEASURE[unit_uom]),
}) })
else: else: