From abe9d7be0b34ffc0683463c4a1288be644d0ed57 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 5 Dec 2012 14:36:39 +0530 Subject: [PATCH] fixes in employee leave balance report --- hr/doctype/leave_control_panel/leave_control_panel.py | 2 +- .../employee_leave_balance_report.py | 5 +++-- .../employee_leave_balance_report.sql | 11 +++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hr/doctype/leave_control_panel/leave_control_panel.py b/hr/doctype/leave_control_panel/leave_control_panel.py index a2d4fee47a..c81575c1d9 100644 --- a/hr/doctype/leave_control_panel/leave_control_panel.py +++ b/hr/doctype/leave_control_panel/leave_control_panel.py @@ -49,7 +49,7 @@ class DocType: emp_query = "select name from `tabEmployee` " if flag == 1: emp_query += condition - e = sql(emp_query) + e = sql(emp_query, debug=1) return e # ---------------- diff --git a/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.py b/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.py index cb822100d1..5b8ed08a15 100644 --- a/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.py +++ b/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.py @@ -15,6 +15,7 @@ # along with this program. If not, see . from __future__ import unicode_literals + leave_types = sql(""" SELECT name FROM `tabLeave Type` WHERE @@ -57,7 +58,7 @@ try: if d[3] in colnames: # If exists, then append the leave type data if exists: - res[ind][colnames.index(d[3])] = d[4] - d[5] + res[ind][colnames.index(d[3])] = flt(d[4]) - flt(d[5]) res[ind][len(colnames)-1] = sum(res[ind][3:-1]) # Else create a new row in res else: @@ -65,7 +66,7 @@ try: new_row[0] = d[0] new_row[1] = d[1] new_row[2] = d[2] - new_row[colnames.index(d[3])] = d[4] - d[5] + new_row[colnames.index(d[3])] = flt(d[4]) - flt(d[5]) new_row[len(colnames)-1] = sum(new_row[3:-1]) res.append(new_row) except Exception, e: diff --git a/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.sql b/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.sql index 50811c0aa2..454772aa27 100644 --- a/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.sql +++ b/hr/search_criteria/employee_leave_balance_report/employee_leave_balance_report.sql @@ -6,14 +6,13 @@ SELECT leave_alloc.total_leaves_allocated AS 'total_leaves_allocated', SUM(leave_app.total_leave_days) AS 'total_leaves_applied' FROM - `tabLeave Allocation` AS leave_alloc, - `tabLeave Application` AS leave_app -WHERE - leave_alloc.employee=leave_app.employee AND + `tabLeave Allocation` AS leave_alloc LEFT JOIN `tabLeave Application` AS leave_app + ON leave_alloc.employee=leave_app.employee AND leave_alloc.leave_type=leave_app.leave_type AND leave_alloc.fiscal_year=leave_app.fiscal_year AND - leave_alloc.docstatus=1 AND - leave_app.docstatus=1 AND + leave_app.docstatus=1 +WHERE + leave_alloc.docstatus=1 AND leave_alloc.fiscal_year LIKE '%(fiscal_year)s%%' AND leave_alloc.employee_name LIKE '%(employee_name)s%%' GROUP BY