Patch fixes

This commit is contained in:
Nabin Hait 2018-07-31 17:33:03 +05:30
parent ef52e8ab64
commit 14ad9f70b5
4 changed files with 12 additions and 13 deletions

View File

@ -37,8 +37,7 @@ class TestLeaveEncashment(unittest.TestCase):
# create the leave period and assign the leaves
leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3))
leave_period.employee = employee
leave_period.grant_leave_allocation()
leave_period.grant_leave_allocation(employee=employee)
leave_encashment = frappe.get_doc(dict(
doctype = 'Leave Encashment',

View File

@ -40,14 +40,9 @@ class TestLeavePeriod(unittest.TestCase):
leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3))
# test leave_allocation
leave_period.employee = employee_doc_name
leave_period.grant_leave_allocation()
leave_period.grant_leave_allocation(employee=employee_doc_name)
self.assertEqual(get_leave_balance_on(employee_doc_name, leave_type, today()), 20)
# leave_period.grant_leave_alloc(employee_doc_name)
self.assertRaises(frappe.ValidationError, leave_period.grant_leave_allocation)
def create_leave_period(from_date, to_date):
leave_period = frappe.get_doc({
"doctype": "Leave Period",

View File

@ -30,7 +30,7 @@ def execute():
comp_dict[company.name][department.name] = copy_doc.name
rebuild_tree('Department', 'parent_department')
doctypes = ["Asset", "Employee", "Leave Period", "Payroll Entry", "Staffing Plan", "Job Opening"]
doctypes = ["Asset", "Employee", "Payroll Entry", "Staffing Plan", "Job Opening"]
for d in doctypes:
update_records(d, comp_dict)

View File

@ -21,11 +21,16 @@ def execute():
where ss.name = sse.parent AND ss.is_active='Yes'
AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1)
else:
cols = ""
if "base" in frappe.db.get_table_columns("Salary Structure"):
cols = ", base, variable"
ss_details = frappe.db.sql("""
select name as salary_structure, employee, employee_name, from_date, to_date, base, variable, company
select name as salary_structure, employee, employee_name, from_date, to_date, company {0}
from `tabSalary Structure`
where is_active='Yes'
AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1)
AND employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')
""".format(cols), as_dict=1)
for d in ss_details:
try:
@ -35,8 +40,8 @@ def execute():
s.salary_structure = d.salary_structure
s.from_date = d.from_date
s.to_date = d.to_date if isinstance(d.to_date, datetime) else None
s.base = d.base
s.variable = d.variable
s.base = d.get("base")
s.variable = d.get("variable")
s.company = d.company
# to migrate the data of the old employees