From bb0290e61fdba63e1ff9441bd236b598d218bb3f Mon Sep 17 00:00:00 2001 From: kunhimohamed Date: Tue, 21 Apr 2026 18:38:02 +0400 Subject: [PATCH] fix(tax_validation): tax id validation based on vat registraton such as turnover --- .../doctype/accounts_settings/accounts_settings.json | 4 ++-- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 1b7c21ab721d..157cf54f72ae 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -299,7 +299,7 @@ "fieldname": "validate_sales_invoice_tax_id", "fieldtype": "Select", "label": "Validate Customer Tax ID for Sales Tax Invoice", - "options": "\nMandatory\nMandatory for Company" + "options": "\nMandatory\nMandatory for Company\nMandatory for Company and Annual Turnover" }, { "default": "0", @@ -325,7 +325,7 @@ "idx": 1, "issingle": 1, "links": [], - "modified": "2025-08-28 14:27:21.809120", + "modified": "2026-04-21 18:35:17.448972", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index bb1d24ac9e44..0cc5f9063353 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -656,6 +656,11 @@ def validate_tax_id_mandatory(self): if validation == "Mandatory for Company": if frappe.get_cached_value("Customer", self.bill_to or self.customer, "customer_type") == "Individual": return + if validation == "Mandatory for Company and Annual Turnover": + if frappe.get_cached_value("Customer", self.bill_to or self.customer, "customer_type") == "Individual" or \ + (frappe.get_cached_value("Customer", self.bill_to or self.customer, "customer_type") == "Company" and \ + frappe.get_cached_value("Customer", self.bill_to or self.customer, "vat_registration_decider") == "Annual Turnover <= 375,000 AED"): + return if validation: frappe.throw(_("Customer {0} or Identification Number is mandatory for Sales Tax Invoice").format(_("Tax ID")))