diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 9fea3cb1b16..e9d6d14cbd9 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -428,3 +428,4 @@ erpnext.patches.v15_0.set_company_on_pos_inv_merge_log erpnext.patches.v15_0.rename_price_list_to_buying_price_list erpnext.patches.v15_0.patch_missing_buying_price_list_in_material_request erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice +erpnext.patches.v15_0.update_uae_zero_rated_fetch diff --git a/erpnext/patches/v15_0/update_uae_zero_rated_fetch.py b/erpnext/patches/v15_0/update_uae_zero_rated_fetch.py new file mode 100644 index 00000000000..a769cc0a85e --- /dev/null +++ b/erpnext/patches/v15_0/update_uae_zero_rated_fetch.py @@ -0,0 +1,9 @@ +import frappe +from frappe.custom.doctype.property_setter.property_setter import make_property_setter + + +def execute(): + if not frappe.db.get_value("Company", {"country": "United Arab Emirates"}): + return + + make_property_setter("Sales Invoice Item", "is_zero_rated", "fetch_if_empty", 1, "Check") diff --git a/erpnext/regional/report/uae_vat_201/uae_vat_201.py b/erpnext/regional/report/uae_vat_201/uae_vat_201.py index 1a68d7dec6a..7cf86adbe01 100644 --- a/erpnext/regional/report/uae_vat_201/uae_vat_201.py +++ b/erpnext/regional/report/uae_vat_201/uae_vat_201.py @@ -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; diff --git a/erpnext/regional/united_arab_emirates/setup.py b/erpnext/regional/united_arab_emirates/setup.py index 36a079546e5..6a8c7b9438b 100644 --- a/erpnext/regional/united_arab_emirates/setup.py +++ b/erpnext/regional/united_arab_emirates/setup.py @@ -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, ) diff --git a/erpnext/regional/united_arab_emirates/utils.py b/erpnext/regional/united_arab_emirates/utils.py index 8265c27831f..8e23fe9e81b 100644 --- a/erpnext/regional/united_arab_emirates/utils.py +++ b/erpnext/regional/united_arab_emirates/utils.py @@ -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 @@ -19,6 +15,14 @@ def update_itemised_tax_data(doc): return itemised_tax = get_itemised_tax(doc.taxes) + is_export = 0 + + if doc.customer_address and doc.company_address: + company_country = frappe.get_cached_value("Address", doc.company_address, "country") + customer_country = frappe.db.get_value("Address", doc.customer_address, "country") + + if company_country != customer_country: + is_export = 1 for row in doc.items: tax_rate, tax_amount = 0.0, 0.0 @@ -30,6 +34,7 @@ def update_itemised_tax_data(doc): tax_amount += flt((row.net_amount * _tax_rate) / 100, row.precision("tax_amount")) tax_rate += _tax_rate + row.is_zero_rated = is_export 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"))