parent
6a2d073fe1
commit
35397a1033
@ -4,10 +4,17 @@
|
||||
frappe.query_reports["Salary Register"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"date_range",
|
||||
"label": __("Date Range"),
|
||||
"fieldtype": "DateRange",
|
||||
"default": [frappe.datetime.add_months(frappe.datetime.get_today(),-1), frappe.datetime.get_today()],
|
||||
"fieldname":"from_date",
|
||||
"label": __("From"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.add_months(frappe.datetime.get_today(),-1),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"to_date",
|
||||
"label": __("To"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.get_today(),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
|
@ -9,6 +9,8 @@ from frappe import _
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
salary_slips = get_salary_slips(filters)
|
||||
if not salary_slips: return [], []
|
||||
|
||||
columns, earning_types, ded_types = get_columns(salary_slips)
|
||||
ss_earning_map = get_ss_earning_map(salary_slips)
|
||||
ss_ded_map = get_ss_ded_map(salary_slips)
|
||||
@ -70,20 +72,17 @@ def get_columns(salary_slips):
|
||||
return columns, salary_components[_("Earning")], salary_components[_("Deduction")]
|
||||
|
||||
def get_salary_slips(filters):
|
||||
filters.update({"from_date": filters.get("date_range")[0], "to_date":filters.get("date_range")[1]})
|
||||
filters.update({"from_date": filters.get("from_date"), "to_date":filters.get("to_date")})
|
||||
conditions, filters = get_conditions(filters)
|
||||
salary_slips = frappe.db.sql("""select * from `tabSalary Slip` where docstatus = 1 %s
|
||||
order by employee""" % conditions, filters, as_dict=1)
|
||||
|
||||
if not salary_slips:
|
||||
frappe.throw(_("No salary slip found between {0} and {1}").format(
|
||||
filters.get("from_date"), filters.get("to_date")))
|
||||
return salary_slips
|
||||
return salary_slips or []
|
||||
|
||||
def get_conditions(filters):
|
||||
conditions = ""
|
||||
if filters.get("date_range"): conditions += " and start_date >= %(from_date)s"
|
||||
if filters.get("date_range"): conditions += " and end_date <= %(to_date)s"
|
||||
if filters.get("from_date"): conditions += " and start_date >= %(from_date)s"
|
||||
if filters.get("to_date"): conditions += " and end_date <= %(to_date)s"
|
||||
if filters.get("company"): conditions += " and company = %(company)s"
|
||||
if filters.get("employee"): conditions += " and employee = %(employee)s"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user