From 7630c01e40d0de69822919f4196147ad0cfc0fb3 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Tue, 21 Apr 2026 18:33:25 +0530 Subject: [PATCH 1/4] refactor: use consistent report column names --- .../tax_withholding_details.py | 10 +++++----- .../test_tax_withholding_details.py | 2 +- .../tds_computation_summary.py | 14 +++++++------- 3 files changed, 13 insertions(+), 13 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 d93c60b2cf4..8d9dbbbe2de 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -119,8 +119,8 @@ def get_result(filters, tds_accounts, tax_category_map, net_total_map): row.update( { - "section_code": tax_withholding_category or "", - "entity_type": party_map.get(party, {}).get(party_type), + "tax_withholding_category": tax_withholding_category or "", + "party_entity_type": party_map.get(party, {}).get(party_type), "rate": rate, "total_amount": total_amount, "grand_total": grand_total, @@ -141,7 +141,7 @@ def get_result(filters, tds_accounts, tax_category_map, net_total_map): else: entries[key] = row out = list(entries.values()) - out.sort(key=lambda x: (x["section_code"], x["transaction_date"], x["ref_no"])) + out.sort(key=lambda x: (x["tax_withholding_category"], x["transaction_date"], x["ref_no"])) return out @@ -207,7 +207,7 @@ def get_columns(filters): { "label": _("Section Code"), "options": "Tax Withholding Category", - "fieldname": "section_code", + "fieldname": "tax_withholding_category", "fieldtype": "Link", "width": 90, }, @@ -236,7 +236,7 @@ def get_columns(filters): columns.extend( [ - {"label": _("Entity Type"), "fieldname": "entity_type", "fieldtype": "Data", "width": 100}, + {"label": _("Entity Type"), "fieldname": "party_entity_type", "fieldtype": "Data", "width": 100}, ] ) if filters.party_type == "Supplier": diff --git a/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py b/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py index 56dba9d86d3..a4eaa44e64a 100644 --- a/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py @@ -118,7 +118,7 @@ class TestTaxWithholdingDetails(AccountsTestMixin, FrappeTestCase): voucher_expected_values = expected_values[i] voucher_actual_values = ( voucher.ref_no, - voucher.section_code, + voucher.tax_withholding_category, voucher.rate, voucher.base_tax_withholding_net_total, voucher.base_total, diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py index cbceaeed092..71bf90d11df 100644 --- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py +++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py @@ -49,25 +49,25 @@ def group_by_party_and_category(data, filters): for row in data: party_category_wise_map.setdefault( - (row.get("party"), row.get("section_code")), + (row.get("party"), row.get("tax_withholding_category")), { "pan": row.get("pan"), "tax_id": row.get("tax_id"), "party": row.get("party"), "party_name": row.get("party_name"), - "section_code": row.get("section_code"), - "entity_type": row.get("entity_type"), + "tax_withholding_category": row.get("tax_withholding_category"), + "party_entity_type": row.get("party_entity_type"), "rate": row.get("rate"), "total_amount": 0.0, "tax_amount": 0.0, }, ) - party_category_wise_map.get((row.get("party"), row.get("section_code")))["total_amount"] += row.get( + party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))["total_amount"] += row.get( "total_amount", 0.0 ) - party_category_wise_map.get((row.get("party"), row.get("section_code")))["tax_amount"] += row.get( + party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))["tax_amount"] += row.get( "tax_amount", 0.0 ) @@ -112,11 +112,11 @@ def get_columns(filters): { "label": _("Section Code"), "options": "Tax Withholding Category", - "fieldname": "section_code", + "fieldname": "tax_withholding_category", "fieldtype": "Link", "width": 180, }, - {"label": _("Entity Type"), "fieldname": "entity_type", "fieldtype": "Data", "width": 180}, + {"label": _("Entity Type"), "fieldname": "party_entity_type", "fieldtype": "Data", "width": 180}, { "label": _("TDS Rate %") if filters.get("party_type") == "Supplier" else _("TCS Rate %"), "fieldname": "rate", From 8e12bda108bc2a354b0e90b4d01be0e166889873 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Wed, 22 Apr 2026 12:11:04 +0530 Subject: [PATCH 2/4] refactor: better label for entity type --- .../tax_withholding_details.py | 9 ++++++-- .../tds_computation_summary.py | 21 ++++++++++++------- 2 files changed, 20 insertions(+), 10 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 8d9dbbbe2de..99ac592097b 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -205,7 +205,7 @@ def get_columns(filters): pan = "pan" if frappe.db.has_column(filters.party_type, "pan") else "tax_id" columns = [ { - "label": _("Section Code"), + "label": _("Tax Withholding Category"), "options": "Tax Withholding Category", "fieldname": "tax_withholding_category", "fieldtype": "Link", @@ -236,7 +236,12 @@ def get_columns(filters): columns.extend( [ - {"label": _("Entity Type"), "fieldname": "party_entity_type", "fieldtype": "Data", "width": 100}, + { + "label": _(f"{filters.get('party_type', 'Party')} Type"), + "fieldname": "party_entity_type", + "fieldtype": "Data", + "width": 100, + }, ] ) if filters.party_type == "Supplier": diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py index 71bf90d11df..8916dbb7aa2 100644 --- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py +++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py @@ -63,13 +63,13 @@ def group_by_party_and_category(data, filters): }, ) - party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))["total_amount"] += row.get( - "total_amount", 0.0 - ) + party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))[ + "total_amount" + ] += row.get("total_amount", 0.0) - party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))["tax_amount"] += row.get( - "tax_amount", 0.0 - ) + party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))[ + "tax_amount" + ] += row.get("tax_amount", 0.0) final_result = get_final_result(party_category_wise_map) @@ -110,13 +110,18 @@ def get_columns(filters): columns.extend( [ { - "label": _("Section Code"), + "label": _("Tax Withholding Category"), "options": "Tax Withholding Category", "fieldname": "tax_withholding_category", "fieldtype": "Link", "width": 180, }, - {"label": _("Entity Type"), "fieldname": "party_entity_type", "fieldtype": "Data", "width": 180}, + { + "label": _(f"{filters.get('party_type', 'Party')} Type"), + "fieldname": "party_entity_type", + "fieldtype": "Data", + "width": 180, + }, { "label": _("TDS Rate %") if filters.get("party_type") == "Supplier" else _("TCS Rate %"), "fieldname": "rate", From a3ad1fb163d537c0dd66c78c6522d7607604eee2 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Wed, 22 Apr 2026 12:12:18 +0530 Subject: [PATCH 3/4] fix: add party_type for dynamic link and add it to grouping key --- .../report/tds_computation_summary/tds_computation_summary.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py index 8916dbb7aa2..ff8816dba4d 100644 --- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py +++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py @@ -49,11 +49,12 @@ def group_by_party_and_category(data, filters): for row in data: party_category_wise_map.setdefault( - (row.get("party"), row.get("tax_withholding_category")), + (row.get("party_type"), row.get("party"), row.get("tax_withholding_category")), { "pan": row.get("pan"), "tax_id": row.get("tax_id"), "party": row.get("party"), + "party_type": row.get("party_type"), "party_name": row.get("party_name"), "tax_withholding_category": row.get("tax_withholding_category"), "party_entity_type": row.get("party_entity_type"), From 8f9a5e6c0cf28bdbbad6c9f5fd99bc421033fda0 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 23 Apr 2026 15:01:46 +0530 Subject: [PATCH 4/4] fix: use key consistently --- .../tds_computation_summary.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py index ff8816dba4d..a1b9c22f63f 100644 --- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py +++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py @@ -48,8 +48,9 @@ def group_by_party_and_category(data, filters): party_category_wise_map = {} for row in data: + key = (row.get("party_type"), row.get("party"), row.get("tax_withholding_category")) party_category_wise_map.setdefault( - (row.get("party_type"), row.get("party"), row.get("tax_withholding_category")), + key, { "pan": row.get("pan"), "tax_id": row.get("tax_id"), @@ -64,13 +65,8 @@ def group_by_party_and_category(data, filters): }, ) - party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))[ - "total_amount" - ] += row.get("total_amount", 0.0) - - party_category_wise_map.get((row.get("party"), row.get("tax_withholding_category")))[ - "tax_amount" - ] += row.get("tax_amount", 0.0) + party_category_wise_map.get(key)["total_amount"] += row.get("total_amount", 0.0) + party_category_wise_map.get(key)["tax_amount"] += row.get("tax_amount", 0.0) final_result = get_final_result(party_category_wise_map)