[Fix] Monthly Salary Register Fix
This commit is contained in:
parent
ae25e0da88
commit
7b29dc7208
@ -4,19 +4,18 @@
|
|||||||
frappe.query_reports["Monthly Salary Register"] = {
|
frappe.query_reports["Monthly Salary Register"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"month",
|
"fieldname":"from_date",
|
||||||
"label": __("Month"),
|
"label": __("From"),
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Date",
|
||||||
"options": "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec",
|
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
||||||
"default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
"reqd": 1
|
||||||
"Dec"][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"fiscal_year",
|
"fieldname":"to_date",
|
||||||
"label": __("Fiscal Year"),
|
"label": __("To"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Date",
|
||||||
"options": "Fiscal Year",
|
"default": frappe.datetime.get_today(),
|
||||||
"default": sys_defaults.fiscal_year,
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"employee",
|
"fieldname":"employee",
|
||||||
|
@ -18,7 +18,7 @@ def execute(filters=None):
|
|||||||
data = []
|
data = []
|
||||||
for ss in salary_slips:
|
for ss in salary_slips:
|
||||||
row = [ss.name, ss.employee, ss.employee_name, ss.branch, ss.department, ss.designation,
|
row = [ss.name, ss.employee, ss.employee_name, ss.branch, ss.department, ss.designation,
|
||||||
ss.company, ss.month, ss.leave_withut_pay, ss.payment_days]
|
ss.company, ss.start_date, ss.end_date, ss.leave_withut_pay, ss.payment_days]
|
||||||
|
|
||||||
for e in earning_types:
|
for e in earning_types:
|
||||||
row.append(ss_earning_map.get(ss.name, {}).get(e))
|
row.append(ss_earning_map.get(ss.name, {}).get(e))
|
||||||
@ -38,7 +38,7 @@ def get_columns(salary_slips):
|
|||||||
columns = [
|
columns = [
|
||||||
_("Salary Slip ID") + ":Link/Salary Slip:150",_("Employee") + ":Link/Employee:120", _("Employee Name") + "::140", _("Branch") + ":Link/Branch:120",
|
_("Salary Slip ID") + ":Link/Salary Slip:150",_("Employee") + ":Link/Employee:120", _("Employee Name") + "::140", _("Branch") + ":Link/Branch:120",
|
||||||
_("Department") + ":Link/Department:120", _("Designation") + ":Link/Designation:120",
|
_("Department") + ":Link/Department:120", _("Designation") + ":Link/Designation:120",
|
||||||
_("Company") + ":Link/Company:120", _("Month") + "::80", _("Leave Without Pay") + ":Float:130",
|
_("Company") + ":Link/Company:120", _("Start Date") + "::80", _("End Date") + "::80", _("Leave Without Pay") + ":Float:130",
|
||||||
_("Payment Days") + ":Float:120"
|
_("Payment Days") + ":Float:120"
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -60,23 +60,18 @@ def get_columns(salary_slips):
|
|||||||
def get_salary_slips(filters):
|
def get_salary_slips(filters):
|
||||||
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 docstatus = 1 %s
|
||||||
order by employee, month""" % conditions, filters, as_dict=1)
|
order by employee""" % conditions, filters, as_dict=1)
|
||||||
|
|
||||||
if not salary_slips:
|
if not salary_slips:
|
||||||
frappe.throw(_("No salary slip found for month {0} and year {1}").format(
|
frappe.throw(_("No salary slip found between {0} and {1}").format(
|
||||||
filters.get("month"), filters.get("fiscal_year")))
|
filters.get("from_date"), filters.get("to_date")))
|
||||||
|
|
||||||
return salary_slips
|
return salary_slips
|
||||||
|
|
||||||
def get_conditions(filters):
|
def get_conditions(filters):
|
||||||
conditions = ""
|
conditions = ""
|
||||||
if filters.get("month"):
|
if filters.get("from_date"): conditions += " and start_date >= %(from_date)s"
|
||||||
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
if filters.get("to_date"): conditions += " and end_date <= %(to_date)s"
|
||||||
"Dec"].index(filters["month"]) + 1
|
|
||||||
filters["month"] = month
|
|
||||||
conditions += " and month = %(month)s"
|
|
||||||
|
|
||||||
if filters.get("fiscal_year"): conditions += " and fiscal_year = %(fiscal_year)s"
|
|
||||||
if filters.get("company"): conditions += " and company = %(company)s"
|
if filters.get("company"): conditions += " and company = %(company)s"
|
||||||
if filters.get("employee"): conditions += " and employee = %(employee)s"
|
if filters.get("employee"): conditions += " and employee = %(employee)s"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user