brotherton-erpnext/erpnext/hr/report/employee_birthday/employee_birthday.py

41 lines
1.3 KiB
Python
Raw Normal View History

2013-11-20 07:29:58 +00:00
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
2013-05-06 13:07:57 +00:00
from __future__ import unicode_literals
2014-02-14 10:17:51 +00:00
import frappe
2014-09-11 08:15:27 +00:00
from frappe import _
2014-02-14 10:17:51 +00:00
from frappe.utils import flt
2013-05-06 13:07:57 +00:00
def execute(filters=None):
if not filters: filters = {}
2014-07-02 12:05:00 +00:00
2013-05-06 13:07:57 +00:00
columns = get_columns()
data = get_employees(filters)
2014-07-02 12:05:00 +00:00
2013-05-06 13:07:57 +00:00
return columns, data
2014-07-02 12:05:00 +00:00
2013-05-06 13:07:57 +00:00
def get_columns():
return [
2014-09-11 08:15:27 +00:00
_("Employee") + ":Link/Employee:120", _("Name") + ":Data:200", _("Date of Birth")+ ":Date:100",
_("Branch") + ":Link/Branch:120", _("Department") + ":Link/Department:120",
_("Designation") + ":Link/Designation:120", _("Gender") + "::60", _("Company") + ":Link/Company:120"
2013-05-06 13:07:57 +00:00
]
2014-07-02 12:05:00 +00:00
2013-05-06 13:07:57 +00:00
def get_employees(filters):
conditions = get_conditions(filters)
return frappe.db.sql("""select name, employee_name, date_of_birth,
branch, department, designation,
2013-05-06 13:07:57 +00:00
gender, company from tabEmployee where status = 'Active' %s""" % conditions, as_list=1)
2014-07-02 12:05:00 +00:00
2013-05-06 13:07:57 +00:00
def get_conditions(filters):
conditions = ""
if filters.get("month"):
2014-07-02 12:05:00 +00:00
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
2013-05-06 13:07:57 +00:00
"Dec"].index(filters["month"]) + 1
conditions += " and month(date_of_birth) = '%s'" % month
2014-07-02 12:05:00 +00:00
2014-03-03 10:21:13 +00:00
if filters.get("company"): conditions += " and company = '%s'" % \
2014-07-02 12:05:00 +00:00
filters["company"].replace("'", "\\'")
return conditions