From 0fd0695bbbaec834bd120b4fdc93bc7142f60532 Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Tue, 18 Feb 2025 12:52:33 +0530 Subject: [PATCH] fix: set taxes before calculating taxes and totals --- erpnext/controllers/accounts_controller.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 93489231cf0..df8c33a0fb8 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -197,6 +197,14 @@ class AccountsController(TransactionBase): self.set_incoming_rate() self.init_internal_values() + # Need to set taxes based on taxes_and_charges template + # before calculating taxes and totals + if self.meta.get_field("taxes_and_charges"): + self.validate_enabled_taxes_and_charges() + self.validate_tax_account_company() + + self.set_taxes_and_charges() + if self.meta.get_field("currency"): self.calculate_taxes_and_totals() @@ -207,10 +215,6 @@ class AccountsController(TransactionBase): self.validate_all_documents_schedule() - if self.meta.get_field("taxes_and_charges"): - self.validate_enabled_taxes_and_charges() - self.validate_tax_account_company() - self.validate_party() self.validate_currency() self.validate_party_account_currency() @@ -255,8 +259,6 @@ class AccountsController(TransactionBase): self.validate_deferred_income_expense_account() self.set_inter_company_account() - self.set_taxes_and_charges() - if self.doctype == "Purchase Invoice": self.calculate_paid_amount() # apply tax withholding only if checked and applicable