From e1c75a9d55eee6d7554084d924ebfb9e52d3c891 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Feb 2019 12:25:40 +0530 Subject: [PATCH] fix: fixed salary structure assignment patch (#16546) * fix: fixed salary structure assignment patch * fix: patch --- .../v11_0/create_salary_structure_assignments.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v11_0/create_salary_structure_assignments.py b/erpnext/patches/v11_0/create_salary_structure_assignments.py index 2dab1940d8..610fa85172 100644 --- a/erpnext/patches/v11_0/create_salary_structure_assignments.py +++ b/erpnext/patches/v11_0/create_salary_structure_assignments.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe from datetime import datetime +from frappe.utils import getdate from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import DuplicateAssignment def execute(): @@ -31,14 +32,22 @@ def execute(): where is_active='Yes' AND employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left') """.format(cols), as_dict=1) - + for d in ss_details: try: + joining_date, relieving_date = frappe.db.get_value("Employee", d.employee, + ["date_of_joining", "relieving_date"]) + from_date = d.from_date + if joining_date and getdate(from_date) < joining_date: + from_date = joining_date + elif relieving_date and getdate(from_date) > relieving_date: + continue + s = frappe.new_doc("Salary Structure Assignment") s.employee = d.employee s.employee_name = d.employee_name s.salary_structure = d.salary_structure - s.from_date = d.from_date + s.from_date = from_date s.to_date = d.to_date if isinstance(d.to_date, datetime) else None s.base = d.get("base") s.variable = d.get("variable")