From 57282999ad70b543aefb0e372b85675eb4b91bfb Mon Sep 17 00:00:00 2001 From: ljain112 Date: Wed, 12 Nov 2025 18:41:20 +0530 Subject: [PATCH 1/3] fix: back calcalute total amount from rate and tax_amount in tax withholding details report (cherry picked from commit d3751d9bb4eaddbdf4282f2f4adc45ee382a1ad0) --- .../tax_withholding_details.py | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 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 81dba55d609..c96510aa497 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -72,17 +72,28 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_ tax_withholding_category = party_map.get(party, {}).get("tax_withholding_category") rate = get_tax_withholding_rates(tax_rate_map.get(tax_withholding_category, []), posting_date) - if net_total_map.get((voucher_type, name)): + + values = net_total_map.get((voucher_type, name)) + + if values: if voucher_type == "Journal Entry" and tax_amount and rate: # back calcalute total amount from rate and tax_amount - base_total = min(tax_amount / (rate / 100), net_total_map.get((voucher_type, name))[0]) + base_total = min(tax_amount / (rate / 100), values[0]) total_amount = grand_total = base_total - elif voucher_type == "Purchase Invoice": - 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((voucher_type, name)) + if tax_amount and rate: + # back calcalute total amount from rate and tax_amount + total_amount = (tax_amount * 100) / rate + else: + total_amount = values[0] + + grand_total = values[1] + base_total = values[2] + + if voucher_type == "Purchase Invoice": + bill_no = values[3] + bill_date = values[4] else: total_amount += entry.credit From c150e5795e9fbcf4132ac1c64f9d11c9c7a0a0c2 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Wed, 12 Nov 2025 18:59:45 +0530 Subject: [PATCH 2/3] fix: improve precision in tax amount calculations in tax withholding details report (cherry picked from commit 7c5f5405cc17ff1a56e55777af29507dbc512168) --- .../tax_withholding_details/tax_withholding_details.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 c96510aa497..169de9cd801 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -4,7 +4,9 @@ import frappe from frappe import _ -from frappe.utils import getdate +from frappe.utils import flt, getdate + +from erpnext.accounts.utils import get_currency_precision def execute(filters=None): @@ -43,6 +45,7 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_ party_map = get_party_pan_map(filters.get("party_type")) tax_rate_map = get_tax_rate_map(filters) gle_map = get_gle_map(tds_docs) + precision = get_currency_precision() out = [] entries = {} @@ -78,13 +81,13 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_ if values: if voucher_type == "Journal Entry" and tax_amount and rate: # back calcalute total amount from rate and tax_amount - base_total = min(tax_amount / (rate / 100), values[0]) + base_total = min(flt(tax_amount / (rate / 100), precision=precision), values[0]) total_amount = grand_total = base_total else: if tax_amount and rate: # back calcalute total amount from rate and tax_amount - total_amount = (tax_amount * 100) / rate + total_amount = flt((tax_amount * 100) / rate, precision=precision) else: total_amount = values[0] From 4df80c5b53c678a2740eaca74fe14cd89ae7fbbb Mon Sep 17 00:00:00 2001 From: ljain112 Date: Wed, 12 Nov 2025 19:28:38 +0530 Subject: [PATCH 3/3] chore: typo in comment (cherry picked from commit e056c0327dc2043bb3baf43c6e73706f29bc31d4) --- .../report/tax_withholding_details/tax_withholding_details.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 169de9cd801..78fc08614f2 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -80,13 +80,13 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_ if values: if voucher_type == "Journal Entry" and tax_amount and rate: - # back calcalute total amount from rate and tax_amount + # back calculate total amount from rate and tax_amount base_total = min(flt(tax_amount / (rate / 100), precision=precision), values[0]) total_amount = grand_total = base_total else: if tax_amount and rate: - # back calcalute total amount from rate and tax_amount + # back calculate total amount from rate and tax_amount total_amount = flt((tax_amount * 100) / rate, precision=precision) else: total_amount = values[0]