mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
refactor(tests): create_leave_type usage
This commit is contained in:
@@ -702,7 +702,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
).insert()
|
)
|
||||||
|
|
||||||
create_carry_forwarded_allocation(employee, leave_type)
|
create_carry_forwarded_allocation(employee, leave_type)
|
||||||
details = get_leave_balance_on(
|
details = get_leave_balance_on(
|
||||||
@@ -774,7 +774,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
|
|
||||||
leave_type = create_leave_type(leave_type_name="Test Leave Type 1")
|
leave_type = create_leave_type(leave_type_name="Test Leave Type 1")
|
||||||
leave_type.save()
|
|
||||||
|
|
||||||
leave_allocation = create_leave_allocation(
|
leave_allocation = create_leave_allocation(
|
||||||
employee=employee.name, employee_name=employee.employee_name, leave_type=leave_type.name
|
employee=employee.name, employee_name=employee.employee_name, leave_type=leave_type.name
|
||||||
@@ -817,7 +816,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
include_holiday=True,
|
include_holiday=True,
|
||||||
)
|
)
|
||||||
leave_type.submit()
|
|
||||||
|
|
||||||
create_carry_forwarded_allocation(employee, leave_type)
|
create_carry_forwarded_allocation(employee, leave_type)
|
||||||
|
|
||||||
@@ -856,7 +854,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
)
|
)
|
||||||
leave_type.submit()
|
|
||||||
|
|
||||||
create_carry_forwarded_allocation(employee, leave_type)
|
create_carry_forwarded_allocation(employee, leave_type)
|
||||||
|
|
||||||
@@ -1005,7 +1002,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
).insert()
|
)
|
||||||
|
|
||||||
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
||||||
cf_expiry = frappe.db.get_value(
|
cf_expiry = frappe.db.get_value(
|
||||||
@@ -1038,7 +1035,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
).insert()
|
)
|
||||||
|
|
||||||
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
||||||
cf_expiry = frappe.db.get_value(
|
cf_expiry = frappe.db.get_value(
|
||||||
@@ -1072,7 +1069,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
).insert()
|
)
|
||||||
|
|
||||||
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
||||||
cf_expiry = frappe.db.get_value(
|
cf_expiry = frappe.db.get_value(
|
||||||
@@ -1114,7 +1111,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
).insert()
|
)
|
||||||
|
|
||||||
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
||||||
cf_expiry = frappe.db.get_value(
|
cf_expiry = frappe.db.get_value(
|
||||||
@@ -1148,7 +1145,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
leave_type_name="_Test_CF_leave_expiry",
|
leave_type_name="_Test_CF_leave_expiry",
|
||||||
is_carry_forward=1,
|
is_carry_forward=1,
|
||||||
expire_carry_forwarded_leaves_after_days=90,
|
expire_carry_forwarded_leaves_after_days=90,
|
||||||
).insert()
|
)
|
||||||
|
|
||||||
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
leave_alloc = create_carry_forwarded_allocation(employee, leave_type)
|
||||||
cf_expiry = frappe.db.get_value(
|
cf_expiry = frappe.db.get_value(
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ test_records = frappe.get_test_records("Leave Type")
|
|||||||
def create_leave_type(**args):
|
def create_leave_type(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
if frappe.db.exists("Leave Type", args.leave_type_name):
|
if frappe.db.exists("Leave Type", args.leave_type_name):
|
||||||
return frappe.get_doc("Leave Type", args.leave_type_name)
|
frappe.delete_doc("Leave Type", args.leave_type_name)
|
||||||
|
|
||||||
leave_type = frappe.get_doc(
|
leave_type = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Leave Type",
|
"doctype": "Leave Type",
|
||||||
@@ -23,10 +24,14 @@ def create_leave_type(**args):
|
|||||||
"expire_carry_forwarded_leaves_after_days": args.expire_carry_forwarded_leaves_after_days or 0,
|
"expire_carry_forwarded_leaves_after_days": args.expire_carry_forwarded_leaves_after_days or 0,
|
||||||
"encashment_threshold_days": args.encashment_threshold_days or 5,
|
"encashment_threshold_days": args.encashment_threshold_days or 5,
|
||||||
"earning_component": "Leave Encashment",
|
"earning_component": "Leave Encashment",
|
||||||
|
"max_leaves_allowed": args.max_leaves_allowed,
|
||||||
|
"maximum_carry_forwarded_leaves": args.maximum_carry_forwarded_leaves,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if leave_type.is_ppl:
|
if leave_type.is_ppl:
|
||||||
leave_type.fraction_of_daily_salary_per_leave = args.fraction_of_daily_salary_per_leave or 0.5
|
leave_type.fraction_of_daily_salary_per_leave = args.fraction_of_daily_salary_per_leave or 0.5
|
||||||
|
|
||||||
|
leave_type.insert()
|
||||||
|
|
||||||
return leave_type
|
return leave_type
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ class TestEmployeeLeaveBalance(unittest.TestCase):
|
|||||||
@set_holiday_list("_Test Emp Balance Holiday List", "_Test Company")
|
@set_holiday_list("_Test Emp Balance Holiday List", "_Test Company")
|
||||||
def test_opening_balance_considers_carry_forwarded_leaves(self):
|
def test_opening_balance_considers_carry_forwarded_leaves(self):
|
||||||
leave_type = create_leave_type(leave_type_name="_Test_CF_leave_expiry", is_carry_forward=1)
|
leave_type = create_leave_type(leave_type_name="_Test_CF_leave_expiry", is_carry_forward=1)
|
||||||
leave_type.insert()
|
|
||||||
|
|
||||||
# 30 leaves allocated for first half of the year
|
# 30 leaves allocated for first half of the year
|
||||||
allocation1 = make_allocation_record(
|
allocation1 = make_allocation_record(
|
||||||
|
|||||||
@@ -267,7 +267,6 @@ class TestSalarySlip(FrappeTestCase):
|
|||||||
make_leave_application(emp_id, first_sunday, add_days(first_sunday, 3), "Leave Without Pay")
|
make_leave_application(emp_id, first_sunday, add_days(first_sunday, 3), "Leave Without Pay")
|
||||||
|
|
||||||
leave_type_ppl = create_leave_type(leave_type_name="Test Partially Paid Leave", is_ppl=1)
|
leave_type_ppl = create_leave_type(leave_type_name="Test Partially Paid Leave", is_ppl=1)
|
||||||
leave_type_ppl.save()
|
|
||||||
|
|
||||||
alloc = create_leave_allocation(
|
alloc = create_leave_allocation(
|
||||||
employee=emp_id,
|
employee=emp_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user