Minor fixes

This commit is contained in:
Nabin Hait 2018-04-14 17:18:54 +05:30
parent 81706fdb46
commit 265426a5a6
3 changed files with 13 additions and 10 deletions

View File

@ -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()

View File

@ -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):

View File

@ -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