From 8df5900f98029ad9c0a71b076d67047d29b1ef2f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 2 Dec 2015 14:50:08 +0530 Subject: [PATCH] [fix] Inactive salary structure validation --- erpnext/hr/doctype/salary_slip/salary_slip.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 88d1402c9e0..ea7c96e499c 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -29,10 +29,15 @@ class SalarySlip(TransactionBase): def check_sal_struct(self): m = get_month_details(self.fiscal_year, self.month) + + joining_date, relieving_date = frappe.db.get_value("Employee", self.employee, + ["date_of_joining", "relieving_date"]) + struct = frappe.db.sql("""select name from `tabSalary Structure` where employee=%s and is_active = 'Yes' - and from_date <= %s and (to_date is null or to_date >= %s)""", - (self.employee, m.month_start_date, m.month_end_date)) + and (from_date <= %s or from_date <= %s) + and (to_date is null or to_date >= %s or to_date >= %s)""", + (self.employee, m.month_start_date, joining_date, m.month_end_date, relieving_date)) if not struct: msgprint(_("No active Salary Structure found for employee {0} and the month")