mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-01 09:36:53 +00:00
fix(regional-uae): split export determination
(cherry picked from commit dc72e6cf36)
This commit is contained in:
@@ -15,14 +15,25 @@ def update_itemised_tax_data(doc):
|
|||||||
return
|
return
|
||||||
|
|
||||||
itemised_tax = get_itemised_tax(doc.taxes)
|
itemised_tax = get_itemised_tax(doc.taxes)
|
||||||
is_export = 0
|
is_export = False
|
||||||
|
|
||||||
if doc.customer_address and doc.company_address:
|
def determine_if_export(doc):
|
||||||
company_country = frappe.get_cached_value("Address", doc.company_address, "country")
|
if doc.flags.export_determined is not None:
|
||||||
customer_country = frappe.db.get_value("Address", doc.customer_address, "country")
|
return doc.flags.export_determined
|
||||||
|
|
||||||
if company_country != customer_country:
|
doc.flags.export_determined = False
|
||||||
is_export = 1
|
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:
|
||||||
|
doc.flags.export_determined = True
|
||||||
|
return doc.flags.export_determined
|
||||||
|
else:
|
||||||
|
frappe.msgprint(
|
||||||
|
_("Please set Customer and Company Address to determine if the transaction is an export."),
|
||||||
|
alert=True,
|
||||||
|
)
|
||||||
|
|
||||||
for row in doc.items:
|
for row in doc.items:
|
||||||
tax_rate, tax_amount = 0.0, 0.0
|
tax_rate, tax_amount = 0.0, 0.0
|
||||||
@@ -34,11 +45,16 @@ def update_itemised_tax_data(doc):
|
|||||||
tax_amount += flt((row.net_amount * _tax_rate) / 100, row.precision("tax_amount"))
|
tax_amount += flt((row.net_amount * _tax_rate) / 100, row.precision("tax_amount"))
|
||||||
tax_rate += _tax_rate
|
tax_rate += _tax_rate
|
||||||
|
|
||||||
row.is_zero_rated = is_export
|
if not row.is_zero_rated and not tax_rate:
|
||||||
|
is_export = is_export or determine_if_export(doc)
|
||||||
|
row.is_zero_rated = is_export
|
||||||
|
|
||||||
row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
|
row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
|
||||||
row.tax_amount = flt(tax_amount, row.precision("tax_amount"))
|
row.tax_amount = flt(tax_amount, row.precision("tax_amount"))
|
||||||
row.total_amount = flt((row.net_amount + row.tax_amount), row.precision("total_amount"))
|
row.total_amount = flt((row.net_amount + row.tax_amount), row.precision("total_amount"))
|
||||||
|
|
||||||
|
doc.flags.export_determined = None
|
||||||
|
|
||||||
|
|
||||||
def get_account_currency(account):
|
def get_account_currency(account):
|
||||||
"""Helper function to get account currency."""
|
"""Helper function to get account currency."""
|
||||||
|
|||||||
Reference in New Issue
Block a user