Skip to content

Commit

Permalink
Merge pull request #41685 from ruthra-kumar/allow_partial_tds_on_purc…
Browse files Browse the repository at this point in the history
…hase_invoice

refactor: enabling partial TDS application on partial invoice
  • Loading branch information
ruthra-kumar authored Jun 11, 2024
2 parents 7ce9f7b + 091c549 commit 4c03dcb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ frappe.ui.form.on("Purchase Invoice", {
if (frm.doc.supplier) {
frm.doc.apply_tds = frm.doc.__onload.supplier_tds ? 1 : 0;
}
if (!frm.doc.__onload.supplier_tds) {
if (!frm.doc.__onload.enable_apply_tds) {
frm.set_df_property("apply_tds", "read_only", 1);
}
}
Expand Down
16 changes: 16 additions & 0 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ def set_missing_values(self, for_validate=False):
self.tax_withholding_category = tds_category
self.set_onload("supplier_tds", tds_category)

# If Linked Purchase Order has TDS applied, enable 'apply_tds' checkbox
if purchase_orders := [x.purchase_order for x in self.items if x.purchase_order]:
po = qb.DocType("Purchase Order")
po_with_tds = (
qb.from_(po)
.select(po.name)
.where(
po.docstatus.eq(1)
& (po.name.isin(purchase_orders))
& (po.apply_tds.eq(1))
& (po.tax_withholding_category.notnull())
)
.run()
)
self.set_onload("enable_apply_tds", True if po_with_tds else False)

super().set_missing_values(for_validate)

def validate_credit_to_acc(self):
Expand Down

0 comments on commit 4c03dcb

Please sign in to comment.