diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index b14597d3a0..83698f887c 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -61,11 +61,11 @@ class PurchaseInvoice(BuyingController): self.validate_posting_time() + super(PurchaseInvoice, self).validate() + # apply tax withholding only if checked and applicable self.set_tax_withholding() - super(PurchaseInvoice, self).validate() - if not self.is_return: self.po_required() self.pr_required() @@ -839,6 +839,9 @@ class PurchaseInvoice(BuyingController): if not accounts or tax_withholding_details.get("account_head") not in accounts: self.append("taxes", tax_withholding_details) + # calculate totals again after applying TDS + self.calculate_taxes_and_totals() + @frappe.whitelist() def make_debit_note(source_name, target_doc=None): from erpnext.controllers.sales_and_purchase_return import make_return_doc