Skip to content

Commit 071a28f

Browse files
refactor: use consistent report column names (backport #54451) (#54518)
* refactor: use consistent report column names (cherry picked from commit 7630c01) * refactor: better label for entity type (cherry picked from commit 8e12bda) * fix: add party_type for dynamic link and add it to grouping key (cherry picked from commit a3ad1fb) * fix: use key consistently (cherry picked from commit 8f9a5e6) --------- Co-authored-by: Smit Vora <smitvora203@gmail.com>
1 parent b6902ef commit 071a28f

3 files changed

Lines changed: 27 additions & 20 deletions

File tree

erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def get_result(filters, tds_accounts, tax_category_map, net_total_map):
119119

120120
row.update(
121121
{
122-
"section_code": tax_withholding_category or "",
123-
"entity_type": party_map.get(party, {}).get(party_type),
122+
"tax_withholding_category": tax_withholding_category or "",
123+
"party_entity_type": party_map.get(party, {}).get(party_type),
124124
"rate": rate,
125125
"total_amount": total_amount,
126126
"grand_total": grand_total,
@@ -141,7 +141,7 @@ def get_result(filters, tds_accounts, tax_category_map, net_total_map):
141141
else:
142142
entries[key] = row
143143
out = list(entries.values())
144-
out.sort(key=lambda x: (x["section_code"], x["transaction_date"], x["ref_no"]))
144+
out.sort(key=lambda x: (x["tax_withholding_category"], x["transaction_date"], x["ref_no"]))
145145

146146
return out
147147

@@ -205,9 +205,9 @@ def get_columns(filters):
205205
pan = "pan" if frappe.db.has_column(filters.party_type, "pan") else "tax_id"
206206
columns = [
207207
{
208-
"label": _("Section Code"),
208+
"label": _("Tax Withholding Category"),
209209
"options": "Tax Withholding Category",
210-
"fieldname": "section_code",
210+
"fieldname": "tax_withholding_category",
211211
"fieldtype": "Link",
212212
"width": 90,
213213
},
@@ -236,7 +236,12 @@ def get_columns(filters):
236236

237237
columns.extend(
238238
[
239-
{"label": _("Entity Type"), "fieldname": "entity_type", "fieldtype": "Data", "width": 100},
239+
{
240+
"label": _(f"{filters.get('party_type', 'Party')} Type"),
241+
"fieldname": "party_entity_type",
242+
"fieldtype": "Data",
243+
"width": 100,
244+
},
240245
]
241246
)
242247
if filters.party_type == "Supplier":

erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def check_expected_values(self, result, expected_values):
118118
voucher_expected_values = expected_values[i]
119119
voucher_actual_values = (
120120
voucher.ref_no,
121-
voucher.section_code,
121+
voucher.tax_withholding_category,
122122
voucher.rate,
123123
voucher.base_tax_withholding_net_total,
124124
voucher.base_total,

erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,25 @@ def group_by_party_and_category(data, filters):
4848
party_category_wise_map = {}
4949

5050
for row in data:
51+
key = (row.get("party_type"), row.get("party"), row.get("tax_withholding_category"))
5152
party_category_wise_map.setdefault(
52-
(row.get("party"), row.get("section_code")),
53+
key,
5354
{
5455
"pan": row.get("pan"),
5556
"tax_id": row.get("tax_id"),
5657
"party": row.get("party"),
58+
"party_type": row.get("party_type"),
5759
"party_name": row.get("party_name"),
58-
"section_code": row.get("section_code"),
59-
"entity_type": row.get("entity_type"),
60+
"tax_withholding_category": row.get("tax_withholding_category"),
61+
"party_entity_type": row.get("party_entity_type"),
6062
"rate": row.get("rate"),
6163
"total_amount": 0.0,
6264
"tax_amount": 0.0,
6365
},
6466
)
6567

66-
party_category_wise_map.get((row.get("party"), row.get("section_code")))["total_amount"] += row.get(
67-
"total_amount", 0.0
68-
)
69-
70-
party_category_wise_map.get((row.get("party"), row.get("section_code")))["tax_amount"] += row.get(
71-
"tax_amount", 0.0
72-
)
68+
party_category_wise_map.get(key)["total_amount"] += row.get("total_amount", 0.0)
69+
party_category_wise_map.get(key)["tax_amount"] += row.get("tax_amount", 0.0)
7370

7471
final_result = get_final_result(party_category_wise_map)
7572

@@ -110,13 +107,18 @@ def get_columns(filters):
110107
columns.extend(
111108
[
112109
{
113-
"label": _("Section Code"),
110+
"label": _("Tax Withholding Category"),
114111
"options": "Tax Withholding Category",
115-
"fieldname": "section_code",
112+
"fieldname": "tax_withholding_category",
116113
"fieldtype": "Link",
117114
"width": 180,
118115
},
119-
{"label": _("Entity Type"), "fieldname": "entity_type", "fieldtype": "Data", "width": 180},
116+
{
117+
"label": _(f"{filters.get('party_type', 'Party')} Type"),
118+
"fieldname": "party_entity_type",
119+
"fieldtype": "Data",
120+
"width": 180,
121+
},
120122
{
121123
"label": _("TDS Rate %") if filters.get("party_type") == "Supplier" else _("TCS Rate %"),
122124
"fieldname": "rate",

0 commit comments

Comments
 (0)