feat: add reverse charge to uae vat report
This commit is contained in:
parent
91f1e26672
commit
031d77be2e
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from erpnext.regional.united_arab_emirates.utils import get_tax_accounts
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns = get_columns()
|
columns = get_columns()
|
||||||
@ -70,19 +71,21 @@ def get_data(filters = None):
|
|||||||
"vat_amount": 0
|
"vat_amount": 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
data.append(
|
||||||
|
{
|
||||||
|
"no": '3',
|
||||||
|
"legend": f'Supplies subject to the reverse charge provision',
|
||||||
|
"amount": get_reverse_charge_total(filters),
|
||||||
|
"vat_amount": get_reverse_charge_tax(filters)
|
||||||
|
}
|
||||||
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def get_total_emiratewise(filters):
|
def get_total_emiratewise(filters):
|
||||||
conditions = get_conditions(filters)
|
|
||||||
print(f"""
|
|
||||||
select emirate, sum(total), sum(total_taxes_and_charges) from `tabSales Invoice`
|
|
||||||
where docstatus = 1 {conditions}
|
|
||||||
group by `tabSales Invoice`.emirate;
|
|
||||||
""")
|
|
||||||
return frappe.db.sql(f"""
|
return frappe.db.sql(f"""
|
||||||
select emirate, sum(total), sum(total_taxes_and_charges) from `tabSales Invoice`
|
select emirate, sum(total), sum(total_taxes_and_charges) from `tabSales Invoice`
|
||||||
where docstatus = 1 {conditions}
|
where docstatus = 1 {get_conditions(filters)}
|
||||||
group by `tabSales Invoice`.emirate;
|
group by `tabSales Invoice`.emirate;
|
||||||
""", filters)
|
""", filters)
|
||||||
|
|
||||||
@ -99,10 +102,40 @@ def get_emirates():
|
|||||||
|
|
||||||
def get_conditions(filters):
|
def get_conditions(filters):
|
||||||
conditions = ""
|
conditions = ""
|
||||||
|
for opts in (("company", f' and company="{filters.get("company")}"'),
|
||||||
|
("from_date", f' and posting_date>="{filters.get("from_date")}"'),
|
||||||
|
("to_date", f' and posting_date<="{filters.get("to_date")}"')):
|
||||||
|
if filters.get(opts[0]):
|
||||||
|
conditions += opts[1]
|
||||||
|
return conditions
|
||||||
|
|
||||||
for opts in (("company", " and company=%(company)s"),
|
def get_reverse_charge_tax(filters):
|
||||||
("from_date", " and posting_date>=%(from_date)s"),
|
return frappe.db.sql(f"""
|
||||||
("to_date", " and posting_date<=%(to_date)s")):
|
select sum(debit) from
|
||||||
|
`tabPurchase Invoice` inner join `tabGL Entry`
|
||||||
|
on `tabGL Entry`.voucher_no = `tabPurchase Invoice`.name
|
||||||
|
where
|
||||||
|
`tabPurchase Invoice`.reverse_charge = "Y"
|
||||||
|
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]
|
||||||
|
|
||||||
|
|
||||||
|
def get_reverse_charge_total(filters):
|
||||||
|
return frappe.db.sql(f"""
|
||||||
|
select sum(total) from
|
||||||
|
`tabPurchase Invoice`
|
||||||
|
where
|
||||||
|
reverse_charge = "Y"
|
||||||
|
and docstatus = 1 {get_conditions(filters)} ;
|
||||||
|
""")[0][0]
|
||||||
|
|
||||||
|
def get_conditions_join(filters):
|
||||||
|
conditions = ""
|
||||||
|
for opts in (("company", f' and `tabPurchase Invoice`.company="{filters.get("company")}"'),
|
||||||
|
("from_date", f' and `tabPurchase Invoice`.posting_date>="{filters.get("from_date")}"'),
|
||||||
|
("to_date", f' and `tabPurchase Invoice`.posting_date<="{filters.get("to_date")}"')):
|
||||||
if filters.get(opts[0]):
|
if filters.get(opts[0]):
|
||||||
conditions += opts[1]
|
conditions += opts[1]
|
||||||
return conditions
|
return conditions
|
@ -20,7 +20,7 @@ def make_custom_fields():
|
|||||||
insert_after='group_same_items', print_hide=1, collapsible=1),
|
insert_after='group_same_items', print_hide=1, collapsible=1),
|
||||||
dict(fieldname='permit_no', label='Permit Number',
|
dict(fieldname='permit_no', label='Permit Number',
|
||||||
fieldtype='Data', insert_after='vat_section', print_hide=1),
|
fieldtype='Data', insert_after='vat_section', print_hide=1),
|
||||||
dict(fieldname='reverse_charge_applicable', label='Reverse Charge Applicable',
|
dict(fieldname='reverse_charge', label='Reverse Charge Applicable',
|
||||||
fieldtype='Select', insert_after='permit_no', print_hide=1,
|
fieldtype='Select', insert_after='permit_no', print_hide=1,
|
||||||
options='Y\nN', default='N')
|
options='Y\nN', default='N')
|
||||||
]
|
]
|
||||||
@ -42,7 +42,7 @@ def make_custom_fields():
|
|||||||
fieldtype='Read Only', insert_after='customer_name',
|
fieldtype='Read Only', insert_after='customer_name',
|
||||||
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',
|
||||||
fetch_from='customer_address.emirates'),
|
fieldtype='Read Only', fetch_from='customer_address.emirates'),
|
||||||
]
|
]
|
||||||
|
|
||||||
invoice_item_fields = [
|
invoice_item_fields = [
|
||||||
@ -79,8 +79,8 @@ def make_custom_fields():
|
|||||||
fieldtype='Data', insert_after='supplier_name'),
|
fieldtype='Data', insert_after='supplier_name'),
|
||||||
],
|
],
|
||||||
'Address': [
|
'Address': [
|
||||||
dict(fieldname='emirates', label='Emirates',
|
dict(fieldname='emirates', label='Emirates', fieldtype='Select', insert_after='state',
|
||||||
fieldtype='Data', insert_after='state'),
|
options='Abu Dhabi\nAjman\nDubai\nFujairah\nRas Al Khaimah\nSharjah\nUmm Al Quwain')
|
||||||
],
|
],
|
||||||
'Purchase Invoice': purchase_invoice_fields + invoice_fields,
|
'Purchase Invoice': purchase_invoice_fields + invoice_fields,
|
||||||
'Purchase Order': purchase_invoice_fields + invoice_fields,
|
'Purchase Order': purchase_invoice_fields + invoice_fields,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user