(cherry picked from commit 4eb7c2a011f3abbe547c2a32978e7af6e1fd6d33) Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
This commit is contained in:
parent
7cb1eec1f8
commit
81b4590479
@ -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):
|
def get_tds_amount(ldc, parties, inv, tax_details, fiscal_year_details, tax_deducted, vouchers):
|
||||||
tds_amount = 0
|
tds_amount = 0
|
||||||
invoice_filters = {
|
invoice_filters = {
|
||||||
'name': ('in', vouchers),
|
'name': ('in', vouchers),
|
||||||
'docstatus': 1
|
'docstatus': 1,
|
||||||
|
'apply_tds': 1
|
||||||
}
|
}
|
||||||
|
|
||||||
field = 'sum(net_total)'
|
field = 'sum(net_total)'
|
||||||
|
|
||||||
if not cint(tax_details.consider_party_ledger_amount):
|
if cint(tax_details.consider_party_ledger_amount):
|
||||||
invoice_filters.update({'apply_tds': 1})
|
invoice_filters.pop('apply_tds', None)
|
||||||
field = 'sum(grand_total)'
|
field = 'sum(grand_total)'
|
||||||
|
|
||||||
supp_credit_amt = frappe.db.get_value('Purchase Invoice', invoice_filters, field) or 0.0
|
supp_credit_amt = frappe.db.get_value('Purchase Invoice', invoice_filters, field) or 0.0
|
||||||
|
@ -145,6 +145,36 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
|||||||
for d in invoices:
|
for d in invoices:
|
||||||
d.cancel()
|
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():
|
def cancel_invoices():
|
||||||
purchase_invoices = frappe.get_all("Purchase Invoice", {
|
purchase_invoices = frappe.get_all("Purchase Invoice", {
|
||||||
'supplier': ['in', ['Test TDS Supplier', 'Test TDS Supplier1', 'Test TDS Supplier2']],
|
'supplier': ['in', ['Test TDS Supplier', 'Test TDS Supplier1', 'Test TDS Supplier2']],
|
||||||
@ -220,7 +250,7 @@ def create_sales_invoice(**args):
|
|||||||
|
|
||||||
def create_records():
|
def create_records():
|
||||||
# create a new suppliers
|
# 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):
|
if frappe.db.exists('Supplier', name):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user