mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
feat: item wise tds calculation
item wise tds calculation
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
"discount_amount",
|
"discount_amount",
|
||||||
"base_rate_with_margin",
|
"base_rate_with_margin",
|
||||||
"sec_break2",
|
"sec_break2",
|
||||||
|
"apply_tds",
|
||||||
"rate",
|
"rate",
|
||||||
"amount",
|
"amount",
|
||||||
"item_tax_template",
|
"item_tax_template",
|
||||||
@@ -866,6 +867,12 @@
|
|||||||
"label": "Product Bundle",
|
"label": "Product Bundle",
|
||||||
"options": "Product Bundle",
|
"options": "Product Bundle",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "apply_tds",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Apply TDS"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
|
|||||||
if party_type == "Supplier":
|
if party_type == "Supplier":
|
||||||
ldc = get_lower_deduction_certificate(tax_details, pan_no)
|
ldc = get_lower_deduction_certificate(tax_details, pan_no)
|
||||||
if tax_deducted:
|
if tax_deducted:
|
||||||
net_total = inv.net_total
|
net_total = inv.tax_withholding_net_total
|
||||||
if ldc:
|
if ldc:
|
||||||
tax_amount = get_tds_amount_from_ldc(
|
tax_amount = get_tds_amount_from_ldc(
|
||||||
ldc, parties, pan_no, tax_details, posting_date, net_total
|
ldc, parties, pan_no, tax_details, posting_date, net_total
|
||||||
@@ -395,7 +395,7 @@ def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers):
|
|||||||
tds_amount = 0
|
tds_amount = 0
|
||||||
invoice_filters = {"name": ("in", vouchers), "docstatus": 1, "apply_tds": 1}
|
invoice_filters = {"name": ("in", vouchers), "docstatus": 1, "apply_tds": 1}
|
||||||
|
|
||||||
field = "sum(net_total)"
|
field = "sum(tax_withholding_net_total)"
|
||||||
|
|
||||||
if cint(tax_details.consider_party_ledger_amount):
|
if cint(tax_details.consider_party_ledger_amount):
|
||||||
invoice_filters.pop("apply_tds", None)
|
invoice_filters.pop("apply_tds", None)
|
||||||
@@ -418,12 +418,12 @@ def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers):
|
|||||||
)
|
)
|
||||||
|
|
||||||
supp_credit_amt += supp_jv_credit_amt
|
supp_credit_amt += supp_jv_credit_amt
|
||||||
supp_credit_amt += inv.net_total
|
supp_credit_amt += inv.tax_withholding_net_total
|
||||||
|
|
||||||
threshold = tax_details.get("threshold", 0)
|
threshold = tax_details.get("threshold", 0)
|
||||||
cumulative_threshold = tax_details.get("cumulative_threshold", 0)
|
cumulative_threshold = tax_details.get("cumulative_threshold", 0)
|
||||||
|
|
||||||
if (threshold and inv.net_total >= threshold) or (
|
if (threshold and inv.tax_withholding_net_total >= threshold) or (
|
||||||
cumulative_threshold and supp_credit_amt >= cumulative_threshold
|
cumulative_threshold and supp_credit_amt >= cumulative_threshold
|
||||||
):
|
):
|
||||||
if (cumulative_threshold and supp_credit_amt >= cumulative_threshold) and cint(
|
if (cumulative_threshold and supp_credit_amt >= cumulative_threshold) and cint(
|
||||||
@@ -443,7 +443,7 @@ def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers):
|
|||||||
ldc.valid_upto,
|
ldc.valid_upto,
|
||||||
inv.get("posting_date") or inv.get("transaction_date"),
|
inv.get("posting_date") or inv.get("transaction_date"),
|
||||||
tax_deducted,
|
tax_deducted,
|
||||||
inv.net_total,
|
inv.tax_withholding_net_total,
|
||||||
ldc.certificate_limit,
|
ldc.certificate_limit,
|
||||||
):
|
):
|
||||||
tds_amount = get_ltds_amount(supp_credit_amt, 0, ldc.certificate_limit, ldc.rate, tax_details)
|
tds_amount = get_ltds_amount(supp_credit_amt, 0, ldc.certificate_limit, ldc.rate, tax_details)
|
||||||
@@ -526,7 +526,7 @@ def get_tds_amount_from_ldc(ldc, parties, pan_no, tax_details, posting_date, net
|
|||||||
limit_consumed = frappe.db.get_value(
|
limit_consumed = frappe.db.get_value(
|
||||||
"Purchase Invoice",
|
"Purchase Invoice",
|
||||||
{"supplier": ("in", parties), "apply_tds": 1, "docstatus": 1},
|
{"supplier": ("in", parties), "apply_tds": 1, "docstatus": 1},
|
||||||
"sum(net_total)",
|
"sum(tax_withholding_net_total)",
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_valid_certificate(
|
if is_valid_certificate(
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class calculate_taxes_and_totals(object):
|
|||||||
self.initialize_taxes()
|
self.initialize_taxes()
|
||||||
self.determine_exclusive_rate()
|
self.determine_exclusive_rate()
|
||||||
self.calculate_net_total()
|
self.calculate_net_total()
|
||||||
|
self.calculate_tax_withholding_net_total()
|
||||||
self.calculate_taxes()
|
self.calculate_taxes()
|
||||||
self.manipulate_grand_total_for_inclusive_tax()
|
self.manipulate_grand_total_for_inclusive_tax()
|
||||||
self.calculate_totals()
|
self.calculate_totals()
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.db.sql("""
|
frappe.db.sql(
|
||||||
|
"""
|
||||||
UPDATE
|
UPDATE
|
||||||
`tabPurchase Invoice Item`
|
`tabPurchase Invoice Item`
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
@@ -13,11 +14,17 @@ def execute():
|
|||||||
WHERE
|
WHERE
|
||||||
`tabPurchase Invoice`.apply_tds = 1
|
`tabPurchase Invoice`.apply_tds = 1
|
||||||
and `tabPurchase Invoice`.docstatus = 1
|
and `tabPurchase Invoice`.docstatus = 1
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
frappe.db.sql("""
|
|
||||||
UPDATE `tabPurchase Invoice`
|
|
||||||
SET tax_withholding_net_total = net_total,
|
|
||||||
base_tax_withholding_net_total = base_net_total
|
|
||||||
WHERE apply_tds = 1 and docstatus = 1""")
|
|
||||||
|
|
||||||
|
frappe.db.sql(
|
||||||
|
"""
|
||||||
|
UPDATE
|
||||||
|
`tabPurchase Invoice`
|
||||||
|
SET
|
||||||
|
tax_withholding_net_total = net_total,
|
||||||
|
base_tax_withholding_net_total = base_net_total
|
||||||
|
WHERE
|
||||||
|
apply_tds = 1 and docstatus = 1
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user