From 1c77506e80133cbfe6d72074c7611d702de34329 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 Dec 2015 18:59:34 +0530 Subject: [PATCH 1/2] [fix] Don't overwrite exchange rate on saving for bank transfer --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 6 +----- erpnext/accounts/doctype/journal_entry/journal_entry.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index b1c355b375..479eaafd23 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -368,10 +368,6 @@ frappe.ui.form.on("Journal Entry Account", { credit: function(frm, dt, dn) { cur_frm.cscript.update_totals(frm.doc); - }, - - exchange_rate: function(frm, cdt, cdn) { - erpnext.journal_entry.set_debit_credit_in_company_currency(frm, cdt, cdn); } }) @@ -418,7 +414,7 @@ $.extend(erpnext.journal_entry, { if(row.account_currency == company_currency || !frm.doc.multi_currency) { frappe.model.set_value(cdt, cdn, "exchange_rate", 1); - } else if (!row.exchange_rate || row.account_type == "Bank") { + } else if (!row.exchange_rate || row.exchange_rate == 1 || row.account_type == "Bank") { frappe.call({ method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_exchange_rate", args: { diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index eefa0db1bb..c540582802 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -295,7 +295,7 @@ class JournalEntry(AccountsController): for d in self.get("accounts"): if d.account_currency == self.company_currency: d.exchange_rate = 1 - elif not d.exchange_rate or d.account_type=="Bank" or \ + elif not d.exchange_rate or d.exchange_rate == 1 or \ (d.reference_type in ("Sales Invoice", "Purchase Invoice") and d.reference_name): d.exchange_rate = get_exchange_rate(d.account, d.account_currency, self.company, d.reference_type, d.reference_name, d.debit, d.credit, d.exchange_rate) From f58a3726a796f5a43518ed8c08e2245579e1439a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 2 Dec 2015 11:13:20 +0530 Subject: [PATCH 2/2] Balance in chart of accounts in both company and account currency --- erpnext/accounts/page/accounts_browser/accounts_browser.js | 5 ++++- erpnext/accounts/page/accounts_browser/accounts_browser.py | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index 6a2a8312f2..403c1cea02 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -166,7 +166,10 @@ erpnext.AccountsChart = Class.extend({ var dr_or_cr = node.data.balance < 0 ? "Cr" : "Dr"; if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) { $('' - + format_currency(Math.abs(node.data.balance), node.data.account_currency) + + (node.data.balance_in_account_currency ? + (format_currency(Math.abs(node.data.balance_in_account_currency), + node.data.account_currency) + " / ") : "") + + format_currency(Math.abs(node.data.balance), node.data.company_currency) + " " + dr_or_cr + '').insertBefore(node.$ul); } diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.py b/erpnext/accounts/page/accounts_browser/accounts_browser.py index 210c4bf729..891a05de7b 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.py +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.py @@ -44,7 +44,12 @@ def get_children(): args['parent'], as_dict=1) if ctype == 'Account': + company_currency = frappe.db.get_value("Company", company, "default_currency") for each in acc: - each["balance"] = flt(get_balance_on(each.get("value"))) + each["company_currency"] = company_currency + each["balance"] = flt(get_balance_on(each.get("value"), in_account_currency=False)) + + if each.account_currency != company_currency: + each["balance_in_account_currency"] = flt(get_balance_on(each.get("value"))) return acc