From 481752134fc9a0e15fbfb4b372cee16b460651ce Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 13 May 2022 18:08:32 +0530 Subject: [PATCH] fix: Add validation for SEZ and Export invoices without payment of taxes (cherry picked from commit cb8453dac8c38aed201f84c51f27ae217cc1f465) --- erpnext/hooks.py | 1 + erpnext/regional/india/utils.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index d1b5113e2b..813ac17ca0 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -321,6 +321,7 @@ doc_events = { "validate": [ "erpnext.regional.india.utils.validate_document_name", "erpnext.regional.india.utils.update_taxable_values", + "erpnext.regional.india.utils.validate_sez_and_export_invoices", ], }, "POS Invoice": {"on_submit": ["erpnext.regional.saudi_arabia.utils.create_qr_code"]}, diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 0b6fcc6f7a..6a7e113390 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -840,6 +840,30 @@ def get_gst_accounts( return gst_accounts +def validate_sez_and_export_invoices(doc, method): + country = frappe.get_cached_value("Company", doc.company, "country") + + if country != "India": + return + + if ( + doc.get("gst_category") in ("SEZ", "Overseas") + and doc.get("export_type") == "Without Payment of Tax" + ): + gst_accounts = get_gst_accounts(doc.company) + + for tax in doc.get("taxes"): + for tax in doc.get("taxes"): + if ( + tax.account_head + in gst_accounts.get("igst_account", []) + + gst_accounts.get("sgst_account", []) + + gst_accounts.get("cgst_account", []) + and tax.tax_amount_after_discount_amount + ): + frappe.throw(_("GST cannot be applied on SEZ or Export invoices without payment of tax")) + + def validate_reverse_charge_transaction(doc, method): country = frappe.get_cached_value("Company", doc.company, "country") @@ -887,6 +911,8 @@ def validate_reverse_charge_transaction(doc, method): frappe.throw(msg) + doc.eligibility_for_itc = "ITC on Reverse Charge" + def update_itc_availed_fields(doc, method): country = frappe.get_cached_value("Company", doc.company, "country")