Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: base Roster Management (backport #1760) #2136

Merged
merged 136 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
c183cf6
feat: init roster app
krantheman Apr 26, 2024
599a582
fix: update server proxy, routing, package.json scripts, .gitignore, …
krantheman Apr 26, 2024
63f27ea
chore: enable typescript
krantheman Apr 29, 2024
8da3f03
feat: add month view header
krantheman Apr 30, 2024
761645c
chore: format index.html
krantheman Apr 30, 2024
9d74e3c
feat: add month table header
krantheman Apr 30, 2024
a8026b1
chore: update tsconfig.json
krantheman May 2, 2024
24894da
feat: get context
krantheman May 2, 2024
d33f271
feat: fetch shifts
krantheman May 2, 2024
22978ff
feat: display shifts on calendar
krantheman May 3, 2024
a845306
fix: table border
krantheman May 3, 2024
6e82292
feat: add employee pics and fix spacing and font sizes
krantheman May 6, 2024
5eaeb02
feat: add shift timings
krantheman May 6, 2024
3a578d0
feat: add shift assignment dialog
krantheman May 7, 2024
770137a
refactor: use createListresource and createDocumentResource
krantheman May 7, 2024
7d39170
feat: add update shift assignment values
krantheman May 7, 2024
fdcd5ff
feat: add plus button to create shift assignments
krantheman May 7, 2024
5d5f21f
refactor: move ShiftAssignmentDialog to a new component
krantheman May 7, 2024
6c73b6e
feat: fetch company and department from employee
krantheman May 8, 2024
e290920
feat: select date from selected cell
krantheman May 8, 2024
676310f
feat: add shift assignment creation
krantheman May 8, 2024
6a7e500
fix: submit shift assignment on insert
krantheman May 8, 2024
9f3fd60
fix: firstOfMonth time
krantheman May 8, 2024
7e2f071
fix: fetch employee data only when dialog opens
krantheman May 9, 2024
76ae5a8
feat: add shift assignment deletion
krantheman May 9, 2024
f077331
feat: make employee column sticky
krantheman May 10, 2024
095b4cd
fix: spacing
krantheman May 10, 2024
242892e
fix: cell height fluctuation
krantheman May 10, 2024
51a1f02
fix: dialog buttons
krantheman May 10, 2024
f5102fe
chore: add typings
krantheman May 13, 2024
3a2dfdb
feat: add holidays
krantheman May 13, 2024
33c20d7
feat: add employee search
krantheman May 14, 2024
fb0cf0f
feat: add makeshift navbar
krantheman May 14, 2024
f4b9daa
feat: add FilterBar
krantheman May 14, 2024
d917ae7
chore: remove redundant code
krantheman May 14, 2024
de409a6
chore: improve readability
krantheman May 14, 2024
7bfdf61
feat: add filters
krantheman May 15, 2024
fb19283
chore: improve readability
krantheman May 15, 2024
49dbd64
refactor: move filters to month select header
krantheman May 16, 2024
6bae972
feat: add button to toggle showing of filters
krantheman May 16, 2024
2ec3c76
feat: add transition for filter button
krantheman May 16, 2024
03c92ba
feat: add clear filters button
krantheman May 16, 2024
a16440d
feat: add colors for shift types
krantheman May 17, 2024
ce20168
fix: font weights
krantheman May 17, 2024
8d43d2a
refactor: holiday cell
krantheman May 21, 2024
a541f57
fix: leave filter bar open by default
krantheman May 23, 2024
73a499d
fix: spacing
krantheman May 23, 2024
ac0ce16
feat: add designation filter
krantheman May 23, 2024
010f1e7
feat: add multiple selections for employee search
krantheman May 23, 2024
15ca987
fix(ShiftAssignmentDialog): use FormControl instead of Autocomplete
krantheman May 23, 2024
2a21714
fix: spacing
krantheman May 23, 2024
adc3b5e
feat: get_leaves api
krantheman May 24, 2024
8039ff6
feat: add leaves to roster
krantheman May 24, 2024
33b7261
fix(Filters): use FormControl instead of Autocomplete
krantheman May 24, 2024
13d6144
feat: add Select Working Days ui
krantheman May 27, 2024
ebed38f
feat: select default working day based on start date
krantheman May 27, 2024
3943e6b
fix: setting of default day if no start date
krantheman May 27, 2024
eb1fb83
feat: add repeating shift assignments
krantheman May 27, 2024
b67112c
refactor: clump consecutive shift assignments as one
krantheman May 28, 2024
d62d1b2
fix: clumping of shifts with gap >= 1 week
krantheman May 28, 2024
e652da0
feat: use background job for creating repeating shifts if date_diff >…
krantheman May 28, 2024
8d9b3ff
feat: add Shift Assignment Group
krantheman May 28, 2024
2b77964
feat: add delete repeating shift assignments
krantheman May 28, 2024
fef3428
fix: unselected day button text color
krantheman May 29, 2024
d706d87
chore: improve readability
krantheman May 29, 2024
8c21a06
style: increase employee column width
krantheman May 29, 2024
a21a3cb
feat: add toasts everywhere
krantheman May 29, 2024
abeda24
refactor: move employees resource to MonthView
krantheman May 30, 2024
4ab4c0c
fix: fetch events on creating shift from top bar
krantheman May 30, 2024
eb042b5
chore: rename file: Navbar.vue -> NavBar.vue
krantheman May 30, 2024
57582b2
chore: remove vue router
krantheman May 30, 2024
ee4f0ee
fix: dependencies
krantheman May 30, 2024
e16d9b3
revert: removal of vue-router
krantheman May 30, 2024
e41d5a9
style: center employee names when no designation in employee column
krantheman May 30, 2024
9977614
fix: import
krantheman May 30, 2024
cc941bc
style: fix table height and make th row stick
krantheman May 30, 2024
0e71463
fix: table height
krantheman May 30, 2024
ed69172
fix: creation of repeating shift with frequency > every week
krantheman May 31, 2024
a05b656
refactor: change Shift Assignment Group to Shift Assignment Schedule
krantheman May 31, 2024
aba2492
feat: add shift move
krantheman Jun 4, 2024
5971aaa
feat: add shift swapping
krantheman Jun 4, 2024
9675c63
refactor: shift swapping logic
krantheman Jun 4, 2024
158df52
fix: error message translation
krantheman Jun 10, 2024
1857e1c
fix: employee column z index
krantheman Jun 10, 2024
7dbd680
refactor: join consecutive shifts on moving
krantheman Jun 11, 2024
ef9a6f8
refactor: use insert shift for creating shifts
krantheman Jun 11, 2024
8edc8b4
fix: drag cursor and dragging into blocked days
krantheman Jun 11, 2024
e627819
feat: scale up shift that is being dragged upon
krantheman Jun 11, 2024
769af37
feat: add delete current shift
krantheman Jun 11, 2024
cb642ba
chore: rename repeating shift assignment to shift assignment schedule
krantheman Jun 11, 2024
455f064
feat: add bg color to dragover cell
krantheman Jun 12, 2024
2066fce
feat: can't drop shift to cells with same shift type and status
krantheman Jun 12, 2024
ca74b33
feat: no bg color for forbidden drop days
krantheman Jun 12, 2024
8935540
feat: hide original shift element while dragging
krantheman Jun 12, 2024
c1f2f9e
feat: add loading state
krantheman Jun 12, 2024
a49cb26
fix(Shift Assignment): check for overlap on update after submission a…
krantheman Jun 13, 2024
f63b808
fix(Shift Assignment Schedule): form placement
krantheman Jun 13, 2024
076a628
revert(Shift Assignment Schedule): form placement
krantheman Jun 13, 2024
c4366dc
feat: add process auto shift creation for shifts without end date
krantheman Jun 13, 2024
b30cb35
chore: update frappe-ui to v0.1.62
krantheman Jun 17, 2024
870dd67
feat: use DatePicker instead of FormControl date
krantheman Jun 17, 2024
977fcdd
fix: add website route rule for roster
krantheman Jun 17, 2024
e67d6e8
refactor: use frappe.delete_doc instead of frappe.db.delete
krantheman Jun 17, 2024
c38b543
refactor: remove Select Days checkbox and add Shift Schedule Settings…
krantheman Jun 17, 2024
21cea93
fix: creation of neverending shifts
krantheman Jun 17, 2024
d280717
fix: Shift Assignment Schedule naming
krantheman Jun 18, 2024
bcb9331
feat(Shift Assignment Schedule): add Employee Name field and List Vie…
krantheman Jun 18, 2024
5d46982
feat(Shift Assignment Schedule): add field description and Shift Assi…
krantheman Jun 18, 2024
0291306
feat: show schedule for existing shift assignments
krantheman Jun 18, 2024
7d8d281
feat: redirect to login page when logged out and make navbar actions …
krantheman Jun 19, 2024
782d578
feat: add Confirmation Dialog for delete operations
krantheman Jun 19, 2024
af46ca0
fix: field name in process_auto_shift_creation
krantheman Jun 20, 2024
58be6f8
revert: ShiftAssignmentDialog
krantheman Jun 20, 2024
1ae873c
refactor: DeleteDialog message formatting
krantheman Jun 20, 2024
47e2a96
chore: remove vue-tsc and types/vue
krantheman Jun 21, 2024
6d383e3
fix: Shedule Setting & Repeat On Days label names
krantheman Jun 25, 2024
7cd73c8
feat: add toast for moving/swapping shifts
krantheman Jun 25, 2024
2b46953
refactor: select only day of start_date for Repeat On Days by default
krantheman Jun 27, 2024
e8da11f
refactor(Shift Assignment Schedule): change Status to Enabled
krantheman Jun 27, 2024
2e4869f
refactor(ShiftAssignmentDialog): change Delete button icon to label f…
krantheman Jun 27, 2024
6d3162e
fix: typing
krantheman Jun 27, 2024
8ceb78d
feat(Shift Assignment): add validations for checking linked employee …
krantheman Jun 27, 2024
c78e11c
refactor: use get_holiday_list_for_employee for holidays
krantheman Jun 28, 2024
aa98bfe
fix: insertion of an indefinite shift right after a definite one of t…
krantheman Jul 1, 2024
c0e1d87
fix: route
krantheman Aug 5, 2024
1ed1b2b
feat: add Roster button to Shift Assignment list
krantheman Aug 5, 2024
a832891
feat: add Roster shortcut to workspace
krantheman Aug 5, 2024
b570d62
fix: build routing
krantheman Aug 5, 2024
abe8eae
feat: add Shift Assignment Schedule to workspace
krantheman Aug 7, 2024
c52a1f1
chore: update frappe-ui to v0.1.67
krantheman Aug 28, 2024
28b3adc
chore: update frappe-ui submodule
krantheman Aug 28, 2024
f6303f5
fix: update roster's tailwind config for frappe-ui submodule
ruchamahabal Aug 29, 2024
f7a30c4
chore: reset git submodule to the latest version (v0.1.67)
ruchamahabal Aug 29, 2024
db688e0
build: add roster as a separate yarn workspace
ruchamahabal Aug 29, 2024
510ec80
chore: regenerate yarn.lock file
ruchamahabal Aug 29, 2024
d698461
chore: fix conflicts
ruchamahabal Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trim_trailing_whitespace = true
charset = utf-8

# js indentation settings
[{*.js,*.vue,*.css,*.scss,*.html}]
[{*.js,*.ts,*.vue,*.css,*.scss,*.html}]
indent_style = tab
indent_size = 4
max_line_length = 99
max_line_length = 99
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ node_modules
hrms/docs/current
hrms/public/frontend
hrms/www/hrms.html
hrms/public/roster
hrms/www/roster.html
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ repos:
rev: v3.1.0
hooks:
- id: prettier
types_or: [javascript, vue, css, scss]
# Ignore fronetend folder and any files that might contain jinja / bundles
types_or: [javascript, ts, vue, css, scss]
# Ignore frontend folder and any files that might contain jinja / bundles
exclude: |
(?x)^(
frontend/.*|
Expand All @@ -46,4 +46,4 @@ repos:
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
submodules: false
2 changes: 1 addition & 1 deletion frappe-ui
Submodule frappe-ui updated 53 files
+3 −2 package.json
+4 −2 src/components/Autocomplete.vue
+11 −2 src/components/Avatar.vue
+1 −0 src/components/Breadcrumbs.vue
+247 −0 src/components/Calendar.story.md
+138 −0 src/components/Calendar.story.vue
+432 −0 src/components/Calendar/Calendar.vue
+113 −0 src/components/Calendar/CalendarDaily.vue
+512 −0 src/components/Calendar/CalendarEvent.vue
+143 −0 src/components/Calendar/CalendarMonthly.vue
+49 −0 src/components/Calendar/CalendarTimeMarker.vue
+252 −0 src/components/Calendar/CalendarWeekly.vue
+63 −0 src/components/Calendar/EventModalContent.vue
+46 −0 src/components/Calendar/FloatingPopover.vue
+210 −0 src/components/Calendar/NewEventModal.vue
+37 −0 src/components/Calendar/ShowMoreCalendarEvent.vue
+277 −0 src/components/Calendar/calendarUtils.js
+54 −0 src/components/Calendar/composables/useCalendarData.js
+41 −0 src/components/Calendar/composables/useEventModal.js
+7 −4 src/components/Checkbox.vue
+36 −0 src/components/DatePicker.story.vue
+108 −72 src/components/DatePicker.vue
+333 −0 src/components/DateRangePicker.vue
+405 −0 src/components/DateTimePicker.vue
+11 −3 src/components/Dialog.vue
+3 −3 src/components/FeatherIcon.vue
+6 −6 src/components/FileUploader.vue
+4 −4 src/components/ListFilter/ListFilter.vue
+2 −2 src/components/ListFilter/SearchComplete.vue
+1 −1 src/components/ListView/ListHeader.vue
+19 −7 src/components/ListView/ListRow.vue
+2 −2 src/components/ListView/ListView.vue
+19 −10 src/components/Popover.vue
+4 −4 src/components/Switch.vue
+17 −3 src/components/TabButtons.vue
+2 −2 src/components/TextEditor/InsertVideo.vue
+1 −1 src/components/TextEditor/TextEditor.vue
+1 −1 src/components/TextEditor/image-extension.js
+1 −1 src/components/TextEditor/mention.js
+1 −1 src/components/Tooltip/Tooltip.vue
+2 −2 src/components/toast.js
+4 −2 src/fonts/Inter/inter.css
+4 −0 src/index.js
+6 −6 src/resources/documentResource.js
+8 −8 src/resources/listResource.js
+1 −1 src/resources/plugin.js
+1 −1 src/utils/call.js
+1 −1 src/utils/confirmDialog.js
+1 −1 src/utils/debounce.ts
+1 −1 src/utils/frappeRequest.js
+1 −1 src/utils/markdown.js
+1 −1 src/utils/pageMeta.js
+4 −0 src/utils/tailwind.config.js
12 changes: 6 additions & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
"@ionic/vue": "^7.4.3",
"@ionic/vue-router": "^7.4.3",
"@vitejs/plugin-vue": "^4.4.0",
"autoprefixer": "^10.4.2",
"dayjs": "^1.11.7",
"feather-icons": "^4.28.0",
"frappe-ui": "^0.1.59",
"vue": "^3.2.25",
"vue-router": "^4.0.12",
"autoprefixer": "^10.4.2",
"firebase": "^10.8.0",
"frappe-ui": "^0.1.67",
"postcss": "^8.4.5",
"tailwindcss": "^3.0.15",
"vite": "^5.1.4",
"vite-plugin-pwa": "^0.19.0",
"workbox-precaching": "^7.0.0",
"vue": "^3.2.25",
"vue-router": "^4.0.12",
"workbox-core": "^7.0.0",
"firebase": "^10.8.0"
"workbox-precaching": "^7.0.0"
},
"devDependencies": {
"eslint": "^8.39.0",
Expand Down
251 changes: 251 additions & 0 deletions hrms/api/roster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
import frappe
from frappe import _
from frappe.utils import add_days, date_diff

from erpnext.setup.doctype.employee.employee import get_holiday_list_for_employee

from hrms.hr.doctype.shift_assignment.shift_assignment import ShiftAssignment
from hrms.hr.doctype.shift_assignment_tool.shift_assignment_tool import create_shift_assignment


@frappe.whitelist()
def get_values(doctype: str, name: str, fields: list) -> dict[str, str]:
return frappe.db.get_value(doctype, name, fields, as_dict=True)


@frappe.whitelist()
def get_events(
month_start: str, month_end: str, employee_filters: dict[str, str], shift_filters: dict[str, str]
) -> dict[str, list[dict]]:
holidays = get_holidays(month_start, month_end, employee_filters)
leaves = get_leaves(month_start, month_end, employee_filters)
shifts = get_shifts(month_start, month_end, employee_filters, shift_filters)

events = {}
for event in [holidays, leaves, shifts]:
for key, value in event.items():
if key in events:
events[key].extend(value)
else:
events[key] = value
return events


@frappe.whitelist()
def create_shift_assignment_schedule(
employee: str,
company: str,
shift_type: str,
status: str,
start_date: str,
end_date: str | None,
repeat_on_days: list[str],
frequency: str,
) -> None:
schedule = frappe.get_doc(
{
"doctype": "Shift Assignment Schedule",
"frequency": frequency,
"repeat_on_days": [{"day": day} for day in repeat_on_days],
"enabled": 0 if end_date else 1,
"employee": employee,
"company": company,
"shift_type": shift_type,
"shift_status": status,
}
).insert()

if not end_date or date_diff(end_date, start_date) <= 90:
return schedule.create_shifts(start_date, end_date)

frappe.enqueue(schedule.create_shifts, timeout=4500, start_date=start_date, end_date=end_date)


@frappe.whitelist()
def delete_shift_assignment_schedule(schedule: str) -> None:
for shift_assignment in frappe.get_all("Shift Assignment", {"schedule": schedule}, pluck="name"):
doc = frappe.get_doc("Shift Assignment", shift_assignment)
if doc.docstatus == 1:
doc.cancel()
frappe.delete_doc("Shift Assignment", shift_assignment)
frappe.delete_doc("Shift Assignment Schedule", schedule)


@frappe.whitelist()
def swap_shift(
src_shift: str, src_date: str, tgt_employee: str, tgt_date: str, tgt_shift: str | None
) -> None:
if src_shift == tgt_shift:
frappe.throw(_("Source and target shifts cannot be the same"))

if tgt_shift:
tgt_shift_doc = frappe.get_doc("Shift Assignment", tgt_shift)
tgt_company = tgt_shift_doc.company
break_shift(tgt_shift_doc, tgt_date)
else:
tgt_company = frappe.db.get_value("Employee", tgt_employee, "company")

src_shift_doc = frappe.get_doc("Shift Assignment", src_shift)
break_shift(src_shift_doc, src_date)
insert_shift(
tgt_employee, tgt_company, src_shift_doc.shift_type, tgt_date, tgt_date, src_shift_doc.status
)

if tgt_shift:
insert_shift(
src_shift_doc.employee,
src_shift_doc.company,
tgt_shift_doc.shift_type,
src_date,
src_date,
tgt_shift_doc.status,
)


@frappe.whitelist()
def break_shift(assignment: str | ShiftAssignment, date: str) -> None:
if isinstance(assignment, str):
assignment = frappe.get_doc("Shift Assignment", assignment)

if assignment.end_date and date_diff(assignment.end_date, date) < 0:
frappe.throw(_("Cannot break shift after end date"))
if date_diff(assignment.start_date, date) > 0:
frappe.throw(_("Cannot break shift before start date"))

employee = assignment.employee
company = assignment.company
shift_type = assignment.shift_type
status = assignment.status
end_date = assignment.end_date

if date_diff(date, assignment.start_date) == 0:
assignment.cancel()
assignment.delete()
else:
assignment.end_date = add_days(date, -1)
assignment.save()

if not end_date or date_diff(end_date, date) > 0:
create_shift_assignment(employee, company, shift_type, add_days(date, 1), end_date, status)


@frappe.whitelist()
def insert_shift(
employee: str, company: str, shift_type: str, start_date: str, end_date: str | None, status: str
) -> None:
filters = {
"doctype": "Shift Assignment",
"employee": employee,
"company": company,
"shift_type": shift_type,
"status": status,
}
prev_shift = frappe.db.exists(dict({"end_date": add_days(start_date, -1)}, **filters))
next_shift = (
frappe.db.exists(dict({"start_date": add_days(end_date, 1)}, **filters)) if end_date else None
)

if prev_shift:
if next_shift:
end_date = frappe.db.get_value("Shift Assignment", next_shift, "end_date")
frappe.db.set_value("Shift Assignment", next_shift, "docstatus", 2)
frappe.delete_doc("Shift Assignment", next_shift)
frappe.db.set_value("Shift Assignment", prev_shift, "end_date", end_date or None)

elif next_shift:
frappe.db.set_value("Shift Assignment", next_shift, "start_date", start_date)

else:
create_shift_assignment(employee, company, shift_type, start_date, end_date, status)


def get_holidays(month_start: str, month_end: str, employee_filters: dict[str, str]) -> dict[str, list[dict]]:
holidays = {}

for employee in frappe.get_list("Employee", filters=employee_filters, pluck="name"):
if holiday_list := get_holiday_list_for_employee(employee, raise_exception=False):
holidays[employee] = frappe.get_all(
"Holiday",
filters={"parent": holiday_list, "holiday_date": ["between", [month_start, month_end]]},
fields=["name as holiday", "holiday_date", "description", "weekly_off"],
)

return holidays


def get_leaves(month_start: str, month_end: str, employee_filters: dict[str, str]) -> dict[str, list[dict]]:
LeaveApplication = frappe.qb.DocType("Leave Application")
Employee = frappe.qb.DocType("Employee")

query = (
frappe.qb.select(
LeaveApplication.name.as_("leave"),
LeaveApplication.employee,
LeaveApplication.leave_type,
LeaveApplication.from_date,
LeaveApplication.to_date,
)
.from_(LeaveApplication)
.left_join(Employee)
.on(LeaveApplication.employee == Employee.name)
.where(
(LeaveApplication.docstatus == 1)
& (LeaveApplication.status == "Approved")
& (LeaveApplication.from_date <= month_end)
& (LeaveApplication.to_date >= month_start)
)
)

for filter in employee_filters:
query = query.where(Employee[filter] == employee_filters[filter])

return group_by_employee(query.run(as_dict=True))


def get_shifts(
month_start: str, month_end: str, employee_filters: dict[str, str], shift_filters: dict[str, str]
) -> dict[str, list[dict]]:
ShiftAssignment = frappe.qb.DocType("Shift Assignment")
ShiftType = frappe.qb.DocType("Shift Type")
Employee = frappe.qb.DocType("Employee")

query = (
frappe.qb.select(
ShiftAssignment.name,
ShiftAssignment.employee,
ShiftAssignment.shift_type,
ShiftAssignment.start_date,
ShiftAssignment.end_date,
ShiftAssignment.status,
ShiftType.start_time,
ShiftType.end_time,
ShiftType.color,
)
.from_(ShiftAssignment)
.left_join(ShiftType)
.on(ShiftAssignment.shift_type == ShiftType.name)
.left_join(Employee)
.on(ShiftAssignment.employee == Employee.name)
.where(
(ShiftAssignment.docstatus == 1)
& (ShiftAssignment.start_date <= month_end)
& ((ShiftAssignment.end_date >= month_start) | (ShiftAssignment.end_date.isnull()))
)
)

for filter in employee_filters:
query = query.where(Employee[filter] == employee_filters[filter])

for filter in shift_filters:
query = query.where(ShiftAssignment[filter] == shift_filters[filter])

return group_by_employee(query.run(as_dict=True))


def group_by_employee(events: list[dict]) -> dict[str, list[dict]]:
grouped_events = {}
for event in events:
grouped_events.setdefault(event["employee"], []).append(
{k: v for k, v in event.items() if k != "employee"}
)
return grouped_events
2 changes: 2 additions & 0 deletions hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

website_route_rules = [
{"from_route": "/hrms/<path:app_path>", "to_route": "hrms"},
{"from_route": "/hr/<path:app_path>", "to_route": "roster"},
]
# Jinja
# ----------
Expand Down Expand Up @@ -220,6 +221,7 @@
],
"hourly_long": [
"hrms.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts",
"hrms.hr.doctype.shift_assignment_schedule.shift_assignment_schedule.process_auto_shift_creation",
],
"daily": [
"hrms.controllers.employee_reminders.send_birthday_reminders",
Expand Down
10 changes: 9 additions & 1 deletion hrms/hr/doctype/shift_assignment/shift_assignment.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"employee_name",
"shift_type",
"status",
"schedule",
"column_break_3",
"company",
"start_date",
Expand Down Expand Up @@ -101,11 +102,18 @@
"fieldtype": "Select",
"label": "Status",
"options": "Active\nInactive"
},
{
"fieldname": "schedule",
"fieldtype": "Link",
"label": "Schedule",
"options": "Shift Assignment Schedule",
"read_only": 1
}
],
"is_submittable": 1,
"links": [],
"modified": "2024-04-04 17:13:13.137431",
"modified": "2024-05-31 16:41:32.869130",
"modified_by": "Administrator",
"module": "HR",
"name": "Shift Assignment",
Expand Down
Loading
Loading