diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js index 3eb2fa2802..3265f88f82 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.js +++ b/erpnext/hr/doctype/process_payroll/process_payroll.js @@ -3,7 +3,7 @@ frappe.ui.form.on("Process Payroll", { onload: function(frm) { - frm.doc.posting_date = frappe.datetime.nowdate() + frm.doc.posting_date = frm.doc.start_date = frm.doc.end_date = frappe.datetime.nowdate() }, refresh: function(frm) { diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.json b/erpnext/hr/doctype/process_payroll/process_payroll.json index 08dc14c781..8e0d39577a 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.json +++ b/erpnext/hr/doctype/process_payroll/process_payroll.json @@ -98,7 +98,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "", + "default": "Today", "fieldname": "posting_date", "fieldtype": "Date", "hidden": 0, @@ -352,7 +352,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "", + "default": "Today", "fieldname": "start_date", "fieldtype": "Date", "hidden": 0, @@ -408,7 +408,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "", + "default": "Today", "fieldname": "end_date", "fieldtype": "Date", "hidden": 0, @@ -722,7 +722,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2016-12-14 12:58:16.206040", + "modified": "2016-11-26 01:14:51.691057", "modified_by": "Administrator", "module": "HR", "name": "Process Payroll", diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py index cbed9c3999..97e3876e02 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.py +++ b/erpnext/hr/doctype/process_payroll/process_payroll.py @@ -5,6 +5,9 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint, flt, nowdate, add_days, getdate from frappe import _ +import collections +from collections import defaultdict +from calendar import monthrange from erpnext.accounts.utils import get_fiscal_year from frappe.model.document import Document @@ -27,9 +30,8 @@ class ProcessPayroll(Document): sal_struct = frappe.db.sql(""" select name from `tabSalary Structure` where docstatus != 2 and is_active = 'Yes' and company = %(company)s and - from_date <= %(start_date)s and (to_date is null or to_date >= %(end_date)s) and - ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s {struct_cond}""".format(struct_cond=struct_cond), - {"company": self.company, "start_date": self.start_date, "end_date": self.end_date, "salary_slip_based_on_timesheet":self.salary_slip_based_on_timesheet}) + ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s""", + {"company": self.company, "salary_slip_based_on_timesheet":self.salary_slip_based_on_timesheet}) if sal_struct: cond += "and t2.parent IN %(sal_struct)s " @@ -312,9 +314,7 @@ def get_month_details(year, month): frappe.throw(_("Fiscal Year {0} not found").format(year)) @frappe.whitelist() -def get_start_end_dates(payroll_frequency = None, start_date = None, end_date = None): - if payroll_frequency and not start_date: - start_date = nowdate() +def get_start_end_dates(payroll_frequency, start_date, end_date): if payroll_frequency == "Monthly" or payroll_frequency == "Bimonthly": fiscal_year = get_fiscal_year(start_date)[0] or get_fiscal_year(end_date)[0] month = "%02d" % getdate(start_date).month or "%02d" % getdate(end_date).month diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json index 24651d16ea..062f41f8f3 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.json +++ b/erpnext/hr/doctype/salary_slip/salary_slip.json @@ -408,7 +408,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, @@ -421,7 +421,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "", + "default": "Today", "fieldname": "start_date", "fieldtype": "Date", "hidden": 0, @@ -450,7 +450,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "", + "default": "Today", "depends_on": "", "fieldname": "end_date", "fieldtype": "Date", @@ -1361,7 +1361,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-12-14 12:48:44.038588", + "modified": "2016-12-08 12:03:31.602913", "modified_by": "Administrator", "module": "HR", "name": "Salary Slip",