fix: consider payment entries for checking if tds is deducted
This commit is contained in:
@@ -1709,6 +1709,9 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.db_set("release_date", None)
|
self.db_set("release_date", None)
|
||||||
|
|
||||||
def set_tax_withholding(self):
|
def set_tax_withholding(self):
|
||||||
|
self.set("advance_tax", [])
|
||||||
|
self.set("tax_withheld_vouchers", [])
|
||||||
|
|
||||||
if not self.apply_tds:
|
if not self.apply_tds:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1750,8 +1753,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.remove(d)
|
self.remove(d)
|
||||||
|
|
||||||
## Add pending vouchers on which tax was withheld
|
## Add pending vouchers on which tax was withheld
|
||||||
self.set("tax_withheld_vouchers", [])
|
|
||||||
|
|
||||||
for voucher_no, voucher_details in voucher_wise_amount.items():
|
for voucher_no, voucher_details in voucher_wise_amount.items():
|
||||||
self.append(
|
self.append(
|
||||||
"tax_withheld_vouchers",
|
"tax_withheld_vouchers",
|
||||||
@@ -1766,7 +1767,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.calculate_taxes_and_totals()
|
self.calculate_taxes_and_totals()
|
||||||
|
|
||||||
def allocate_advance_tds(self, tax_withholding_details, advance_taxes):
|
def allocate_advance_tds(self, tax_withholding_details, advance_taxes):
|
||||||
self.set("advance_tax", [])
|
|
||||||
for tax in advance_taxes:
|
for tax in advance_taxes:
|
||||||
allocated_amount = 0
|
allocated_amount = 0
|
||||||
pending_amount = flt(tax.tax_amount - tax.allocated_amount)
|
pending_amount = flt(tax.tax_amount - tax.allocated_amount)
|
||||||
|
|||||||
@@ -268,6 +268,11 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
|
|||||||
vouchers, voucher_wise_amount = get_invoice_vouchers(
|
vouchers, voucher_wise_amount = get_invoice_vouchers(
|
||||||
parties, tax_details, inv.company, party_type=party_type
|
parties, tax_details, inv.company, party_type=party_type
|
||||||
)
|
)
|
||||||
|
|
||||||
|
payment_entry_vouchers = get_payment_entry_vouchers(
|
||||||
|
parties, tax_details, inv.company, party_type=party_type
|
||||||
|
)
|
||||||
|
|
||||||
advance_vouchers = get_advance_vouchers(
|
advance_vouchers = get_advance_vouchers(
|
||||||
parties,
|
parties,
|
||||||
company=inv.company,
|
company=inv.company,
|
||||||
@@ -275,7 +280,8 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
|
|||||||
to_date=tax_details.to_date,
|
to_date=tax_details.to_date,
|
||||||
party_type=party_type,
|
party_type=party_type,
|
||||||
)
|
)
|
||||||
taxable_vouchers = vouchers + advance_vouchers
|
|
||||||
|
taxable_vouchers = vouchers + advance_vouchers + payment_entry_vouchers
|
||||||
tax_deducted_on_advances = 0
|
tax_deducted_on_advances = 0
|
||||||
|
|
||||||
if inv.doctype == "Purchase Invoice":
|
if inv.doctype == "Purchase Invoice":
|
||||||
@@ -387,6 +393,20 @@ def get_invoice_vouchers(parties, tax_details, company, party_type="Supplier"):
|
|||||||
return vouchers, voucher_wise_amount
|
return vouchers, voucher_wise_amount
|
||||||
|
|
||||||
|
|
||||||
|
def get_payment_entry_vouchers(parties, tax_details, company, party_type="Supplier"):
|
||||||
|
payment_entry_filters = {
|
||||||
|
"party_type": party_type,
|
||||||
|
"party": ("in", parties),
|
||||||
|
"docstatus": 1,
|
||||||
|
"apply_tax_withholding_amount": 1,
|
||||||
|
"posting_date": ["between", (tax_details.from_date, tax_details.to_date)],
|
||||||
|
"tax_withholding_category": tax_details.get("tax_withholding_category"),
|
||||||
|
"company": company,
|
||||||
|
}
|
||||||
|
|
||||||
|
return frappe.db.get_all("Payment Entry", filters=payment_entry_filters, pluck="name")
|
||||||
|
|
||||||
|
|
||||||
def get_advance_vouchers(parties, company=None, from_date=None, to_date=None, party_type="Supplier"):
|
def get_advance_vouchers(parties, company=None, from_date=None, to_date=None, party_type="Supplier"):
|
||||||
"""
|
"""
|
||||||
Use Payment Ledger to fetch unallocated Advance Payments
|
Use Payment Ledger to fetch unallocated Advance Payments
|
||||||
|
|||||||
Reference in New Issue
Block a user