diff --git a/erpnext/hooks.py b/erpnext/hooks.py index a0242c175c..8d08c90047 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -242,15 +242,13 @@ doc_events = { "erpnext.regional.italy.utils.sales_invoice_on_cancel", "erpnext.erpnext_integrations.taxjar_integration.delete_transaction" ], - "validate": [ - "erpnext.regional.united_arab_emirates.utils.validate_returns", - ], "on_trash": "erpnext.regional.check_deletion_permission" }, "Purchase Invoice": { "validate": [ "erpnext.regional.india.utils.update_grand_total_for_rcm", "erpnext.regional.united_arab_emirates.utils.update_grand_total_for_rcm", + "erpnext.regional.united_arab_emirates.utils.validate_returns" ] }, "Payment Entry": { diff --git a/erpnext/regional/report/uae_vat_21/uae_vat_21.py b/erpnext/regional/report/uae_vat_21/uae_vat_21.py index 2bded71ec2..227c2fb5a1 100644 --- a/erpnext/regional/report/uae_vat_21/uae_vat_21.py +++ b/erpnext/regional/report/uae_vat_21/uae_vat_21.py @@ -277,7 +277,7 @@ def get_standard_rated_expenses_total(filters): conditions = get_conditions(filters) return frappe.db.sql(""" select sum(total) from - `tabSales Invoice` + `tabPurchase Invoice` where standard_rated_expenses > 0 and docstatus = 1 {where_conditions} ; @@ -288,7 +288,7 @@ def get_standard_rated_expenses_tax(filters): conditions = get_conditions(filters) return frappe.db.sql(""" select sum(standard_rated_expenses) from - `tabSales Invoice` + `tabPurchase Invoice` where standard_rated_expenses > 0 and docstatus = 1 {where_conditions} ; diff --git a/erpnext/regional/united_arab_emirates/setup.py b/erpnext/regional/united_arab_emirates/setup.py index 0de42120c4..e48b9a9ce1 100644 --- a/erpnext/regional/united_arab_emirates/setup.py +++ b/erpnext/regional/united_arab_emirates/setup.py @@ -38,8 +38,11 @@ def make_custom_fields(): dict(fieldname='supplier_name_in_arabic', label='Supplier Name in Arabic', fieldtype='Read Only', insert_after='supplier_name', fetch_from='supplier.supplier_name_in_arabic', print_hide=1), + dict(fieldname='standard_rated_expenses', label='Standard Rated Expenses (AED)', + insert_after='permit_no', fieldtype='Currency', print_hide=1, default='0', + depends_on="eval:doc.reverse_charge=='N'",), dict(fieldname='reverse_charge', label='Reverse Charge Applicable', - fieldtype='Select', insert_after='permit_no', print_hide=1, + fieldtype='Select', insert_after='standard_rated_expenses', print_hide=1, options='Y\nN', default='N'), dict(fieldname='claimable_reverse_charge', label='Claimable Reverse Charge (Percentage)', insert_after='reverse_charge', fieldtype='Percent', print_hide=1, @@ -57,8 +60,6 @@ def make_custom_fields(): fieldtype='Read Only', fetch_from='customer_address.emirates'), dict(fieldname='tourist_tax_return', label='Tax Refund provided to Tourists (AED)', insert_after='permit_no', fieldtype='Currency', print_hide=1, default='0'), - dict(fieldname='standard_rated_expenses', label='Standard Rated Expenses (AED)', - insert_after='tourist_tax_return', fieldtype='Currency', print_hide=1, default='0'), ] invoice_item_fields = [ diff --git a/erpnext/regional/united_arab_emirates/utils.py b/erpnext/regional/united_arab_emirates/utils.py index 5a8c3c47fb..dbe283f226 100644 --- a/erpnext/regional/united_arab_emirates/utils.py +++ b/erpnext/regional/united_arab_emirates/utils.py @@ -143,11 +143,13 @@ def make_regional_gl_entries(gl_entries, doc): return gl_entries def validate_returns(doc, method): - """Sum of Tourist Returns and Standard Rated Expenses should be less than Total Tax.""" + """Standard Rated expenses should not be set when Reverse Charge Applicable is set.""" country = frappe.get_cached_value('Company', doc.company, 'country') - + print("-"*50) + print(doc.reverse_charge) + print(flt(doc.standard_rated_expenses)) if country != 'United Arab Emirates': return - if flt(doc.tourist_tax_return) + flt(doc.standard_rated_expenses) > flt(doc.total_taxes_and_charges): - frappe.throw(_("The Total Returns(Tax Refund provided to Tourists (AED) + Standard Rated Expenses (AED)) should be less than the Total Taxes and Charges (Company Currency)")) \ No newline at end of file + if doc.reverse_charge == 'Y' and flt(doc.standard_rated_expenses) != 0: + frappe.throw(_("Standard Rated expenses should not be set when Reverse Charge Applicable is Y")) \ No newline at end of file