From a7d402132f05e69e8d7749b5b648d0c924fc5135 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Mon, 21 May 2018 18:38:18 +0530 Subject: [PATCH] salary structure patch run if active employee --- erpnext/patches/v11_0/create_salary_structure_assignments.py | 5 +++-- 1 file changed, 3 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 24874f604a..8648e15b25 100644 --- a/erpnext/patches/v11_0/create_salary_structure_assignments.py +++ b/erpnext/patches/v11_0/create_salary_structure_assignments.py @@ -3,18 +3,19 @@ from __future__ import unicode_literals import frappe +from datetime import datetime def execute(): frappe.reload_doc("hr", "doctype", "salary_structure_assignment") for d in frappe.db.sql(""" select sse.*, ss.company from `tabSalary Structure Employee` sse, `tabSalary Structure` ss - where ss.name = sse.parent""", as_dict=1): + where ss.name = sse.parent AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1): 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 + 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