From d2f03c8a650d4ebbf2f227cbf90c1e395bfa3641 Mon Sep 17 00:00:00 2001 From: RitvikSardana <65544983+RitvikSardana@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:00:54 +0530 Subject: [PATCH] fix: payment recon not showing payment entry when party_type is Student (#36920) * fix: payment recon not showing payment entry when party_type is Student * chore: code cleanup * fix: payment recon based on account_type which is fetched from Party Type master --- erpnext/accounts/party.py | 2 +- erpnext/controllers/accounts_controller.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 8bd7b5a3fe..b99bb83c5b 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -409,7 +409,7 @@ def get_party_account(party_type, party=None, company=None, include_advance=Fals if (account and account_currency != existing_gle_currency) or not account: account = get_party_gle_account(party_type, party, company) - if include_advance and party_type in ["Customer", "Supplier"]: + if include_advance and party_type in ["Customer", "Supplier", "Student"]: advance_account = get_party_advance_account(party_type, party, company) if advance_account: return [account, advance_account] diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 9725c25729..0ca1e94427 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2437,7 +2437,8 @@ def get_common_query( limit, condition, ): - payment_type = "Receive" if party_type == "Customer" else "Pay" + account_type = frappe.db.get_value("Party Type", party_type, "account_type") + payment_type = "Receive" if account_type == "Receivable" else "Pay" payment_entry = frappe.qb.DocType("Payment Entry") q = ( @@ -2454,7 +2455,7 @@ def get_common_query( .where(payment_entry.docstatus == 1) ) - if party_type == "Customer": + if payment_type == "Receive": q = q.select((payment_entry.paid_from_account_currency).as_("currency")) q = q.select(payment_entry.paid_from) q = q.where(payment_entry.paid_from.isin(party_account))