fix: Default company bank account
diff --git a/erpnext/accounts/doctype/bank_account/bank_account.py b/erpnext/accounts/doctype/bank_account/bank_account.py
index bfc8b33..8da4566 100644
--- a/erpnext/accounts/doctype/bank_account/bank_account.py
+++ b/erpnext/accounts/doctype/bank_account/bank_account.py
@@ -115,6 +115,10 @@
return frappe.db.get_value(party_type, party, "default_bank_account")
+def get_default_company_bank_account(company):
+ return frappe.db.get_value("Bank Account", {"company": company, "is_company_account": 1, "is_default": 1})
+
+
@frappe.whitelist()
def get_bank_account_details(bank_account):
return frappe.get_cached_value(
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 781d9f5..0ac0156 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -470,6 +470,9 @@
() => frm.events.set_dynamic_labels(frm),
() => {
frm.set_party_account_based_on_party = false;
+ if (r.message.party_bank_account) {
+ frm.set_value("party_bank_account", r.message.party_bank_account);
+ }
if (r.message.bank_account) {
frm.set_value("bank_account", r.message.bank_account);
}
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index e2041bf..79a6c9c 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -16,6 +16,7 @@
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_dimensions
from erpnext.accounts.doctype.bank_account.bank_account import (
get_bank_account_details,
+ get_default_company_bank_account,
get_party_bank_account,
)
from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import (
@@ -2109,7 +2110,9 @@
party_name = frappe.db.get_value(party_type, party, _party_name)
party_balance = get_balance_on(party_type=party_type, party=party, cost_center=cost_center)
if party_type in ["Customer", "Supplier"]:
- bank_account = get_party_bank_account(party_type, party)
+ party_bank_account = get_party_bank_account(party_type, party)
+
+ bank_account = get_default_company_bank_account(company)
return {
"party_account": party_account,
@@ -2117,6 +2120,7 @@
"party_account_currency": account_currency,
"party_balance": party_balance,
"account_balance": account_balance,
+ "party_bank_account": party_bank_account,
"bank_account": bank_account,
}