Skip to content

Commit

Permalink
refactor: use accounts mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
GursheenK committed Sep 5, 2023
1 parent 035eaa5 commit dbeb132
Showing 1 changed file with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
create_tax_withholding_category,
)
from erpnext.accounts.report.tds_payable_monthly.tds_payable_monthly import execute
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
from erpnext.accounts.utils import get_fiscal_year


class TestTdsPayableMonthly(FrappeTestCase):
class TestTdsPayableMonthly(AccountsTestMixin, FrappeTestCase):
def setUp(self):
delete_docs()
self.create_company()
self.clear_old_entries()
create_tax_accounts()
create_tax_categories()
create_tcs_category()

def test_tax_withholding_for_customers(self):
si = create_sales_invoice(rate=1000)
Expand All @@ -30,8 +32,8 @@ def test_tax_withholding_for_customers(self):
)
result = execute(filters)[1]
expected_values = [
[pe.name, "TCS", 0.075, 2550, 0.9, 2550.9],
[si.name, "TCS", 0.075, 1000, 0.9, 1000.9],
[pe.name, "TCS", 0.075, 2550, 0.53, 2550.53],
[si.name, "TCS", 0.075, 1000, 0.53, 1000.53],
]
self.check_expected_values(result, expected_values)

Expand All @@ -47,14 +49,7 @@ def check_expected_values(self, result, expected_values):
self.assertEqual(voucher.grand_total, voucher_expected_values[5])

def tearDown(self):
delete_docs()


def delete_docs():
frappe.db.sql("delete from `tabSales Invoice` where company='_Test Company'")
frappe.db.sql("delete from `tabPurchase Invoice` where company='_Test Company'")
frappe.db.sql("delete from `tabGL Entry` where company='_Test Company'")
frappe.db.sql("delete from `tabPayment Entry` where company='_Test Company'")
self.clear_old_entries()


def create_tax_accounts():
Expand All @@ -72,7 +67,7 @@ def create_tax_accounts():
).insert(ignore_if_duplicate=True)


def create_tax_categories():
def create_tcs_category():
fiscal_year = get_fiscal_year(today(), company="_Test Company")
from_date = fiscal_year[1]
to_date = fiscal_year[2]
Expand Down Expand Up @@ -106,7 +101,7 @@ def create_tcs_payment_entry():
{
"account_head": "TCS - _TC",
"charge_type": "Actual",
"tax_amount": 0.9,
"tax_amount": 0.53,
"add_deduct_tax": "Add",
"description": "Test",
"cost_center": "Main - _TC",
Expand Down

0 comments on commit dbeb132

Please sign in to comment.