Skip to content

Commit

Permalink
[minor] check if date of joining is available before creating Salary …
Browse files Browse the repository at this point in the history
…Slip (#8700)
  • Loading branch information
mbauskar authored and nabinhait committed May 6, 2017
1 parent 3257aee commit 486045e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions erpnext/hr/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions erpnext/hr/doctype/salary_structure/salary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 486045e

Please sign in to comment.