[fix] fetch bank/cash account
This commit is contained in:
parent
2ff177a4fb
commit
081935eff7
@ -225,7 +225,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
var jvdetail = frappe.model.add_child(doc, "Journal Entry Account", "accounts");
|
var jvdetail = frappe.model.add_child(doc, "Journal Entry Account", "accounts");
|
||||||
$.each(r, function(i, d) {
|
$.each(r, function(i, d) {
|
||||||
var row = frappe.model.add_child(doc, "Journal Entry Account", "accounts");
|
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;
|
row.balance = d.balance;
|
||||||
});
|
});
|
||||||
refresh_field("accounts");
|
refresh_field("accounts");
|
||||||
|
|||||||
@ -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
|
from erpnext.accounts.doctype.sales_invoice.sales_invoice import get_bank_cash_account
|
||||||
if mode_of_payment:
|
if mode_of_payment:
|
||||||
account = get_bank_cash_account(mode_of_payment, company)
|
account = get_bank_cash_account(mode_of_payment, company)
|
||||||
if account.get("bank_cash_account"):
|
if account.get("account"):
|
||||||
account.update({"balance": get_balance_on(account.get("bank_cash_account"))})
|
account.update({"balance": get_balance_on(account.get("account"))})
|
||||||
return account
|
return account
|
||||||
|
|
||||||
if voucher_type=="Bank Entry":
|
if voucher_type=="Bank Entry":
|
||||||
@ -467,7 +467,7 @@ def get_default_bank_cash_account(company, voucher_type, mode_of_payment=None):
|
|||||||
|
|
||||||
if account:
|
if account:
|
||||||
return {
|
return {
|
||||||
"cash_bank_account": account,
|
"account": account,
|
||||||
"balance": get_balance_on(account)
|
"balance": get_balance_on(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +524,7 @@ def get_payment_entry(doc):
|
|||||||
d2 = jv.append("accounts")
|
d2 = jv.append("accounts")
|
||||||
|
|
||||||
if bank_account:
|
if bank_account:
|
||||||
d2.account = bank_account["cash_bank_account"]
|
d2.account = bank_account["account"]
|
||||||
d2.balance = bank_account["balance"]
|
d2.balance = bank_account["balance"]
|
||||||
|
|
||||||
return jv
|
return jv
|
||||||
|
|||||||
@ -74,10 +74,9 @@ frappe.ui.form.on("Payment Tool", "payment_mode", function(frm) {
|
|||||||
"mode_of_payment": frm.doc.payment_mode,
|
"mode_of_payment": frm.doc.payment_mode,
|
||||||
"company": frm.doc.company
|
"company": frm.doc.company
|
||||||
},
|
},
|
||||||
callback: function(r, rt) {
|
callback: function(r, rt) {
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
frm.doc.set_value("payment_account", r.message['bank_cash_account']
|
cur_frm.set_value("payment_account", r.message['account']);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -253,6 +253,12 @@ cur_frm.cscript.mode_of_payment = function(doc) {
|
|||||||
"mode_of_payment": doc.mode_of_payment,
|
"mode_of_payment": doc.mode_of_payment,
|
||||||
"company": doc.company
|
"company": doc.company
|
||||||
},
|
},
|
||||||
|
callback: function(r, rt) {
|
||||||
|
if(r.message) {
|
||||||
|
cur_frm.set_value("cash_bank_account", r.message["account"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -590,12 +590,12 @@ def get_list_context(context=None):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_bank_cash_account(mode_of_payment, company):
|
def get_bank_cash_account(mode_of_payment, company):
|
||||||
account = frappe.db.get_value("Mode of Payment Account", {"parent": mode_of_payment, "company": company}, \
|
account = frappe.db.get_value("Mode of Payment Account",
|
||||||
"default_account")
|
{"parent": mode_of_payment, "company": company}, "default_account")
|
||||||
if not account:
|
if not account:
|
||||||
frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment))
|
frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment))
|
||||||
return {
|
return {
|
||||||
"cash_bank_account": account
|
"account": account
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user