fix(journal-entry): auto-populate bank account when user selects account (#50744)

* fix(journal-entry): auto-populate bank account when user selects account

* refactor(journal-entry): simplify get_value call and return None by default

---------

Co-authored-by: Jatin3128 <jatinsarna8@gmail.com>
This commit is contained in:
Jatin3128
2025-11-26 17:26:33 +05:30
committed by GitHub
parent d17120909c
commit 0e7f75f5c0
2 changed files with 14 additions and 0 deletions

View File

@@ -720,6 +720,8 @@ $.extend(erpnext.journal_entry, {
}
},
});
} else {
erpnext.journal_entry.clear_fields(frm, dt, dn);
}
},
set_amount_on_last_row: function (frm, dt, dn) {
@@ -744,4 +746,13 @@ $.extend(erpnext.journal_entry, {
}
refresh_field("accounts");
},
clear_fields: function (frm, dt, dn) {
let row = locals[dt][dn];
row.party_type = null;
row.party = null;
row.bank_account = null;
frm.refresh_field("accounts");
},
});

View File

@@ -1719,6 +1719,9 @@ def get_account_details_and_party_type(account, date, company, debit=None, credi
"party_type": party_type,
"account_type": account_details.account_type,
"account_currency": account_details.account_currency or company_currency,
"bank_account": (
frappe.db.get_value("Bank Account", {"account": account, "company": company}) or None
),
# The date used to retreive the exchange rate here is the date passed in
# as an argument to this function. It is assumed to be the date on which the balance is sought
"exchange_rate": get_exchange_rate(