mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 03:03:50 +00:00
fix: on changes of paid from/to account fetch company bank account
(cherry picked from commit 4901dc2531)
This commit is contained in:
committed by
Mergify
parent
0023476500
commit
3d8a344173
@@ -592,6 +592,8 @@ frappe.ui.form.on("Payment Entry", {
|
|||||||
paid_from: function (frm) {
|
paid_from: function (frm) {
|
||||||
if (frm.set_party_account_based_on_party) return;
|
if (frm.set_party_account_based_on_party) return;
|
||||||
|
|
||||||
|
frm.events.set_company_bank_account(frm);
|
||||||
|
|
||||||
frm.events.set_account_currency_and_balance(
|
frm.events.set_account_currency_and_balance(
|
||||||
frm,
|
frm,
|
||||||
frm.doc.paid_from,
|
frm.doc.paid_from,
|
||||||
@@ -609,6 +611,8 @@ frappe.ui.form.on("Payment Entry", {
|
|||||||
paid_to: function (frm) {
|
paid_to: function (frm) {
|
||||||
if (frm.set_party_account_based_on_party) return;
|
if (frm.set_party_account_based_on_party) return;
|
||||||
|
|
||||||
|
frm.events.set_company_bank_account(frm);
|
||||||
|
|
||||||
frm.events.set_account_currency_and_balance(
|
frm.events.set_account_currency_and_balance(
|
||||||
frm,
|
frm,
|
||||||
frm.doc.paid_to,
|
frm.doc.paid_to,
|
||||||
@@ -1350,6 +1354,8 @@ frappe.ui.form.on("Payment Entry", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
bank_account: function (frm) {
|
bank_account: function (frm) {
|
||||||
|
if (frm.set_company_bank_account_based_on_coa) return;
|
||||||
|
|
||||||
const field = frm.doc.payment_type == "Pay" ? "paid_from" : "paid_to";
|
const field = frm.doc.payment_type == "Pay" ? "paid_from" : "paid_to";
|
||||||
if (frm.doc.bank_account && ["Pay", "Receive"].includes(frm.doc.payment_type)) {
|
if (frm.doc.bank_account && ["Pay", "Receive"].includes(frm.doc.payment_type)) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
@@ -1388,6 +1394,34 @@ frappe.ui.form.on("Payment Entry", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
set_company_bank_account: function (frm) {
|
||||||
|
if (!["Pay", "Receive"].includes(frm.doc.payment_type)) return;
|
||||||
|
|
||||||
|
const field = frm.doc.payment_type == "Pay" ? "paid_from" : "paid_to";
|
||||||
|
|
||||||
|
if (!frm.doc.company || !frm.doc[field]) return;
|
||||||
|
|
||||||
|
frm.set_company_bank_account_based_on_coa = true;
|
||||||
|
|
||||||
|
frappe.call({
|
||||||
|
method: "frappe.client.get_value",
|
||||||
|
args: {
|
||||||
|
doctype: "Bank Account",
|
||||||
|
filters: {
|
||||||
|
company: frm.doc.company,
|
||||||
|
account: frm.doc[field],
|
||||||
|
disabled: 0,
|
||||||
|
},
|
||||||
|
fieldname: ["name"],
|
||||||
|
},
|
||||||
|
callback: async function (r) {
|
||||||
|
if (r.message) await frm.set_value("bank_account", r.message.name);
|
||||||
|
|
||||||
|
frm.set_company_bank_account_based_on_coa = false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
sales_taxes_and_charges_template: function (frm) {
|
sales_taxes_and_charges_template: function (frm) {
|
||||||
frm.trigger("fetch_taxes_from_template");
|
frm.trigger("fetch_taxes_from_template");
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user