Skip to content

Commit

Permalink
fix: don't validate for currency, if account is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Mar 17, 2024
1 parent 1ff8a6f commit 3cde81b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions erpnext/accounts/doctype/bank_transaction/bank_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ def validate_currency(self):
Bank Transaction should be on the same currency as the Bank Account.
"""
if self.currency and self.bank_account:
account = frappe.get_cached_value("Bank Account", self.bank_account, "account")
account_currency = frappe.get_cached_value("Account", account, "account_currency")

if self.currency != account_currency:
frappe.throw(
_(
"Transaction currency: {0} cannot be different from Bank Account({1}) currency: {2}"
).format(
frappe.bold(self.currency), frappe.bold(self.bank_account), frappe.bold(account_currency)
if account := frappe.get_cached_value("Bank Account", self.bank_account, "account"):
account_currency = frappe.get_cached_value("Account", account, "account_currency")

if self.currency != account_currency:
frappe.throw(
_(
"Transaction currency: {0} cannot be different from Bank Account({1}) currency: {2}"
).format(
frappe.bold(self.currency), frappe.bold(self.bank_account), frappe.bold(account_currency)
)
)
)

def set_status(self):
if self.docstatus == 2:
Expand Down

0 comments on commit 3cde81b

Please sign in to comment.