feat(UAE VAT 21): Add zero rated and vat exempt
This commit is contained in:
parent
5225215d31
commit
72cad2a8ab
@ -27,5 +27,15 @@ frappe.query_reports["UAE VAT"] = {
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"default": frappe.datetime.get_today()
|
"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;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -41,12 +41,6 @@ def get_columns():
|
|||||||
"label": "VAT Amount (AED)",
|
"label": "VAT Amount (AED)",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"width": 100
|
"width": 100
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "adjustment",
|
|
||||||
"label": "Adjustment (AED)",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"width": 100
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -61,7 +55,12 @@ def get_data(filters = None):
|
|||||||
Dict: Dictionary containing chart data
|
Dict: Dictionary containing chart data
|
||||||
"""
|
"""
|
||||||
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)
|
total_emiratewise = get_total_emiratewise(filters)
|
||||||
emirates = get_emirates()
|
emirates = get_emirates()
|
||||||
amounts_by_emirate = {}
|
amounts_by_emirate = {}
|
||||||
@ -108,7 +107,30 @@ def get_data(filters = None):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
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(
|
data.append(
|
||||||
{
|
{
|
||||||
"no": '9',
|
"no": '9',
|
||||||
@ -226,7 +248,7 @@ def get_reverse_charge_total(filters):
|
|||||||
where
|
where
|
||||||
reverse_charge = "Y"
|
reverse_charge = "Y"
|
||||||
and docstatus = 1 {get_conditions(filters)} ;
|
and docstatus = 1 {get_conditions(filters)} ;
|
||||||
""")[0][0]
|
""")[0][0] or 0
|
||||||
|
|
||||||
def get_reverse_charge_tax(filters):
|
def get_reverse_charge_tax(filters):
|
||||||
"""Returns the sum of the tax of each Purchase invoice made
|
"""Returns the sum of the tax of each Purchase invoice made
|
||||||
@ -246,7 +268,7 @@ def get_reverse_charge_tax(filters):
|
|||||||
and `tabPurchase Invoice`.docstatus = 1
|
and `tabPurchase Invoice`.docstatus = 1
|
||||||
and `tabGL Entry`.docstatus = 1 {get_conditions_join(filters)}
|
and `tabGL Entry`.docstatus = 1 {get_conditions_join(filters)}
|
||||||
and account in ("{'", "'.join(get_tax_accounts(filters['company']))}");
|
and account in ("{'", "'.join(get_tax_accounts(filters['company']))}");
|
||||||
""")[0][0]
|
""")[0][0] or 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -292,7 +314,7 @@ def get_reverse_charge_recoverable_total(filters):
|
|||||||
reverse_charge = "Y"
|
reverse_charge = "Y"
|
||||||
and claimable_reverse_charge > 0
|
and claimable_reverse_charge > 0
|
||||||
and docstatus = 1 {get_conditions(filters)} ;
|
and docstatus = 1 {get_conditions(filters)} ;
|
||||||
""")[0][0]
|
""")[0][0] or 0
|
||||||
|
|
||||||
|
|
||||||
def get_reverse_charge_recoverable_tax(filters):
|
def get_reverse_charge_recoverable_tax(filters):
|
||||||
@ -314,7 +336,7 @@ def get_reverse_charge_recoverable_tax(filters):
|
|||||||
and `tabPurchase Invoice`.claimable_reverse_charge > 0
|
and `tabPurchase Invoice`.claimable_reverse_charge > 0
|
||||||
and `tabGL Entry`.docstatus = 1 {get_conditions_join(filters)}
|
and `tabGL Entry`.docstatus = 1 {get_conditions_join(filters)}
|
||||||
and account in ("{'", "'.join(get_tax_accounts(filters['company']))}");
|
and account in ("{'", "'.join(get_tax_accounts(filters['company']))}");
|
||||||
""")[0][0]
|
""")[0][0] or 0
|
||||||
|
|
||||||
|
|
||||||
def get_standard_rated_expenses_total(filters):
|
def get_standard_rated_expenses_total(filters):
|
||||||
@ -340,7 +362,7 @@ def get_standard_rated_expenses_total(filters):
|
|||||||
where
|
where
|
||||||
standard_rated_expenses > 0
|
standard_rated_expenses > 0
|
||||||
and docstatus = 1 {get_conditions(filters)} ;
|
and docstatus = 1 {get_conditions(filters)} ;
|
||||||
""")[0][0]
|
""")[0][0] or 0
|
||||||
|
|
||||||
|
|
||||||
def get_standard_rated_expenses_tax(filters):
|
def get_standard_rated_expenses_tax(filters):
|
||||||
@ -358,7 +380,7 @@ def get_standard_rated_expenses_tax(filters):
|
|||||||
where
|
where
|
||||||
standard_rated_expenses > 0
|
standard_rated_expenses > 0
|
||||||
and docstatus = 1 {get_conditions(filters)} ;
|
and docstatus = 1 {get_conditions(filters)} ;
|
||||||
""")[0][0]
|
""")[0][0] or 0
|
||||||
|
|
||||||
def get_tourist_tax_return_total(filters):
|
def get_tourist_tax_return_total(filters):
|
||||||
"""Returns the sum of the total of each Sales invoice with non zero tourist_tax_return
|
"""Returns the sum of the total of each Sales invoice with non zero tourist_tax_return
|
||||||
@ -383,7 +405,7 @@ def get_tourist_tax_return_total(filters):
|
|||||||
where
|
where
|
||||||
tourist_tax_return > 0
|
tourist_tax_return > 0
|
||||||
and docstatus = 1 {get_conditions(filters)} ;
|
and docstatus = 1 {get_conditions(filters)} ;
|
||||||
""")[0][0]
|
""")[0][0] or 0
|
||||||
|
|
||||||
|
|
||||||
def get_tourist_tax_return_tax(filters):
|
def get_tourist_tax_return_tax(filters):
|
||||||
@ -401,4 +423,37 @@ def get_tourist_tax_return_tax(filters):
|
|||||||
where
|
where
|
||||||
tourist_tax_return > 0
|
tourist_tax_return > 0
|
||||||
and docstatus = 1 {get_conditions(filters)} ;
|
and docstatus = 1 {get_conditions(filters)} ;
|
||||||
""")[0][0]
|
""")[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
|
@ -15,6 +15,13 @@ def setup(company=None, patch=True):
|
|||||||
create_sales_tax(company)
|
create_sales_tax(company)
|
||||||
|
|
||||||
def make_custom_fields():
|
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 = [
|
invoice_fields = [
|
||||||
dict(fieldname='vat_section', label='VAT Details', fieldtype='Section Break',
|
dict(fieldname='vat_section', label='VAT Details', fieldtype='Section Break',
|
||||||
insert_after='group_same_items', print_hide=1, collapsible=1),
|
insert_after='group_same_items', print_hide=1, collapsible=1),
|
||||||
@ -46,8 +53,6 @@ def make_custom_fields():
|
|||||||
fetch_from='customer.customer_name_in_arabic', print_hide=1),
|
fetch_from='customer.customer_name_in_arabic', print_hide=1),
|
||||||
dict(fieldname='emirate', label='Emirate', insert_after='customer_address',
|
dict(fieldname='emirate', label='Emirate', insert_after='customer_address',
|
||||||
fieldtype='Read Only', fetch_from='customer_address.emirates'),
|
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)',
|
dict(fieldname='tourist_tax_return', label='Tax Refund provided to Tourists (AED)',
|
||||||
insert_after='permit_no', fieldtype='Currency', print_hide=1, default='0'),
|
insert_after='permit_no', fieldtype='Currency', print_hide=1, default='0'),
|
||||||
dict(fieldname='standard_rated_expenses', label='Standard Rated Expenses (AED)',
|
dict(fieldname='standard_rated_expenses', label='Standard Rated Expenses (AED)',
|
||||||
@ -78,10 +83,12 @@ def make_custom_fields():
|
|||||||
'Item': [
|
'Item': [
|
||||||
dict(fieldname='tax_code', label='Tax Code',
|
dict(fieldname='tax_code', label='Tax Code',
|
||||||
fieldtype='Data', insert_after='item_group'),
|
fieldtype='Data', insert_after='item_group'),
|
||||||
# dict(fieldname='is_zero_rated', label='Is Zero Rated',
|
dict(fieldname='is_zero_rated', label='Is Zero Rated',
|
||||||
# fieldtype='Check', insert_after='tax_code'),
|
fieldtype='Check', insert_after='tax_code',
|
||||||
# dict(fieldname='is_exempt', label='Is Exempt ',
|
print_hide=1),
|
||||||
# fieldtype='Check', insert_after='is_zero_rated')
|
dict(fieldname='is_exempt', label='Is Exempt ',
|
||||||
|
fieldtype='Check', insert_after='is_zero_rated',
|
||||||
|
print_hide=1)
|
||||||
],
|
],
|
||||||
'Customer': [
|
'Customer': [
|
||||||
dict(fieldname='customer_name_in_arabic', label='Customer Name in Arabic',
|
dict(fieldname='customer_name_in_arabic', label='Customer Name in Arabic',
|
||||||
@ -101,7 +108,7 @@ def make_custom_fields():
|
|||||||
'Sales Invoice': sales_invoice_fields + invoice_fields,
|
'Sales Invoice': sales_invoice_fields + invoice_fields,
|
||||||
'Sales Order': sales_invoice_fields + invoice_fields,
|
'Sales Order': sales_invoice_fields + invoice_fields,
|
||||||
'Delivery Note': 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,
|
'Purchase Invoice Item': invoice_item_fields,
|
||||||
'Sales Order Item': invoice_item_fields,
|
'Sales Order Item': invoice_item_fields,
|
||||||
'Delivery Note Item': invoice_item_fields,
|
'Delivery Note Item': invoice_item_fields,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user