Payment Entry included in Bank Reconciliation and related reports
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 8d11374..f430b99 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -181,8 +181,16 @@
{"parenttype": party_group_doctype, "parent": group, "company": company}, "account")
if not account:
- default_account_name = "default_receivable_account" if party_type=="Customer" else "default_payable_account"
+ default_account_name = "default_receivable_account" \
+ if party_type=="Customer" else "default_payable_account"
account = frappe.db.get_value("Company", company, default_account_name)
+
+ existing_gle_currency = get_party_gle_currency(party_type, party, company)
+ if existing_gle_currency:
+ if account:
+ account_currency = frappe.db.get_value("Account", account, "account_currency")
+ if (account and account_currency != existing_gle_currency) or not account:
+ account = get_party_gle_account(party_type, party, company)
return account
@@ -203,6 +211,17 @@
return frappe.local_cache("party_gle_currency", (party_type, party, company), generator,
regenerate_if_none=True)
+
+def get_party_gle_account(party_type, party, company):
+ def generator():
+ existing_gle_account = frappe.db.sql("""select account from `tabGL Entry`
+ where docstatus=1 and company=%(company)s and party_type=%(party_type)s and party=%(party)s
+ limit 1""", { "company": company, "party_type": party_type, "party": party })
+
+ return existing_gle_account[0][0] if existing_gle_account else None
+
+ return frappe.local_cache("party_gle_account", (party_type, party, company), generator,
+ regenerate_if_none=True)
def validate_party_gle_currency(party_type, party, company, party_account_currency=None):
"""Validate party account currency with existing GL Entry's currency"""