From 63bdd679d0d911d10d01cd8ab7b128992daf08f4 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sat, 27 Aug 2016 01:35:31 +0530 Subject: [PATCH] [POS] Fixes and cleanup --- erpnext/accounts/doctype/sales_invoice/pos.py | 15 +++++++++------ erpnext/public/js/controllers/taxes_and_totals.js | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index 599e9b1e1f0..5336b5452cf 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -23,7 +23,8 @@ def get_pos_data(): frappe.msgprint('' + _("Welcome to POS: Create your POS Profile") + ''); - update_pos_profile_data(doc, pos_profile) + company_data = get_company_data(doc.company) + update_pos_profile_data(doc, pos_profile, company_data) update_multi_mode_option(doc, pos_profile) default_print_format = pos_profile.get('print_format') or "Point of Sale" print_template = frappe.db.get_value('Print Format', default_print_format, 'html') @@ -32,7 +33,7 @@ def get_pos_data(): 'doc': doc, 'default_customer': pos_profile.get('customer'), 'items': get_items(doc, pos_profile), - 'customers': get_customers(pos_profile, doc), + 'customers': get_customers(pos_profile, doc, company_data.default_currency), 'pricing_rules': get_pricing_rules(doc), 'print_template': print_template, 'meta': { @@ -42,8 +43,10 @@ def get_pos_data(): } } -def update_pos_profile_data(doc, pos_profile): - company_data = frappe.db.get_value('Company', doc.company, '*', as_dict=1) +def get_company_data(company): + return frappe.get_all('Company', fields = ["*"], filters= {'name': company})[0] + +def update_pos_profile_data(doc, pos_profile, company_data): doc.campaign = pos_profile.get('campaign') doc.write_off_account = pos_profile.get('write_off_account') or \ @@ -148,14 +151,14 @@ def get_serial_nos(item, pos_profile, company): return serial_no_list -def get_customers(pos_profile, doc): +def get_customers(pos_profile, doc, company_currency): filters = {'disabled': 0} customer_list = [] customers = frappe.get_all("Customer", fields=["*"], filters = filters) for customer in customers: customer_currency = get_party_account_currency('Customer', customer.name, doc.company) or doc.currency - if customer_currency == doc.currency: + if customer_currency == doc.currency or customer_currency == company_currency: customer_list.append(customer) return customer_list diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 06c2b3b4b66..8e14922e653 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -586,7 +586,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){ $.each(this.frm.doc['payments'] || [], function(index, data){ if(data.type == "Cash" && payment_status) { - data.amount = total_amount_to_pay; + data.base_amount = flt(total_amount_to_pay, precision("base_amount")); + data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount")); payment_status = false; }else if(me.frm.doc.paid_amount){ data.amount = 0.0; @@ -599,7 +600,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ var me = this; var paid_amount = base_paid_amount = 0.0; $.each(this.frm.doc['payments'] || [], function(index, data){ - data.base_amount = flt(data.amount * me.frm.doc.conversion_rate); + data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount")); paid_amount += data.amount; base_paid_amount += data.base_amount; })