def get_total_emiratewise(filters):
βββReturns Emiratewise Amount and Taxes.βββ
conditions = get_conditions(filters)
try:
return frappe.db.sql(ββ"
select
s.vat_emirate as emirate, sum(i.base_amount) as total, sum(s.total_taxes_and_charges)
from tabSales Invoice Item i inner join tabSales Invoice s
on
i.parent = s.name
where
s.docstatus = 1 and i.is_exempt != 1 and i.is_zero_rated != 1
{where_conditions}
group by
s.vat_emirate;
ββ".format(where_conditions=conditions), filters)
except (IndexError, TypeError):
return 0
select
s.vat_emirate as emirate, sum(i.base_amount) astotal,sum(s.total_taxes_and_charges)
Trying to understand this select why Total is a sum of Sale Inoice Item and the Tax is picked from Sales Invoice field total_taxes_and_charges (and also the sum here is confusing)