Add filters to show Draft salary slips in salary register (#14780)
* [fix] #14778 * replace if-elif block with inline block
This commit is contained in:
parent
1baa811a40
commit
e734b7c17b
@ -29,6 +29,13 @@ frappe.query_reports["Salary Register"] = {
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": frappe.defaults.get_user_default("Company")
|
"default": frappe.defaults.get_user_default("Company")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"docstatus",
|
||||||
|
"label":__("Document Status"),
|
||||||
|
"fieldtype":"Select",
|
||||||
|
"options":["Draft", "Submitted", "Cancelled"],
|
||||||
|
"default":"Submitted"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -74,13 +74,18 @@ def get_columns(salary_slips):
|
|||||||
def get_salary_slips(filters):
|
def get_salary_slips(filters):
|
||||||
filters.update({"from_date": filters.get("from_date"), "to_date":filters.get("to_date")})
|
filters.update({"from_date": filters.get("from_date"), "to_date":filters.get("to_date")})
|
||||||
conditions, filters = get_conditions(filters)
|
conditions, filters = get_conditions(filters)
|
||||||
salary_slips = frappe.db.sql("""select * from `tabSalary Slip` where docstatus = 1 %s
|
salary_slips = frappe.db.sql("""select * from `tabSalary Slip` where %s
|
||||||
order by employee""" % conditions, filters, as_dict=1)
|
order by employee""" % conditions, filters, as_dict=1)
|
||||||
|
|
||||||
return salary_slips or []
|
return salary_slips or []
|
||||||
|
|
||||||
def get_conditions(filters):
|
def get_conditions(filters):
|
||||||
conditions = ""
|
conditions = ""
|
||||||
|
doc_status = {"Draft": 0, "Submitted": 1, "Cancelled": 2}
|
||||||
|
|
||||||
|
if filters.get("docstatus"):
|
||||||
|
conditions += "docstatus = {0}".format(doc_status[filters.get("docstatus")])
|
||||||
|
|
||||||
if filters.get("from_date"): conditions += " and start_date >= %(from_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("to_date"): conditions += " and end_date <= %(to_date)s"
|
||||||
if filters.get("company"): conditions += " and company = %(company)s"
|
if filters.get("company"): conditions += " and company = %(company)s"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user