Skip to content

Commit

Permalink
fix: TDS deduction via journal entry
Browse files Browse the repository at this point in the history
(cherry picked from commit 36d0906)
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed Sep 20, 2022
1 parent e07fd46 commit ca0cce7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 3 additions & 1 deletion erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def apply_tax_withholding(self):
}
)

tax_withholding_details = get_party_tax_withholding_details(inv, self.tax_withholding_category)
tax_withholding_details, advance_taxes, voucher_wise_amount = get_party_tax_withholding_details(
inv, self.tax_withholding_category
)

if not tax_withholding_details:
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,25 @@ def get_advance_vouchers(


def get_taxes_deducted_on_advances_allocated(inv, tax_details):
advances = [d.reference_name for d in inv.get("advances")]
tax_info = []

if advances:
pe = frappe.qb.DocType("Payment Entry").as_("pe")
at = frappe.qb.DocType("Advance Taxes and Charges").as_("at")

tax_info = (
frappe.qb.from_(at)
.inner_join(pe)
.on(pe.name == at.parent)
.select(at.parent, at.name, at.tax_amount, at.allocated_amount)
.where(pe.tax_withholding_category == tax_details.get("tax_withholding_category"))
.where(at.parent.isin(advances))
.where(at.account_head == tax_details.account_head)
.run(as_dict=True)
)
if inv.get("advances"):
advances = [d.reference_name for d in inv.get("advances")]

if advances:
pe = frappe.qb.DocType("Payment Entry").as_("pe")
at = frappe.qb.DocType("Advance Taxes and Charges").as_("at")

tax_info = (
frappe.qb.from_(at)
.inner_join(pe)
.on(pe.name == at.parent)
.select(at.parent, at.name, at.tax_amount, at.allocated_amount)
.where(pe.tax_withholding_category == tax_details.get("tax_withholding_category"))
.where(at.parent.isin(advances))
.where(at.account_head == tax_details.account_head)
.run(as_dict=True)
)

return tax_info

Expand Down

0 comments on commit ca0cce7

Please sign in to comment.