mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-27 02:28:30 +00:00
fix(tds): correct tax logic for customer
(cherry picked from commit 86b0f67dbc)
This commit is contained in:
@@ -415,7 +415,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
|||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"tax_amount": 500,
|
"tax_amount": 500,
|
||||||
"description": "Test",
|
"description": "Test",
|
||||||
"add_deduct_tax": "Add",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
pi.save()
|
pi.save()
|
||||||
@@ -506,7 +505,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
|||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"tax_amount": 200,
|
"tax_amount": 200,
|
||||||
"description": "Test Gross Tax",
|
"description": "Test Gross Tax",
|
||||||
"add_deduct_tax": "Add",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
si.save()
|
si.save()
|
||||||
@@ -541,10 +539,10 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
|||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"tax_amount": 400,
|
"tax_amount": 400,
|
||||||
"description": "Test Gross Tax",
|
"description": "Test Gross Tax",
|
||||||
"add_deduct_tax": "Add",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
si.save()
|
si.save()
|
||||||
|
si.reload()
|
||||||
si.submit()
|
si.submit()
|
||||||
invoices.append(si)
|
invoices.append(si)
|
||||||
# For amount before threshold (first 8000 + VAT): TCS entry with amount zero
|
# For amount before threshold (first 8000 + VAT): TCS entry with amount zero
|
||||||
@@ -594,7 +592,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
|||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"tax_amount": 500,
|
"tax_amount": 500,
|
||||||
"description": "VAT added to test TDS calculation on gross amount",
|
"description": "VAT added to test TDS calculation on gross amount",
|
||||||
"add_deduct_tax": "Add",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
si.save()
|
si.save()
|
||||||
@@ -1024,7 +1021,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
|||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"tax_amount": 1000,
|
"tax_amount": 1000,
|
||||||
"description": "VAT added to test TDS calculation on gross amount",
|
"description": "VAT added to test TDS calculation on gross amount",
|
||||||
"add_deduct_tax": "Add",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
pi.save()
|
pi.save()
|
||||||
@@ -1162,7 +1158,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
|||||||
"cost_center": "Main - _TC",
|
"cost_center": "Main - _TC",
|
||||||
"tax_amount": 8000,
|
"tax_amount": 8000,
|
||||||
"description": "Test",
|
"description": "Test",
|
||||||
"add_deduct_tax": "Add",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -708,6 +708,10 @@ class TaxWithholdingController:
|
|||||||
existing_taxes = {row.account_head: row for row in self.doc.taxes if row.is_tax_withholding_account}
|
existing_taxes = {row.account_head: row for row in self.doc.taxes if row.is_tax_withholding_account}
|
||||||
precision = self.doc.precision("tax_amount", "taxes")
|
precision = self.doc.precision("tax_amount", "taxes")
|
||||||
conversion_rate = self.get_conversion_rate()
|
conversion_rate = self.get_conversion_rate()
|
||||||
|
add_deduct_tax = "Deduct"
|
||||||
|
|
||||||
|
if self.party_type == "Customer":
|
||||||
|
add_deduct_tax = "Add"
|
||||||
|
|
||||||
for account_head, base_amount in account_amount_map.items():
|
for account_head, base_amount in account_amount_map.items():
|
||||||
tax_amount = flt(base_amount / conversion_rate, precision)
|
tax_amount = flt(base_amount / conversion_rate, precision)
|
||||||
@@ -724,6 +728,7 @@ class TaxWithholdingController:
|
|||||||
tax_row = self._create_tax_row(account_head, tax_amount)
|
tax_row = self._create_tax_row(account_head, tax_amount)
|
||||||
for_update = False
|
for_update = False
|
||||||
|
|
||||||
|
tax_row.add_deduct_tax = add_deduct_tax
|
||||||
# Set item-wise tax breakup for this tax row
|
# Set item-wise tax breakup for this tax row
|
||||||
self._set_item_wise_tax_for_tds(
|
self._set_item_wise_tax_for_tds(
|
||||||
tax_row, account_head, category_withholding_map, for_update=for_update
|
tax_row, account_head, category_withholding_map, for_update=for_update
|
||||||
@@ -743,7 +748,6 @@ class TaxWithholdingController:
|
|||||||
"account_head": account_head,
|
"account_head": account_head,
|
||||||
"description": account_head,
|
"description": account_head,
|
||||||
"cost_center": cost_center,
|
"cost_center": cost_center,
|
||||||
"add_deduct_tax": "Deduct",
|
|
||||||
"tax_amount": tax_amount,
|
"tax_amount": tax_amount,
|
||||||
"dont_recompute_tax": 1,
|
"dont_recompute_tax": 1,
|
||||||
},
|
},
|
||||||
@@ -807,12 +811,14 @@ class TaxWithholdingController:
|
|||||||
else:
|
else:
|
||||||
item_tax_amount = 0
|
item_tax_amount = 0
|
||||||
|
|
||||||
|
multiplier = -1 if tax_row.add_deduct_tax == "Deduct" else 1
|
||||||
|
|
||||||
self.doc._item_wise_tax_details.append(
|
self.doc._item_wise_tax_details.append(
|
||||||
frappe._dict(
|
frappe._dict(
|
||||||
item=item,
|
item=item,
|
||||||
tax=tax_row,
|
tax=tax_row,
|
||||||
rate=category.tax_rate,
|
rate=category.tax_rate,
|
||||||
amount=item_tax_amount * -1, # Negative because it's a deduction
|
amount=item_tax_amount * multiplier,
|
||||||
taxable_amount=item_base_taxable,
|
taxable_amount=item_base_taxable,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user