-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2203 from frappe/version-15-hotfix
chore: release v15
- Loading branch information
Showing
11 changed files
with
252 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 37 additions & 2 deletions
39
hrms/hr/doctype/leave_ledger_entry/test_leave_ledger_entry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,44 @@ | ||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
import frappe | ||
from frappe.tests.utils import FrappeTestCase | ||
from frappe.utils.data import add_to_date, today | ||
|
||
from erpnext.setup.doctype.employee.test_employee import make_employee | ||
|
||
from hrms.hr.doctype.leave_ledger_entry.leave_ledger_entry import expire_allocation | ||
|
||
|
||
class TestLeaveLedgerEntry(FrappeTestCase): | ||
pass | ||
def setUp(self): | ||
emp_id = make_employee("[email protected]", company="_Test Company") | ||
self.employee = frappe.get_doc("Employee", emp_id) | ||
|
||
def test_expire_allocation(self): | ||
import json | ||
|
||
allocation = { | ||
"doctype": "Leave Allocation", | ||
"__islocal": 1, | ||
"employee": self.employee.name, | ||
"employee_name": self.employee.employee_name, | ||
"leave_type": "_Test Leave Type", | ||
"from_date": today(), | ||
"to_date": add_to_date(today(), days=30), | ||
"new_leaves_allocated": 5, | ||
"docstatus": 1, | ||
} | ||
|
||
allocation = frappe.get_doc(allocation).save() | ||
|
||
expire_allocation(json.dumps(allocation.as_dict())) | ||
allocation.reload() | ||
|
||
self.assertEqual(allocation.expired, 1) | ||
|
||
def tearDown(self): | ||
frappe.db.rollback() | ||
|
||
|
||
test_dependencies = ["Employee", "Leave Type"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
make_holiday_list, | ||
make_leave_application, | ||
) | ||
from hrms.tests.test_utils import get_first_day_for_prev_month | ||
from hrms.tests.test_utils import create_company, get_first_day_for_prev_month | ||
|
||
|
||
class TestMonthlyAttendanceSheet(FrappeTestCase): | ||
|
@@ -41,6 +41,9 @@ def test_monthly_attendance_sheet_report(self): | |
mark_attendance(self.employee, previous_month_first + relativedelta(days=1), "Present") | ||
mark_attendance(self.employee, previous_month_first + relativedelta(days=2), "On Leave") | ||
|
||
employee_on_leave_with_shift = make_employee("[email protected]", company=self.company) | ||
mark_attendance(employee_on_leave_with_shift, previous_month_first, "On Leave", "Day Shift") | ||
|
||
filters = frappe._dict( | ||
{ | ||
"month": previous_month_first.month, | ||
|
@@ -50,14 +53,14 @@ def test_monthly_attendance_sheet_report(self): | |
) | ||
report = execute(filters=filters) | ||
|
||
record = report[1][0] | ||
datasets = report[3]["data"]["datasets"] | ||
absent = datasets[0]["values"] | ||
present = datasets[1]["values"] | ||
leaves = datasets[2]["values"] | ||
|
||
# ensure correct attendance is reflected on the report | ||
self.assertEqual(self.employee, record.get("employee")) | ||
self.assertEqual(self.employee, report[1][0].get("employee")) | ||
self.assertEqual("Day Shift", report[1][1].get("shift")) | ||
self.assertEqual(absent[0], 1) | ||
self.assertEqual(present[1], 1) | ||
self.assertEqual(leaves[2], 1) | ||
|
@@ -205,6 +208,11 @@ def test_attendance_with_group_by_filter(self): | |
mark_attendance(self.employee, previous_month_first + relativedelta(days=2), "On Leave") | ||
mark_attendance(self.employee, previous_month_first + relativedelta(days=3), "Present") | ||
|
||
departmentless_employee = make_employee( | ||
"[email protected]", company=self.company, department=None | ||
) | ||
mark_attendance(departmentless_employee, previous_month_first + relativedelta(days=3), "Present") | ||
|
||
filters = frappe._dict( | ||
{ | ||
"month": previous_month_first.month, | ||
|
@@ -276,6 +284,35 @@ def test_attendance_with_employee_filter(self): | |
self.assertEqual(present[1], 1) | ||
self.assertEqual(leaves[2], 1) | ||
|
||
def test_attendance_with_company_filter(self): | ||
create_company("Test Parent Company", is_group=1) | ||
create_company("Test Child Company", is_group=1, parent_company="Test Parent Company") | ||
create_company("Test Grandchild Company", parent_company="Test Child Company") | ||
|
||
employee1 = make_employee("[email protected]", company="Test Parent Company") | ||
employee2 = make_employee("[email protected]", company="Test Child Company") | ||
employee3 = make_employee("[email protected]", company="Test Grandchild Company") | ||
|
||
previous_month_first = get_first_day_for_prev_month() | ||
mark_attendance(employee1, previous_month_first, "Present") | ||
mark_attendance(employee2, previous_month_first, "Present") | ||
mark_attendance(employee3, previous_month_first, "Present") | ||
|
||
filters = frappe._dict( | ||
{ | ||
"month": previous_month_first.month, | ||
"year": previous_month_first.year, | ||
"company": "Test Parent Company", | ||
"include_company_descendants": 1, | ||
} | ||
) | ||
report = execute(filters=filters) | ||
self.assertEqual(len(report[1]), 3) | ||
|
||
filters.include_company_descendants = 0 | ||
report = execute(filters=filters) | ||
self.assertEqual(len(report[1]), 1) | ||
|
||
def test_attendance_with_employee_filter_and_summarized_view(self): | ||
previous_month_first = get_first_day_for_prev_month() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.