mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
Merge pull request #39349 from GursheenK/JVs-in-withholding-report
fix: TDS accounts GLE query for withholding category report
This commit is contained in:
@@ -354,9 +354,6 @@ def get_tds_docs_query(filters, bank_accounts, tds_accounts):
|
|||||||
if filters.get("to_date"):
|
if filters.get("to_date"):
|
||||||
query = query.where(gle.posting_date <= filters.get("to_date"))
|
query = query.where(gle.posting_date <= filters.get("to_date"))
|
||||||
|
|
||||||
if bank_accounts:
|
|
||||||
query = query.where(gle.against.notin(bank_accounts))
|
|
||||||
|
|
||||||
if filters.get("party"):
|
if filters.get("party"):
|
||||||
party = [filters.get("party")]
|
party = [filters.get("party")]
|
||||||
jv_condition = gle.against.isin(party) | (
|
jv_condition = gle.against.isin(party) | (
|
||||||
@@ -368,7 +365,14 @@ def get_tds_docs_query(filters, bank_accounts, tds_accounts):
|
|||||||
(gle.voucher_type == "Journal Entry")
|
(gle.voucher_type == "Journal Entry")
|
||||||
& ((gle.party_type == filters.get("party_type")) | (gle.party_type == ""))
|
& ((gle.party_type == filters.get("party_type")) | (gle.party_type == ""))
|
||||||
)
|
)
|
||||||
query = query.where((gle.account.isin(tds_accounts) & jv_condition) | gle.party.isin(party))
|
|
||||||
|
query.where((gle.account.isin(tds_accounts) & jv_condition) | gle.party.isin(party))
|
||||||
|
if bank_accounts:
|
||||||
|
query = query.where(
|
||||||
|
gle.against.notin(bank_accounts) & (gle.account.isin(tds_accounts) & jv_condition)
|
||||||
|
| gle.party.isin(party)
|
||||||
|
)
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import frappe
|
|||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests.utils import FrappeTestCase
|
||||||
from frappe.utils import today
|
from frappe.utils import today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry
|
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
from erpnext.accounts.doctype.tax_withholding_category.test_tax_withholding_category import (
|
from erpnext.accounts.doctype.tax_withholding_category.test_tax_withholding_category import (
|
||||||
create_tax_withholding_category,
|
create_tax_withholding_category,
|
||||||
@@ -17,7 +16,7 @@ from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
|||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
|
|
||||||
class TestTdsPayableMonthly(AccountsTestMixin, FrappeTestCase):
|
class TestTaxWithholdingDetails(AccountsTestMixin, FrappeTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.create_company()
|
self.create_company()
|
||||||
self.clear_old_entries()
|
self.clear_old_entries()
|
||||||
@@ -27,11 +26,15 @@ class TestTdsPayableMonthly(AccountsTestMixin, FrappeTestCase):
|
|||||||
def test_tax_withholding_for_customers(self):
|
def test_tax_withholding_for_customers(self):
|
||||||
si = create_sales_invoice(rate=1000)
|
si = create_sales_invoice(rate=1000)
|
||||||
pe = create_tcs_payment_entry()
|
pe = create_tcs_payment_entry()
|
||||||
|
jv = create_tcs_journal_entry()
|
||||||
|
|
||||||
filters = frappe._dict(
|
filters = frappe._dict(
|
||||||
company="_Test Company", party_type="Customer", from_date=today(), to_date=today()
|
company="_Test Company", party_type="Customer", from_date=today(), to_date=today()
|
||||||
)
|
)
|
||||||
result = execute(filters)[1]
|
result = execute(filters)[1]
|
||||||
expected_values = [
|
expected_values = [
|
||||||
|
# Check for JV totals using back calculation logic
|
||||||
|
[jv.name, "TCS", 0.075, -10000.0, -7.5, -10000.0],
|
||||||
[pe.name, "TCS", 0.075, 2550, 0.53, 2550.53],
|
[pe.name, "TCS", 0.075, 2550, 0.53, 2550.53],
|
||||||
[si.name, "TCS", 0.075, 1000, 0.52, 1000.52],
|
[si.name, "TCS", 0.075, 1000, 0.52, 1000.52],
|
||||||
]
|
]
|
||||||
@@ -41,12 +44,15 @@ class TestTdsPayableMonthly(AccountsTestMixin, FrappeTestCase):
|
|||||||
for i in range(len(result)):
|
for i in range(len(result)):
|
||||||
voucher = frappe._dict(result[i])
|
voucher = frappe._dict(result[i])
|
||||||
voucher_expected_values = expected_values[i]
|
voucher_expected_values = expected_values[i]
|
||||||
self.assertEqual(voucher.ref_no, voucher_expected_values[0])
|
voucher_actual_values = (
|
||||||
self.assertEqual(voucher.section_code, voucher_expected_values[1])
|
voucher.ref_no,
|
||||||
self.assertEqual(voucher.rate, voucher_expected_values[2])
|
voucher.section_code,
|
||||||
self.assertEqual(voucher.base_total, voucher_expected_values[3])
|
voucher.rate,
|
||||||
self.assertAlmostEqual(voucher.tax_amount, voucher_expected_values[4])
|
voucher.base_total,
|
||||||
self.assertAlmostEqual(voucher.grand_total, voucher_expected_values[5])
|
voucher.tax_amount,
|
||||||
|
voucher.grand_total,
|
||||||
|
)
|
||||||
|
self.assertSequenceEqual(voucher_actual_values, voucher_expected_values)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.clear_old_entries()
|
self.clear_old_entries()
|
||||||
@@ -109,3 +115,32 @@ def create_tcs_payment_entry():
|
|||||||
)
|
)
|
||||||
payment_entry.submit()
|
payment_entry.submit()
|
||||||
return payment_entry
|
return payment_entry
|
||||||
|
|
||||||
|
|
||||||
|
def create_tcs_journal_entry():
|
||||||
|
jv = frappe.new_doc("Journal Entry")
|
||||||
|
jv.posting_date = today()
|
||||||
|
jv.company = "_Test Company"
|
||||||
|
jv.set(
|
||||||
|
"accounts",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"account": "Debtors - _TC",
|
||||||
|
"party_type": "Customer",
|
||||||
|
"party": "_Test Customer",
|
||||||
|
"credit_in_account_currency": 10000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account": "Debtors - _TC",
|
||||||
|
"party_type": "Customer",
|
||||||
|
"party": "_Test Customer",
|
||||||
|
"debit_in_account_currency": 9992.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account": "TCS - _TC",
|
||||||
|
"debit_in_account_currency": 7.5,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
jv.insert()
|
||||||
|
return jv.submit()
|
||||||
|
|||||||
Reference in New Issue
Block a user