Merge pull request #23282 from deepeshgarg007/tds_bug
fix: Apply TDS on Purchase Invoice creation from Purchase Order and Purchase Receipt
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 4f6be59..2bfa4a5 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -25,6 +25,12 @@
this.frm.set_df_property("credit_to", "print_hide", 0);
}
}
+
+ // Trigger supplier event on load if supplier is available
+ // The reason for this is PI can be created from PR or PO and supplier is pre populated
+ if (this.frm.doc.supplier) {
+ this.frm.trigger('supplier');
+ }
},
refresh: function(doc) {
@@ -135,6 +141,8 @@
}
});
}
+
+ this.frm.set_df_property("tax_withholding_category", "hidden", doc.apply_tds ? 0 : 1);
},
unblock_invoice: function() {
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 7b1062f..b4ee7c9 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -132,6 +132,11 @@
if not self.due_date:
self.due_date = get_due_date(self.posting_date, "Supplier", self.supplier, self.company, self.bill_date)
+ tds_category = frappe.db.get_value("Supplier", self.supplier, "tax_withholding_category")
+ if tds_category and not for_validate:
+ self.apply_tds = 1
+ self.tax_withholding_category = tds_category
+
super(PurchaseInvoice, self).set_missing_values(for_validate)
def check_conversion_rate(self):