mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-26 18:18:30 +00:00
refactor: use consistent report column names
This commit is contained in:
@@ -46,8 +46,8 @@ def get_tax_withholding_data(filters):
|
||||
party_info = party_details.get((entry.party_type, entry.party), {})
|
||||
|
||||
row = {
|
||||
"section_code": entry.tax_withholding_category,
|
||||
"entity_type": party_info.get("entity_type"),
|
||||
"tax_withholding_category": entry.tax_withholding_category,
|
||||
"party_entity_type": party_info.get("party_entity_type"),
|
||||
"rate": entry.tax_rate,
|
||||
"total_amount": entry.taxable_amount,
|
||||
"grand_total": doc_details.get("grand_total", 0),
|
||||
@@ -70,7 +70,11 @@ def get_tax_withholding_data(filters):
|
||||
|
||||
# Sort by section code, transaction date, then withholding_name for deterministic ordering
|
||||
data.sort(
|
||||
key=lambda x: (x["section_code"] or "", x["transaction_date"] or "", x["withholding_name"] or "")
|
||||
key=lambda x: (
|
||||
x["tax_withholding_category"] or "",
|
||||
x["transaction_date"] or "",
|
||||
x["withholding_name"] or "",
|
||||
)
|
||||
)
|
||||
return data
|
||||
|
||||
@@ -94,9 +98,13 @@ def get_party_details(entries):
|
||||
fields = [doctype.name]
|
||||
|
||||
if party_type == "Supplier":
|
||||
fields.extend([doctype.supplier_type.as_("entity_type"), doctype.supplier_name.as_("party_name")])
|
||||
fields.extend(
|
||||
[doctype.supplier_type.as_("party_entity_type"), doctype.supplier_name.as_("party_name")]
|
||||
)
|
||||
elif party_type == "Customer":
|
||||
fields.extend([doctype.customer_type.as_("entity_type"), doctype.customer_name.as_("party_name")])
|
||||
fields.extend(
|
||||
[doctype.customer_type.as_("party_entity_type"), doctype.customer_name.as_("party_name")]
|
||||
)
|
||||
|
||||
query = frappe.qb.from_(doctype).select(*fields).where(doctype.name.isin(party_set))
|
||||
party_details = query.run(as_dict=True)
|
||||
@@ -113,7 +121,7 @@ def get_columns(filters):
|
||||
{
|
||||
"label": _("Section Code"),
|
||||
"options": "Tax Withholding Category",
|
||||
"fieldname": "section_code",
|
||||
"fieldname": "tax_withholding_category",
|
||||
"fieldtype": "Link",
|
||||
"width": 90,
|
||||
},
|
||||
@@ -133,7 +141,7 @@ def get_columns(filters):
|
||||
},
|
||||
{
|
||||
"label": _("Entity Type"),
|
||||
"fieldname": "entity_type",
|
||||
"fieldname": "party_entity_type",
|
||||
"fieldtype": "Data",
|
||||
"width": 100,
|
||||
},
|
||||
|
||||
@@ -124,7 +124,7 @@ class TestTaxWithholdingDetails(ERPNextTestSuite, AccountsTestMixin):
|
||||
voucher_expected_values = expected_values[i]
|
||||
voucher_actual_values = (
|
||||
voucher.ref_no,
|
||||
voucher.section_code,
|
||||
voucher.tax_withholding_category,
|
||||
voucher.rate,
|
||||
voucher.base_total,
|
||||
voucher.tax_amount,
|
||||
|
||||
@@ -36,26 +36,26 @@ 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")),
|
||||
{
|
||||
"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(
|
||||
"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("section_code")))["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)
|
||||
|
||||
@@ -89,13 +89,13 @@ 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",
|
||||
"fieldname": "party_entity_type",
|
||||
"fieldtype": "Data",
|
||||
"width": 180,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user