From 9e9e37d39b0301807a6d258ac4d42ebcfd44ab79 Mon Sep 17 00:00:00 2001 From: Britlog Date: Tue, 13 Nov 2018 07:04:27 +0100 Subject: [PATCH] [Fix] Conversion factor in offline POS (#15867) --- erpnext/accounts/doctype/sales_invoice/pos.py | 8 ++++++-- erpnext/accounts/page/pos/pos.js | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index f2a5c16bad9..7348e1f8ece 100755 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -165,9 +165,12 @@ def get_items_list(pos_profile, company): select i.name, i.item_code, i.item_name, i.description, i.item_group, i.has_batch_no, i.has_serial_no, i.is_stock_item, i.brand, i.stock_uom, i.image, - id.expense_account, id.selling_cost_center, id.default_warehouse + id.expense_account, id.selling_cost_center, id.default_warehouse, + i.sales_uom, c.conversion_factor from - `tabItem` i LEFT JOIN `tabItem Default` id ON id.parent = i.name and id.company = %s + `tabItem` i + left join `tabItem Default` id on id.parent = i.name and id.company = %s + left join `tabUOM Conversion Detail` c on i.name = c.parent and i.sales_uom = c.uom where i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1 {cond} @@ -534,6 +537,7 @@ def validate_item(doc): item_doc.item_name = item.get('item_name') item_doc.description = item.get('description') item_doc.stock_uom = item.get('stock_uom') + item_doc.uom = item.get('uom') item_doc.item_group = item.get('item_group') item_doc.append('item_defaults', { "company": doc.get("company"), diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index 314b91bea51..91f3711f8d9 100755 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -1407,6 +1407,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.child.item_code = this.items[0].item_code; this.child.item_name = this.items[0].item_name; this.child.stock_uom = this.items[0].stock_uom; + this.child.uom = this.items[0].sales_uom || this.items[0].stock_uom; + this.child.conversion_factor = this.items[0].conversion_factor || 1; this.child.brand = this.items[0].brand; this.child.description = this.items[0].description || this.items[0].item_name; this.child.discount_percentage = 0.0; @@ -1416,8 +1418,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.child.income_account = this.pos_profile_data['income_account'] || this.items[0].income_account; this.child.warehouse = (this.item_serial_no[this.child.item_code] ? this.item_serial_no[this.child.item_code][1] : (this.pos_profile_data['warehouse'] || this.items[0].default_warehouse)); - this.child.price_list_rate = flt(this.price_list_data[this.child.item_code], 9) / flt(this.frm.doc.conversion_rate, 9); - this.child.rate = flt(this.price_list_data[this.child.item_code], 9) / flt(this.frm.doc.conversion_rate, 9); + this.child.price_list_rate = flt(this.price_list_data[this.child.item_code] * this.child.conversion_factor, 9) / flt(this.frm.doc.conversion_rate, 9); + this.child.rate = flt(this.price_list_data[this.child.item_code] * this.child.conversion_factor, 9) / flt(this.frm.doc.conversion_rate, 9); this.child.actual_qty = me.get_actual_qty(this.items[0]); this.child.amount = flt(this.child.qty) * flt(this.child.rate); this.child.batch_no = this.item_batch_no[this.child.item_code];