From 265426a5a6a8a190157413bae0b357b0aac4be43 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 14 Apr 2018 17:18:54 +0530 Subject: [PATCH] Minor fixes --- .../leave_application/test_leave_application.py | 7 +++++-- .../salary_structure_assignment.py | 12 ++++++------ .../v11_0/create_salary_structure_assignments.py | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index f220d7860b..424da90791 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -233,9 +233,9 @@ class TestLeaveApplication(unittest.TestCase): holiday_list = frappe.get_doc(dict( doctype = 'Holiday List', - name = 'test holiday list for optional holiday' + name = 'test holiday list for optional holiday', from_date = year_start_date(), - from_date = year_end_date() + to_date = year_end_date(), holidays = [ dict(holiday_date = today, description = 'test') ] @@ -276,12 +276,15 @@ class TestLeaveApplication(unittest.TestCase): def test_leaves_allowed(self): # TODO: test cannot allocate more than max leaves + pass def test_applicable_after(self): # TODO: test not applicable until applicable working days + pass def test_max_continuous_leaves(self): # TODO: test cannot take continuous leaves more than + pass def test_earned_leave(self): leave_period = get_leave_period() diff --git a/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py b/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py index e5188c3a29..c9269d7c92 100644 --- a/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py +++ b/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py @@ -12,24 +12,24 @@ class SalaryStructureAssignment(Document): def validate(self): self.validate_dates() - def validate_date(self): + def validate_dates(self): joining_date, relieving_date = frappe.db.get_value("Employee", self.employee, ["date_of_joining", "relieving_date"]) if self.from_date: if joining_date and getdate(self.from_date) < joining_date: - frappe.throw(_("From Date {0} cannot be before employee's joining Date {2}") + 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: - frappe.throw(_("From Date {0} cannot be after employee's relieving Date {2}") + frappe.throw(_("From Date {0} cannot be after employee's relieving Date {1}") .format(self.from_date, relieving_date)) if self.to_date: - if self.from_date and getdate(self.from_date) < getdate(self.to_date): - frappe.throw(_("From Date {0} cannot be before To Date {2}") + 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: - frappe.throw(_("To Date {0} cannot be after employee's relieving Date {2}") + frappe.throw(_("To Date {0} cannot be after employee's relieving Date {1}") .format(self.to_date, relieving_date)) def validate_duplicate_assignments(self): diff --git a/erpnext/patches/v11_0/create_salary_structure_assignments.py b/erpnext/patches/v11_0/create_salary_structure_assignments.py index e321db60a5..fc3a4315ee 100644 --- a/erpnext/patches/v11_0/create_salary_structure_assignments.py +++ b/erpnext/patches/v11_0/create_salary_structure_assignments.py @@ -7,9 +7,9 @@ import frappe def execute(): frappe.reload_doc("hr", "doctype", "salary_structure_assignment") for d in frappe.db.sql(""" - select * from `tabSalary Structure Employee` sse, `tabSalary Structure` ss + select sse.*, ss.company from `tabSalary Structure Employee` sse, `tabSalary Structure` ss where ss.name = sse.parent""", as_dict=1): - + print(d) s = frappe.new_doc("Salary Structure Assignment") s.employee = d.employee s.employee_name = d.employee_name