2018-04-14 17:04:56 +05:30
|
|
|
# Copyright (c) 2017, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
2018-05-21 18:38:18 +05:30
|
|
|
from datetime import datetime
|
2018-05-21 18:52:07 +05:30
|
|
|
from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import DuplicateAssignment
|
2018-04-14 17:04:56 +05:30
|
|
|
|
|
|
|
def execute():
|
|
|
|
frappe.reload_doc("hr", "doctype", "salary_structure_assignment")
|
|
|
|
for d in frappe.db.sql("""
|
2018-04-14 17:18:54 +05:30
|
|
|
select sse.*, ss.company from `tabSalary Structure Employee` sse, `tabSalary Structure` ss
|
2018-05-21 18:38:18 +05:30
|
|
|
where ss.name = sse.parent AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1):
|
2018-05-21 18:52:07 +05:30
|
|
|
try:
|
|
|
|
s = frappe.new_doc("Salary Structure Assignment")
|
|
|
|
s.employee = d.employee
|
|
|
|
s.employee_name = d.employee_name
|
|
|
|
s.salary_structure = d.parent
|
|
|
|
s.from_date = d.from_date
|
|
|
|
s.to_date = d.to_date if isinstance(d.to_date, datetime) else None
|
|
|
|
s.base = d.base
|
|
|
|
s.variable = d.variable
|
|
|
|
s.company = d.company
|
2018-05-18 15:46:35 +05:30
|
|
|
|
2018-05-21 18:52:07 +05:30
|
|
|
# to migrate the data of the old employees
|
|
|
|
s.flags.old_employee = True
|
|
|
|
s.save()
|
|
|
|
except DuplicateAssignment:
|
|
|
|
pass
|
2018-04-14 17:04:56 +05:30
|
|
|
|
|
|
|
frappe.db.sql("update `tabSalary Structure` set docstatus=1")
|