From 8264e3bc77dacc2ac62f46fac1bec83cf0ec93cb Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Wed, 10 Jul 2024 11:56:38 +0530 Subject: [PATCH] fix(tds): use doctype reference when mapping keys across multiple doctypes (#42258) * fix(tds): use doctype reference when mapping keys across multiple doctypes * fix: changes as per review --------- Co-authored-by: ljain112 (cherry picked from commit 5c0d52f783acd22fa6ffd0330239a739c902d5dc) # Conflicts: # erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py --- .../tax_withholding_details.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 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 3a3cedc0bae6..b0e47bfa025a 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -12,7 +12,7 @@ def execute(filters=None): else: party_naming_by = frappe.db.get_single_value("Buying Settings", "supp_master_name") - filters.update({"naming_series": party_naming_by}) + filters["naming_series"] = party_naming_by validate_filters(filters) ( @@ -63,21 +63,28 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_ tax_withholding_category = tds_accounts.get(entry.account) # or else the consolidated value from the voucher document if not tax_withholding_category: - tax_withholding_category = tax_category_map.get(name) + tax_withholding_category = tax_category_map.get((voucher_type, name)) # or else from the party default if not tax_withholding_category: tax_withholding_category = party_map.get(party, {}).get("tax_withholding_category") rate = tax_rate_map.get(tax_withholding_category) +<<<<<<< HEAD if net_total_map.get(name): if voucher_type == "Journal Entry": +======= + if net_total_map.get((voucher_type, name)): + if voucher_type == "Journal Entry" and tax_amount and rate: +>>>>>>> 5c0d52f783 (fix(tds): use doctype reference when mapping keys across multiple doctypes (#42258)) # back calcalute total amount from rate and tax_amount if rate: total_amount = grand_total = base_total = tax_amount / (rate / 100) elif voucher_type == "Purchase Invoice": - total_amount, grand_total, base_total, bill_no, bill_date = net_total_map.get(name) + total_amount, grand_total, base_total, bill_no, bill_date = net_total_map.get( + (voucher_type, name) + ) else: - total_amount, grand_total, base_total = net_total_map.get(name) + total_amount, grand_total, base_total = net_total_map.get((voucher_type, name)) else: total_amount += entry.credit @@ -97,7 +104,7 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_ } if filters.naming_series == "Naming Series": - row.update({"party_name": party_map.get(party, {}).get(party_name)}) + row["party_name"] = party_map.get(party, {}).get(party_name) row.update( { @@ -279,7 +286,6 @@ def get_tds_docs(filters): journal_entries = [] tax_category_map = frappe._dict() net_total_map = frappe._dict() - frappe._dict() journal_entry_party_map = frappe._dict() bank_accounts = frappe.get_all("Account", {"is_group": 0, "account_type": "Bank"}, pluck="name") @@ -412,7 +418,7 @@ def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None): ) for entry in entries: - tax_category_map.update({entry.name: entry.tax_withholding_category}) + tax_category_map[(doctype, entry.name)] = entry.tax_withholding_category if doctype == "Purchase Invoice": value = [ entry.base_tax_withholding_net_total, @@ -427,7 +433,8 @@ def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None): value = [entry.paid_amount, entry.paid_amount_after_tax, entry.base_paid_amount] else: value = [entry.total_amount] * 3 - net_total_map.update({entry.name: value}) + + net_total_map[(doctype, entry.name)] = value def get_tax_rate_map(filters):