diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 5182c987a63e..e42295810d4c 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -321,9 +321,13 @@ def check_existing(self): def sum_components(self, component_type, total_field): joining_date, relieving_date = frappe.db.get_value("Employee", self.employee, ["date_of_joining", "relieving_date"]) + if not relieving_date: relieving_date = getdate(self.end_date) + if not joining_date: + frappe.throw(_("Please set the Date Of Joining for employee {0}").format(frappe.bold(employee.employee))) + for d in self.get(component_type): if ((cint(d.depends_on_lwp) == 1 and not self.salary_slip_based_on_timesheet) or\ getdate(self.start_date) < joining_date or getdate(self.end_date) > relieving_date): diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py index da69bccd5955..dc1c04d439de 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/salary_structure.py @@ -33,6 +33,7 @@ def validate_date(self): for employee in self.get('employees'): joining_date, relieving_date = frappe.db.get_value("Employee", employee.employee, ["date_of_joining", "relieving_date"]) + if employee.from_date and joining_date and getdate(employee.from_date) < joining_date: frappe.throw(_("From Date {0} for Employee {1} cannot be before employee's joining Date {2}") .format(employee.from_date, employee.employee, joining_date))