Fixed Employee Leave Balance Report

This commit is contained in:
Anand Doshi 2014-06-18 16:26:45 +05:30
parent 87179346d4
commit 31c977b906

View File

@ -24,17 +24,19 @@ def execute(filters=None):
else: else:
fiscal_years = frappe.db.sql_list("select name from `tabFiscal Year` order by name desc") fiscal_years = frappe.db.sql_list("select name from `tabFiscal Year` order by name desc")
employee_names = [d.name for d in employees]
allocations = frappe.db.sql("""select employee, fiscal_year, leave_type, total_leaves_allocated allocations = frappe.db.sql("""select employee, fiscal_year, leave_type, total_leaves_allocated
from `tabLeave Allocation` from `tabLeave Allocation`
where docstatus=1 and employee in (%s)""" % where docstatus=1 and employee in (%s)""" %
','.join(['%s']*len(employees)), employees, as_dict=True) ','.join(['%s']*len(employee_names)), employee_names, as_dict=True)
applications = frappe.db.sql("""select employee, fiscal_year, leave_type, applications = frappe.db.sql("""select employee, fiscal_year, leave_type,
SUM(total_leave_days) as leaves SUM(total_leave_days) as leaves
from `tabLeave Application` from `tabLeave Application`
where status="Approved" and docstatus = 1 and employee in (%s) where status="Approved" and docstatus = 1 and employee in (%s)
group by employee, fiscal_year, leave_type""" % group by employee, fiscal_year, leave_type""" %
','.join(['%s']*len(employees)), employees, as_dict=True) ','.join(['%s']*len(employee_names)), employee_names, as_dict=True)
columns = [ columns = [
"Fiscal Year", "Employee:Link/Employee:150", "Employee Name::200", "Department::150" "Fiscal Year", "Employee:Link/Employee:150", "Employee Name::200", "Department::150"