fix: only include advances within the tcs period

(cherry picked from commit 477ec9fdcc)
This commit is contained in:
ljain112
2025-05-26 15:36:12 +05:30
committed by Mergify
parent 60dfe36195
commit a2f5975133
2 changed files with 18 additions and 5 deletions

View File

@@ -671,6 +671,7 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers):
conditions.append(ple.party.isin(parties)) conditions.append(ple.party.isin(parties))
conditions.append(ple.voucher_no == ple.against_voucher_no) conditions.append(ple.voucher_no == ple.against_voucher_no)
conditions.append(ple.company == inv.company) conditions.append(ple.company == inv.company)
conditions.append(ple.posting_date[tax_details.from_date : tax_details.to_date])
advance_amt = ( advance_amt = (
qb.from_(ple).select(Abs(Sum(ple.amount))).where(Criterion.all(conditions)).run()[0][0] or 0.0 qb.from_(ple).select(Abs(Sum(ple.amount))).where(Criterion.all(conditions)).run()[0][0] or 0.0

View File

@@ -288,17 +288,18 @@ class TestTaxWithholdingCategory(FrappeTestCase):
frappe.db.set_value( frappe.db.set_value(
"Customer", "Test TCS Customer", "tax_withholding_category", "Cumulative Threshold TCS" "Customer", "Test TCS Customer", "tax_withholding_category", "Cumulative Threshold TCS"
) )
fiscal_year = get_fiscal_year(today(), company="_Test Company")
vouchers = [] vouchers = []
# create advance payment # create advance payment
pe = create_payment_entry( pe1 = create_payment_entry(
payment_type="Receive", party_type="Customer", party="Test TCS Customer", paid_amount=20000 payment_type="Receive", party_type="Customer", party="Test TCS Customer", paid_amount=20000
) )
pe.paid_from = "Debtors - _TC" pe1.paid_from = "Debtors - _TC"
pe.paid_to = "Cash - _TC" pe1.paid_to = "Cash - _TC"
pe.submit() pe1.submit()
vouchers.append(pe) vouchers.append(pe1)
# create invoice # create invoice
si1 = create_sales_invoice(customer="Test TCS Customer", rate=5000) si1 = create_sales_invoice(customer="Test TCS Customer", rate=5000)
@@ -320,6 +321,17 @@ class TestTaxWithholdingCategory(FrappeTestCase):
# make another invoice # make another invoice
# sum of unallocated amount from payment entry and this sales invoice will breach cumulative threashold # sum of unallocated amount from payment entry and this sales invoice will breach cumulative threashold
# TDS should be calculated # TDS should be calculated
# this payment should not be considered for TCS calculation as it is outside of fiscal year
pe2 = create_payment_entry(
payment_type="Receive", party_type="Customer", party="Test TCS Customer", paid_amount=10000
)
pe2.paid_from = "Debtors - _TC"
pe2.paid_to = "Cash - _TC"
pe2.posting_date = add_days(fiscal_year[1], -10)
pe2.submit()
vouchers.append(pe2)
si2 = create_sales_invoice(customer="Test TCS Customer", rate=15000) si2 = create_sales_invoice(customer="Test TCS Customer", rate=15000)
si2.submit() si2.submit()
vouchers.append(si2) vouchers.append(si2)