Skip to content

Commit bd7e5b3

Browse files
refactor: use consistent report column names (backport #54451) (backport #54478) (#54506)
* refactor: use consistent report column names (cherry picked from commit 7630c01) # Conflicts: # erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py (cherry picked from commit ab188c4) * refactor: better label for entity type (cherry picked from commit 8e12bda) (cherry picked from commit e1ff203) * fix: add party_type for dynamic link and add it to grouping key (cherry picked from commit a3ad1fb) (cherry picked from commit 6eb2868) * fix: use key consistently (cherry picked from commit 8f9a5e6) (cherry picked from commit 32d46b3) * chore: resolve conflicts (cherry picked from commit 34e94d6) * chore: translate values correctly (cherry picked from commit 83fd655) --------- Co-authored-by: Smit Vora <smitvora203@gmail.com>
1 parent adf92a8 commit bd7e5b3

3 files changed

Lines changed: 27 additions & 20 deletions

File tree

erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py

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

5454
for row in data:
55+
key = (row.get("party_type"), row.get("party"), row.get("tax_withholding_category"))
5556
party_category_wise_map.setdefault(
56-
(row.get("party"), row.get("section_code")),
57+
key,
5758
{
5859
"pan": row.get("pan"),
5960
"tax_id": row.get("tax_id"),
6061
"party": row.get("party"),
62+
"party_type": row.get("party_type"),
6163
"party_name": row.get("party_name"),
62-
"section_code": row.get("section_code"),
63-
"entity_type": row.get("entity_type"),
64+
"tax_withholding_category": row.get("tax_withholding_category"),
65+
"party_entity_type": row.get("party_entity_type"),
6466
"rate": row.get("rate"),
6567
"total_amount": 0.0,
6668
"tax_amount": 0.0,
6769
},
6870
)
6971

70-
party_category_wise_map.get((row.get("party"), row.get("section_code")))["total_amount"] += row.get(
71-
"total_amount", 0.0
72-
)
73-
74-
party_category_wise_map.get((row.get("party"), row.get("section_code")))["tax_amount"] += row.get(
75-
"tax_amount", 0.0
76-
)
72+
party_category_wise_map.get(key)["total_amount"] += row.get("total_amount", 0.0)
73+
party_category_wise_map.get(key)["tax_amount"] += row.get("tax_amount", 0.0)
7774

7875
final_result = get_final_result(party_category_wise_map)
7976

@@ -114,13 +111,18 @@ def get_columns(filters):
114111
columns.extend(
115112
[
116113
{
117-
"label": _("Section Code"),
114+
"label": _("Tax Withholding Category"),
118115
"options": "Tax Withholding Category",
119-
"fieldname": "section_code",
116+
"fieldname": "tax_withholding_category",
120117
"fieldtype": "Link",
121118
"width": 180,
122119
},
123-
{"label": _("Entity Type"), "fieldname": "entity_type", "fieldtype": "Data", "width": 180},
120+
{
121+
"label": _("{0} Type").format(_(filters.get("party_type", "Party"))),
122+
"fieldname": "party_entity_type",
123+
"fieldtype": "Data",
124+
"width": 180,
125+
},
124126
{
125127
"label": _("TDS Rate %") if filters.get("party_type") == "Supplier" else _("TCS Rate %"),
126128
"fieldname": "rate",

erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_
106106

107107
row.update(
108108
{
109-
"section_code": tax_withholding_category or "",
110-
"entity_type": party_map.get(party, {}).get(party_type),
109+
"tax_withholding_category": tax_withholding_category or "",
110+
"party_entity_type": party_map.get(party, {}).get(party_type),
111111
"rate": rate,
112112
"total_amount": total_amount,
113113
"grand_total": grand_total,
@@ -127,7 +127,7 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_
127127
else:
128128
entries[key] = row
129129
out = list(entries.values())
130-
out.sort(key=lambda x: (x["section_code"], x["transaction_date"]))
130+
out.sort(key=lambda x: (x["tax_withholding_category"], x["transaction_date"], x["ref_no"]))
131131

132132
return out
133133

@@ -177,9 +177,9 @@ def get_columns(filters):
177177
pan = "pan" if frappe.db.has_column(filters.party_type, "pan") else "tax_id"
178178
columns = [
179179
{
180-
"label": _("Section Code"),
180+
"label": _("Tax Withholding Category"),
181181
"options": "Tax Withholding Category",
182-
"fieldname": "section_code",
182+
"fieldname": "tax_withholding_category",
183183
"fieldtype": "Link",
184184
"width": 90,
185185
},
@@ -208,7 +208,12 @@ def get_columns(filters):
208208

209209
columns.extend(
210210
[
211-
{"label": _("Entity Type"), "fieldname": "entity_type", "fieldtype": "Data", "width": 100},
211+
{
212+
"label": _("{0} Type").format(_(filters.get("party_type", "Party"))),
213+
"fieldname": "party_entity_type",
214+
"fieldtype": "Data",
215+
"width": 100,
216+
},
212217
]
213218
)
214219
if filters.party_type == "Supplier":

erpnext/accounts/report/tds_payable_monthly/test_tds_payable_monthly.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_total,
124124
voucher.tax_amount,

0 commit comments

Comments
 (0)