Merge pull request #49085 from frappe/mergify/bp/version-15-hotfix/pr-48730

fix(regional-uae): mark export items as zero rated (backport #48730)
This commit is contained in:
ruthra kumar
2025-08-11 12:35:56 +05:30
committed by GitHub
5 changed files with 39 additions and 5 deletions

View File

@@ -419,3 +419,4 @@ erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice
erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting #2025-08-04
execute:frappe.db.set_single_value("Accounts Settings", "fetch_valuation_rate_for_internal_transaction", 1)
erpnext.patches.v15_0.add_company_payment_gateway_account
erpnext.patches.v15_0.update_uae_zero_rated_fetch

View File

@@ -0,0 +1,10 @@
import frappe
from erpnext.regional.united_arab_emirates.setup import make_custom_fields
def execute():
if not frappe.db.get_value("Company", {"country": "United Arab Emirates"}):
return
make_custom_fields()

View File

@@ -143,7 +143,7 @@ def get_total_emiratewise(filters):
on
i.parent = s.name
where
s.docstatus = 1 and i.is_exempt != 1 and i.is_zero_rated != 1
s.docstatus = 1 and i.is_exempt != 1 and i.is_zero_rated != 1
{conditions}
group by
s.vat_emirate;

View File

@@ -20,6 +20,7 @@ def make_custom_fields():
label="Is Zero Rated",
fieldtype="Check",
fetch_from="item_code.is_zero_rated",
fetch_if_empty=1,
insert_after="description",
print_hide=1,
)

View File

@@ -7,10 +7,6 @@ from erpnext.controllers.taxes_and_totals import get_itemised_tax
def update_itemised_tax_data(doc):
# maybe this should be a standard function rather than a regional one
if not doc.taxes:
return
if not doc.items:
return
@@ -20,6 +16,29 @@ def update_itemised_tax_data(doc):
itemised_tax = get_itemised_tax(doc.taxes)
def determine_if_export(doc):
if doc.doctype != "Sales Invoice":
return False
if not doc.customer_address:
if not doc.total_taxes_and_charges:
frappe.msgprint(
_("Please set Customer Address to determine if the transaction is an export."),
alert=True,
)
return False
company_country = frappe.get_cached_value("Company", doc.company, "country")
customer_country = frappe.db.get_value("Address", doc.customer_address, "country")
if company_country != customer_country:
return True
return False
is_export = determine_if_export(doc)
for row in doc.items:
tax_rate, tax_amount = 0.0, 0.0
# dont even bother checking in item tax template as it contains both input and output accounts - double the tax rate
@@ -30,6 +49,9 @@ def update_itemised_tax_data(doc):
tax_amount += flt((row.net_amount * _tax_rate) / 100, row.precision("tax_amount"))
tax_rate += _tax_rate
if not tax_rate or row.get("is_zero_rated"):
row.is_zero_rated = is_export or frappe.get_cached_value("Item", row.item_code, "is_zero_rated")
row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
row.tax_amount = flt(tax_amount, row.precision("tax_amount"))
row.total_amount = flt((row.net_amount + row.tax_amount), row.precision("total_amount"))