Merge pull request #14134 from manassolanki/fix-salary-patch

[fix] patch for the salary structure assignment for old employees
This commit is contained in:
Manas Solanki 2018-05-18 15:47:14 +05:30 committed by GitHub
commit d976c04b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -21,7 +21,9 @@ class SalaryStructureAssignment(Document):
if joining_date and getdate(self.from_date) < joining_date:
frappe.throw(_("From Date {0} cannot be before employee's joining Date {1}")
.format(self.from_date, joining_date))
if relieving_date and getdate(self.from_date) > relieving_date:
# flag - old_employee is for migrating the old employees data via patch
if relieving_date and getdate(self.from_date) > relieving_date and not self.flags.old_employee:
frappe.throw(_("From Date {0} cannot be after employee's relieving Date {1}")
.format(self.from_date, relieving_date))
@ -29,7 +31,7 @@ class SalaryStructureAssignment(Document):
if self.from_date and getdate(self.from_date) > getdate(self.to_date):
frappe.throw(_("From Date {0} cannot be after To Date {1}")
.format(self.from_date, self.to_date))
if relieving_date and getdate(self.to_date) > relieving_date:
if relieving_date and getdate(self.to_date) > relieving_date and not self.flags.old_employee:
frappe.throw(_("To Date {0} cannot be after employee's relieving Date {1}")
.format(self.to_date, relieving_date))

View File

@ -18,6 +18,9 @@ def execute():
s.base = d.base
s.variable = d.variable
s.company = d.company
# to migrate the data of the old employees
s.flags.old_employee = True
s.save()
frappe.db.sql("update `tabSalary Structure` set docstatus=1")