Patch fixes
This commit is contained in:
parent
ef52e8ab64
commit
14ad9f70b5
@ -37,8 +37,7 @@ class TestLeaveEncashment(unittest.TestCase):
|
|||||||
|
|
||||||
# create the leave period and assign the leaves
|
# create the leave period and assign the leaves
|
||||||
leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3))
|
leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3))
|
||||||
leave_period.employee = employee
|
leave_period.grant_leave_allocation(employee=employee)
|
||||||
leave_period.grant_leave_allocation()
|
|
||||||
|
|
||||||
leave_encashment = frappe.get_doc(dict(
|
leave_encashment = frappe.get_doc(dict(
|
||||||
doctype = 'Leave Encashment',
|
doctype = 'Leave Encashment',
|
||||||
|
@ -40,14 +40,9 @@ class TestLeavePeriod(unittest.TestCase):
|
|||||||
leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3))
|
leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3))
|
||||||
|
|
||||||
# test leave_allocation
|
# test leave_allocation
|
||||||
leave_period.employee = employee_doc_name
|
leave_period.grant_leave_allocation(employee=employee_doc_name)
|
||||||
leave_period.grant_leave_allocation()
|
|
||||||
self.assertEqual(get_leave_balance_on(employee_doc_name, leave_type, today()), 20)
|
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):
|
def create_leave_period(from_date, to_date):
|
||||||
leave_period = frappe.get_doc({
|
leave_period = frappe.get_doc({
|
||||||
"doctype": "Leave Period",
|
"doctype": "Leave Period",
|
||||||
|
@ -30,7 +30,7 @@ def execute():
|
|||||||
comp_dict[company.name][department.name] = copy_doc.name
|
comp_dict[company.name][department.name] = copy_doc.name
|
||||||
|
|
||||||
rebuild_tree('Department', 'parent_department')
|
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:
|
for d in doctypes:
|
||||||
update_records(d, comp_dict)
|
update_records(d, comp_dict)
|
||||||
|
@ -21,11 +21,16 @@ def execute():
|
|||||||
where ss.name = sse.parent AND ss.is_active='Yes'
|
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)
|
AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1)
|
||||||
else:
|
else:
|
||||||
|
cols = ""
|
||||||
|
if "base" in frappe.db.get_table_columns("Salary Structure"):
|
||||||
|
cols = ", base, variable"
|
||||||
|
|
||||||
ss_details = frappe.db.sql("""
|
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`
|
from `tabSalary Structure`
|
||||||
where is_active='Yes'
|
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:
|
for d in ss_details:
|
||||||
try:
|
try:
|
||||||
@ -35,8 +40,8 @@ def execute():
|
|||||||
s.salary_structure = d.salary_structure
|
s.salary_structure = d.salary_structure
|
||||||
s.from_date = d.from_date
|
s.from_date = d.from_date
|
||||||
s.to_date = d.to_date if isinstance(d.to_date, datetime) else None
|
s.to_date = d.to_date if isinstance(d.to_date, datetime) else None
|
||||||
s.base = d.base
|
s.base = d.get("base")
|
||||||
s.variable = d.variable
|
s.variable = d.get("variable")
|
||||||
s.company = d.company
|
s.company = d.company
|
||||||
|
|
||||||
# to migrate the data of the old employees
|
# to migrate the data of the old employees
|
||||||
|
Loading…
x
Reference in New Issue
Block a user