2019-01-22 12:52:20 +00:00
|
|
|
from __future__ import unicode_literals
|
2017-01-13 05:45:53 +00:00
|
|
|
import frappe
|
2017-12-01 05:12:12 +00:00
|
|
|
from erpnext.hr.doctype.payroll_entry.payroll_entry import get_month_details
|
2017-01-19 07:18:03 +00:00
|
|
|
from frappe.utils import cint
|
2017-01-13 05:45:53 +00:00
|
|
|
|
|
|
|
def execute():
|
2017-01-13 13:23:11 +00:00
|
|
|
frappe.reload_doctype('Salary Slip')
|
|
|
|
if not frappe.db.has_column('Salary Slip', 'fiscal_year'):
|
2017-01-13 11:59:39 +00:00
|
|
|
return
|
2017-01-13 13:23:11 +00:00
|
|
|
|
2017-01-19 07:14:40 +00:00
|
|
|
salary_slips = frappe.db.sql("""select month, name, fiscal_year from `tabSalary Slip`
|
2017-01-13 13:23:11 +00:00
|
|
|
where (month is not null and month != '') and
|
2018-01-31 10:00:03 +00:00
|
|
|
start_date is null and end_date is null and docstatus != 2""", as_dict=True)
|
2017-01-13 05:45:53 +00:00
|
|
|
|
|
|
|
for salary_slip in salary_slips:
|
2017-01-19 07:21:37 +00:00
|
|
|
if not cint(salary_slip.month):
|
|
|
|
continue
|
|
|
|
get_start_end_date = get_month_details(salary_slip.fiscal_year, cint(salary_slip.month))
|
2017-01-13 05:45:53 +00:00
|
|
|
start_date = get_start_end_date['month_start_date']
|
|
|
|
end_date = get_start_end_date['month_end_date']
|
|
|
|
frappe.db.sql("""update `tabSalary Slip` set start_date = %s, end_date = %s where name = %s""",
|
|
|
|
(start_date, end_date, salary_slip.name))
|