fix: Lower deduction certificate not getting applied (#35667)
* fix: Lower deduction certificate not getting applied (#35667)
(cherry picked from commit 937c0feefe)
# Conflicts:
# erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
* chore: Resolve conflicts
---------
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint, getdate
|
from frappe.utils import cint, flt, getdate
|
||||||
|
|
||||||
|
|
||||||
class TaxWithholdingCategory(Document):
|
class TaxWithholdingCategory(Document):
|
||||||
@@ -520,8 +520,13 @@ def get_tds_amount_from_ldc(ldc, parties, pan_no, tax_details, posting_date, net
|
|||||||
tds_amount = 0
|
tds_amount = 0
|
||||||
limit_consumed = frappe.db.get_value(
|
limit_consumed = frappe.db.get_value(
|
||||||
"Purchase Invoice",
|
"Purchase Invoice",
|
||||||
{"supplier": ("in", parties), "apply_tds": 1, "docstatus": 1},
|
{
|
||||||
"sum(net_total)",
|
"supplier": ("in", parties),
|
||||||
|
"apply_tds": 1,
|
||||||
|
"docstatus": 1,
|
||||||
|
"posting_date": ("between", (ldc.valid_from, ldc.valid_upto)),
|
||||||
|
},
|
||||||
|
"sum(tax_withholding_net_total)",
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_valid_certificate(
|
if is_valid_certificate(
|
||||||
@@ -535,10 +540,10 @@ def get_tds_amount_from_ldc(ldc, parties, pan_no, tax_details, posting_date, net
|
|||||||
|
|
||||||
|
|
||||||
def get_ltds_amount(current_amount, deducted_amount, certificate_limit, rate, tax_details):
|
def get_ltds_amount(current_amount, deducted_amount, certificate_limit, rate, tax_details):
|
||||||
if current_amount < (certificate_limit - deducted_amount):
|
if certificate_limit - flt(deducted_amount) - flt(current_amount) >= 0:
|
||||||
return current_amount * rate / 100
|
return current_amount * rate / 100
|
||||||
else:
|
else:
|
||||||
ltds_amount = certificate_limit - deducted_amount
|
ltds_amount = certificate_limit - flt(deducted_amount)
|
||||||
tds_amount = current_amount - ltds_amount
|
tds_amount = current_amount - ltds_amount
|
||||||
|
|
||||||
return ltds_amount * rate / 100 + tds_amount * tax_details.rate / 100
|
return ltds_amount * rate / 100 + tds_amount * tax_details.rate / 100
|
||||||
@@ -549,9 +554,9 @@ def is_valid_certificate(
|
|||||||
):
|
):
|
||||||
valid = False
|
valid = False
|
||||||
|
|
||||||
if (
|
available_amount = flt(certificate_limit) - flt(deducted_amount) - flt(current_amount)
|
||||||
getdate(valid_from) <= getdate(posting_date) <= getdate(valid_upto)
|
|
||||||
) and certificate_limit > deducted_amount:
|
if (getdate(valid_from) <= getdate(posting_date) <= getdate(valid_upto)) and available_amount > 0:
|
||||||
valid = True
|
valid = True
|
||||||
|
|
||||||
return valid
|
return valid
|
||||||
|
|||||||
Reference in New Issue
Block a user