feat(UAE VAT 21): Add zero rated and vat exempt
diff --git a/erpnext/regional/report/uae_vat/uae_vat.js b/erpnext/regional/report/uae_vat/uae_vat.js
index 45df167..0213956 100644
--- a/erpnext/regional/report/uae_vat/uae_vat.js
+++ b/erpnext/regional/report/uae_vat/uae_vat.js
@@ -27,5 +27,15 @@
"reqd": 1,
"default": frappe.datetime.get_today()
},
- ]
+ ],
+ "formatter": function(value, row, column, data, default_formatter) {
+ if (data
+ && (data.legend=='VAT on Sales and All Other Outputs' || data.legend=='VAT on Expenses and All Other Inputs')
+ && data.legend==value) {
+ value = $(`<span>${value}</span>`);
+ var $value = $(value).css("font-weight", "bold");
+ value = $value.wrap("<p></p>").parent().html();
+ }
+ return value;
+ },
};
diff --git a/erpnext/regional/report/uae_vat/uae_vat.py b/erpnext/regional/report/uae_vat/uae_vat.py
index b3e52be..1a3537c 100644
--- a/erpnext/regional/report/uae_vat/uae_vat.py
+++ b/erpnext/regional/report/uae_vat/uae_vat.py
@@ -41,12 +41,6 @@
"label": "VAT Amount (AED)",
"fieldtype": "Currency",
"width": 100
- },
- {
- "fieldname": "adjustment",
- "label": "Adjustment (AED)",
- "fieldtype": "Currency",
- "width": 100
}
]
@@ -61,7 +55,12 @@
Dict: Dictionary containing chart data
"""
data = []
- data.append({"legend": f'VAT on Sales and All Other Outputs',})
+ data.append({
+ "no": '',
+ "legend": f'VAT on Sales and All Other Outputs',
+ "amount": '',
+ "vat_amount": ''
+ })
total_emiratewise = get_total_emiratewise(filters)
emirates = get_emirates()
amounts_by_emirate = {}
@@ -108,7 +107,30 @@
}
)
- data.append({"legend": f'VAT on Expenses and All Other Inputs'})
+ data.append(
+ {
+ "no": '4',
+ "legend": f'Zero Rated',
+ "amount": get_zero_rated_total(filters),
+ "vat_amount": "-"
+ }
+ )
+
+ data.append(
+ {
+ "no": '5',
+ "legend": f'Exempt Supplies',
+ "amount": get_exempt_total(filters),
+ "vat_amount": "-"
+ }
+ )
+
+ data.append({
+ "no": '',
+ "legend": f'VAT on Expenses and All Other Inputs',
+ "amount": '',
+ "vat_amount": ''
+ })
data.append(
{
"no": '9',
@@ -226,7 +248,7 @@
where
reverse_charge = "Y"
and docstatus = 1 {get_conditions(filters)} ;
- """)[0][0]
+ """)[0][0] or 0
def get_reverse_charge_tax(filters):
"""Returns the sum of the tax of each Purchase invoice made
@@ -246,7 +268,7 @@
and `tabPurchase Invoice`.docstatus = 1
and `tabGL Entry`.docstatus = 1 {get_conditions_join(filters)}
and account in ("{'", "'.join(get_tax_accounts(filters['company']))}");
- """)[0][0]
+ """)[0][0] or 0
@@ -292,7 +314,7 @@
reverse_charge = "Y"
and claimable_reverse_charge > 0
and docstatus = 1 {get_conditions(filters)} ;
- """)[0][0]
+ """)[0][0] or 0
def get_reverse_charge_recoverable_tax(filters):
@@ -314,7 +336,7 @@
and `tabPurchase Invoice`.claimable_reverse_charge > 0
and `tabGL Entry`.docstatus = 1 {get_conditions_join(filters)}
and account in ("{'", "'.join(get_tax_accounts(filters['company']))}");
- """)[0][0]
+ """)[0][0] or 0
def get_standard_rated_expenses_total(filters):
@@ -340,7 +362,7 @@
where
standard_rated_expenses > 0
and docstatus = 1 {get_conditions(filters)} ;
- """)[0][0]
+ """)[0][0] or 0
def get_standard_rated_expenses_tax(filters):
@@ -358,7 +380,7 @@
where
standard_rated_expenses > 0
and docstatus = 1 {get_conditions(filters)} ;
- """)[0][0]
+ """)[0][0] or 0
def get_tourist_tax_return_total(filters):
"""Returns the sum of the total of each Sales invoice with non zero tourist_tax_return
@@ -383,7 +405,7 @@
where
tourist_tax_return > 0
and docstatus = 1 {get_conditions(filters)} ;
- """)[0][0]
+ """)[0][0] or 0
def get_tourist_tax_return_tax(filters):
@@ -401,4 +423,37 @@
where
tourist_tax_return > 0
and docstatus = 1 {get_conditions(filters)} ;
- """)[0][0]
\ No newline at end of file
+ """)[0][0] or 0
+
+def get_zero_rated_total(filters):
+ """Returns the sum of each Sales Invoice Item Amount which is zero rated
+
+ Args:
+ filters (Dict, optional): Dictionary consisting of the filters selected by the user. Defaults to None.
+
+ Returns:
+ Float: sum of each Sales Invoice Item Amount which is zero rated
+ """
+ return frappe.db.sql(f"""
+ select sum(i.base_amount) as total from
+ `tabSales Invoice Item` i, `tabSales Invoice` s
+ where s.docstatus = 1 and i.parent = s.name and i.is_zero_rated = 1
+ {get_conditions(filters)} ;
+ """)[0][0] or 0
+
+
+def get_exempt_total(filters):
+ """Returns the sum of each Sales Invoice Item Amount which is Vat Exempt
+
+ Args:
+ filters (Dict, optional): Dictionary consisting of the filters selected by the user. Defaults to None.
+
+ Returns:
+ Float: sum of each Sales Invoice Item Amount which is Vat Exempt
+ """
+ return frappe.db.sql(f"""
+ select sum(i.base_amount) as total from
+ `tabSales Invoice Item` i, `tabSales Invoice` s
+ where s.docstatus = 1 and i.parent = s.name and i.is_exempt = 1
+ {get_conditions(filters)} ;
+ """)[0][0] or 0
\ No newline at end of file
diff --git a/erpnext/regional/united_arab_emirates/setup.py b/erpnext/regional/united_arab_emirates/setup.py
index 0176340..29ad41c 100644
--- a/erpnext/regional/united_arab_emirates/setup.py
+++ b/erpnext/regional/united_arab_emirates/setup.py
@@ -15,6 +15,13 @@
create_sales_tax(company)
def make_custom_fields():
+ is_zero_rated = dict(fieldname='is_zero_rated', label='Is Zero Rated',
+ fieldtype='Check', fetch_from='item_code.is_zero_rated', insert_after='description',
+ print_hide=1)
+ is_exempt = dict(fieldname='is_exempt', label='Is Exempt',
+ fieldtype='Check', fetch_from='item_code.is_exempt', insert_after='is_zero_rated',
+ print_hide=1)
+
invoice_fields = [
dict(fieldname='vat_section', label='VAT Details', fieldtype='Section Break',
insert_after='group_same_items', print_hide=1, collapsible=1),
@@ -46,8 +53,6 @@
fetch_from='customer.customer_name_in_arabic', print_hide=1),
dict(fieldname='emirate', label='Emirate', insert_after='customer_address',
fieldtype='Read Only', fetch_from='customer_address.emirates'),
- # dict(fieldname='returns_column_break', fieldtype='Column Break',
- # insert_after='select_print_heading'),
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)',
@@ -78,10 +83,12 @@
'Item': [
dict(fieldname='tax_code', label='Tax Code',
fieldtype='Data', insert_after='item_group'),
- # dict(fieldname='is_zero_rated', label='Is Zero Rated',
- # fieldtype='Check', insert_after='tax_code'),
- # dict(fieldname='is_exempt', label='Is Exempt ',
- # fieldtype='Check', insert_after='is_zero_rated')
+ dict(fieldname='is_zero_rated', label='Is Zero Rated',
+ fieldtype='Check', insert_after='tax_code',
+ print_hide=1),
+ dict(fieldname='is_exempt', label='Is Exempt ',
+ fieldtype='Check', insert_after='is_zero_rated',
+ print_hide=1)
],
'Customer': [
dict(fieldname='customer_name_in_arabic', label='Customer Name in Arabic',
@@ -101,7 +108,7 @@
'Sales Invoice': sales_invoice_fields + invoice_fields,
'Sales Order': sales_invoice_fields + invoice_fields,
'Delivery Note': sales_invoice_fields + invoice_fields,
- 'Sales Invoice Item': invoice_item_fields + delivery_date_field,
+ 'Sales Invoice Item': invoice_item_fields + delivery_date_field + [is_zero_rated, is_exempt],
'Purchase Invoice Item': invoice_item_fields,
'Sales Order Item': invoice_item_fields,
'Delivery Note Item': invoice_item_fields,