fix: TDS calculation on net total (#27058) (#27140)

(cherry picked from commit 4eb7c2a011f3abbe547c2a32978e7af6e1fd6d33)

Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
This commit is contained in:
Frappe PR Bot 2021-08-25 18:18:16 +05:30 committed by GitHub
parent 7cb1eec1f8
commit 81b4590479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 5 deletions

View File

@ -240,14 +240,15 @@ def get_deducted_tax(taxable_vouchers, fiscal_year, tax_details):
def get_tds_amount(ldc, parties, inv, tax_details, fiscal_year_details, tax_deducted, vouchers):
tds_amount = 0
invoice_filters = {
'name': ('in', vouchers),
'docstatus': 1
'name': ('in', vouchers),
'docstatus': 1,
'apply_tds': 1
}
field = 'sum(net_total)'
if not cint(tax_details.consider_party_ledger_amount):
invoice_filters.update({'apply_tds': 1})
if cint(tax_details.consider_party_ledger_amount):
invoice_filters.pop('apply_tds', None)
field = 'sum(grand_total)'
supp_credit_amt = frappe.db.get_value('Purchase Invoice', invoice_filters, field) or 0.0

View File

@ -145,6 +145,36 @@ class TestTaxWithholdingCategory(unittest.TestCase):
for d in invoices:
d.cancel()
def test_tds_calculation_on_net_total(self):
frappe.db.set_value("Supplier", "Test TDS Supplier4", "tax_withholding_category", "Cumulative Threshold TDS")
invoices = []
pi = create_purchase_invoice(supplier = "Test TDS Supplier4", rate = 20000, do_not_save=True)
pi.append('taxes', {
"category": "Total",
"charge_type": "Actual",
"account_head": '_Test Account VAT - _TC',
"cost_center": 'Main - _TC',
"tax_amount": 1000,
"description": "Test",
"add_deduct_tax": "Add"
})
pi.save()
pi.submit()
invoices.append(pi)
# Second Invoice will apply TDS checked
pi1 = create_purchase_invoice(supplier = "Test TDS Supplier4", rate = 20000)
pi1.submit()
invoices.append(pi1)
self.assertEqual(pi1.taxes[0].tax_amount, 4000)
#delete invoices to avoid clashing
for d in invoices:
d.cancel()
def cancel_invoices():
purchase_invoices = frappe.get_all("Purchase Invoice", {
'supplier': ['in', ['Test TDS Supplier', 'Test TDS Supplier1', 'Test TDS Supplier2']],
@ -220,7 +250,7 @@ def create_sales_invoice(**args):
def create_records():
# create a new suppliers
for name in ['Test TDS Supplier', 'Test TDS Supplier1', 'Test TDS Supplier2', 'Test TDS Supplier3']:
for name in ['Test TDS Supplier', 'Test TDS Supplier1', 'Test TDS Supplier2', 'Test TDS Supplier3', 'Test TDS Supplier4']:
if frappe.db.exists('Supplier', name):
continue