From 081935eff73606f22bc34eead1594c8b113258eb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 28 Apr 2015 19:08:42 +0530 Subject: [PATCH] [fix] fetch bank/cash account --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 2 +- erpnext/accounts/doctype/journal_entry/journal_entry.py | 8 ++++---- erpnext/accounts/doctype/payment_tool/payment_tool.js | 5 ++--- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 6 ++++++ erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 6 +++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index fe533e2a44..5ff9e5fd2c 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -225,7 +225,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { var jvdetail = frappe.model.add_child(doc, "Journal Entry Account", "accounts"); $.each(r, function(i, d) { var row = frappe.model.add_child(doc, "Journal Entry Account", "accounts"); - row.account = d.cash_bank_account; + row.account = d.account; row.balance = d.balance; }); refresh_field("accounts"); diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 81608505bd..0bd230701e 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -452,8 +452,8 @@ def get_default_bank_cash_account(company, voucher_type, mode_of_payment=None): from erpnext.accounts.doctype.sales_invoice.sales_invoice import get_bank_cash_account if mode_of_payment: account = get_bank_cash_account(mode_of_payment, company) - if account.get("bank_cash_account"): - account.update({"balance": get_balance_on(account.get("bank_cash_account"))}) + if account.get("account"): + account.update({"balance": get_balance_on(account.get("account"))}) return account if voucher_type=="Bank Entry": @@ -467,7 +467,7 @@ def get_default_bank_cash_account(company, voucher_type, mode_of_payment=None): if account: return { - "cash_bank_account": account, + "account": account, "balance": get_balance_on(account) } @@ -524,7 +524,7 @@ def get_payment_entry(doc): d2 = jv.append("accounts") if bank_account: - d2.account = bank_account["cash_bank_account"] + d2.account = bank_account["account"] d2.balance = bank_account["balance"] return jv diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.js b/erpnext/accounts/doctype/payment_tool/payment_tool.js index 7224f3ba5a..cff0bd2f22 100644 --- a/erpnext/accounts/doctype/payment_tool/payment_tool.js +++ b/erpnext/accounts/doctype/payment_tool/payment_tool.js @@ -74,10 +74,9 @@ frappe.ui.form.on("Payment Tool", "payment_mode", function(frm) { "mode_of_payment": frm.doc.payment_mode, "company": frm.doc.company }, - callback: function(r, rt) { + callback: function(r, rt) { if(r.message) { - frm.doc.set_value("payment_account", r.message['bank_cash_account'] -); + cur_frm.set_value("payment_account", r.message['account']); } } }); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 36d8fdd0e6..96b47c6926 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -253,6 +253,12 @@ cur_frm.cscript.mode_of_payment = function(doc) { "mode_of_payment": doc.mode_of_payment, "company": doc.company }, + callback: function(r, rt) { + if(r.message) { + cur_frm.set_value("cash_bank_account", r.message["account"]); + } + + } }); } } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 17c3739ea7..9568c90653 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -590,12 +590,12 @@ def get_list_context(context=None): @frappe.whitelist() def get_bank_cash_account(mode_of_payment, company): - account = frappe.db.get_value("Mode of Payment Account", {"parent": mode_of_payment, "company": company}, \ - "default_account") + account = frappe.db.get_value("Mode of Payment Account", + {"parent": mode_of_payment, "company": company}, "default_account") if not account: frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment)) return { - "cash_bank_account": account + "account": account }