Skip to content

Commit

Permalink
Merge pull request #40796 from deepeshgarg007/pe_default_company_bank…
Browse files Browse the repository at this point in the history
…_account

fix: Default company bank account
  • Loading branch information
deepeshgarg007 authored Apr 1, 2024
2 parents 4f89906 + 7ac91de commit 6416a6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions erpnext/accounts/doctype/bank_account/bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def get_party_bank_account(party_type, party):
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(
Expand Down
3 changes: 3 additions & 0 deletions erpnext/accounts/doctype/payment_entry/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ frappe.ui.form.on("Payment Entry", {
() => 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);
}
Expand Down
6 changes: 5 additions & 1 deletion erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -2112,14 +2113,17 @@ def get_party_details(company, party_type, party, date, cost_center=None):
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,
"party_name": party_name,
"party_account_currency": account_currency,
"party_balance": party_balance,
"account_balance": account_balance,
"party_bank_account": party_bank_account,
"bank_account": bank_account,
}

Expand Down

0 comments on commit 6416a6a

Please sign in to comment.