From c648090b5d18c58af658ec4fe88114741efa60c7 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Fri, 12 Jan 2024 18:33:06 +0530 Subject: [PATCH] fix: query for filter by party --- .../tax_withholding_details.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py index d045d91f52..613d6f9fca 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -340,9 +340,6 @@ def get_tds_docs_query(filters, bank_accounts, tds_accounts): if filters.get("to_date"): query = query.where(gle.posting_date <= filters.get("to_date")) - if bank_accounts: - query = query.where(gle.against.notin(bank_accounts)) - if filters.get("party"): party = [filters.get("party")] jv_condition = gle.against.isin(party) | ( @@ -354,7 +351,14 @@ def get_tds_docs_query(filters, bank_accounts, tds_accounts): (gle.voucher_type == "Journal Entry") & ((gle.party_type == filters.get("party_type")) | (gle.party_type == "")) ) - query = query.where((gle.account.isin(tds_accounts) & jv_condition) | gle.party.isin(party)) + + query.where((gle.account.isin(tds_accounts) & jv_condition) | gle.party.isin(party)) + if bank_accounts: + query = query.where( + gle.against.notin(bank_accounts) & (gle.account.isin(tds_accounts) & jv_condition) + | gle.party.isin(party) + ) + return query