From 07c3605905d9490dd890645a1872e47eb3edd631 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 31 Dec 2024 13:46:50 +0530 Subject: [PATCH] fix: deduct tds on excess amount if checked (cherry picked from commit a203e3ffaf7c2c9fcc9b8b79af5a4c490b692885) --- .../tax_withholding_category.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index cde1d24e5b4..325fefed804 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -555,9 +555,11 @@ def get_tds_amount(ldc, parties, inv, tax_details, vouchers): else: tax_withholding_net_total = inv.get("tax_withholding_net_total", 0) - if (threshold and tax_withholding_net_total >= threshold) or ( + has_cumulative_threshold_breached = ( cumulative_threshold and (supp_credit_amt + supp_inv_credit_amt) >= cumulative_threshold - ): + ) + + if (threshold and tax_withholding_net_total >= threshold) or (has_cumulative_threshold_breached): # Get net total again as TDS is calculated on net total # Grand is used to just check for threshold breach net_total = ( @@ -565,9 +567,7 @@ def get_tds_amount(ldc, parties, inv, tax_details, vouchers): ) supp_credit_amt += net_total - if (cumulative_threshold and supp_credit_amt >= cumulative_threshold) and cint( - tax_details.tax_on_excess_amount - ): + if has_cumulative_threshold_breached and cint(tax_details.tax_on_excess_amount): supp_credit_amt = net_total + tax_withholding_net_total - cumulative_threshold if ldc and is_valid_certificate(ldc, inv.get("posting_date") or inv.get("transaction_date"), 0):