Summary
Rework Shifts (Turnos) end-to-end: modernize the frontend UX and
enforce robust business rules/validations on the backend. Ensure
a clean flow to start/close shifts, prevent overlaps, and prepare
reliable shift data for cashier closing (corte de caja).
Goals
- Provide clear, usable shift management UI (list, start, close,
edit notes).
- Enforce business rules: one active shift per user, no overlaps,
valid times.
- Align API and validations with existing Ktor patterns and tests.
- Integrate permissions: shifts_read, shifts_create, shifts_update,
shifts_delete, shifts_close.
Scope
- Server (Ktor):
- Review and harden shift business logic in ShiftService and
Shifts.kt.
- Add explicit “start” and “close” actions or enforce
validations within existing CRUD.
- Ensure all routes require auth; align 204/404 semantics with
current style.
- Unit tests mirroring DishServiceTest patterns.
- Client (Next.js):
- Frontend rework: dedicated shifts UI under client/src/modules/
cashier or new client/src/modules/shifts.
- Create/edit/close flows with inline validations and
permission-based gating.
- Filter by date/user; highlight current active shift; show
state clearly.
- Docs:
- Update shifts usage and validation rules; describe permission
checks.
Out of Scope
- Full cashier closing printing/report (handled in “Cashier Closing”
feature).
- Complex scheduling (multi-location, overlapping roles).
Acceptance Criteria
Tasks
- Backend: Business Logic
- Backend: API and Docs
- Tests (Server)
- Frontend Rework
- Docs
Business Rules
- One active shift per user at any time.
- No overlapping shifts for the same user on the same date.
- Close requires end_time > start_time.
- Only authorized users can create/close shifts; admins can manage
any user’s shifts (if policy requires).
API Contract (Draft)
- GET /shifts → 200 list | 204 none
- GET /shifts/{id} → 200 item | 404
- POST /shifts (start, if using CRUD) → 201 | 409 on overlap/active
- PUT /shifts/{id} (close via update or notes edit) → 200 | 409
invalid close | 404
- Optional explicit:
- POST /shifts/start → 201 | 409
- POST /shifts/{id}/close → 200 | 409 | 404
Implementation Notes
- Server: follow Shifts.kt/service patterns; keep responses
consistent with Dishes.kt/Suppliers.kt.
- DB: SQLite overlap is validated in service; consider indices for
performance.
- Client: mirror structure/patterns used in client/src/modules/
dishes; 2-space indent; show active shift prominently in cashier
context.
Risks
- Overlap detection edge cases with time boundaries; add unit tests
for equality at boundaries.
- Existing clients may rely on current unauthenticated GET /shifts;
coordinate change.
- Partial data if client starts but never closes; surface in UI and
allow admin remediation.
Labels
type:feature area:shifts area:frontend area:backend area:auth
priority:medium
Summary
Rework Shifts (Turnos) end-to-end: modernize the frontend UX and
enforce robust business rules/validations on the backend. Ensure
a clean flow to start/close shifts, prevent overlaps, and prepare
reliable shift data for cashier closing (corte de caja).
Goals
edit notes).
valid times.
shifts_delete, shifts_close.
Scope
Shifts.kt.
validations within existing CRUD.
current style.
cashier or new client/src/modules/shifts.
permission-based gating.
state clearly.
checks.
Out of Scope
feature).
Acceptance Criteria
invalid close).
Tasks
same user.
(align with others).
(migration optional).
notes?)
close success; double-close conflict; invalid end time.
Business Rules
any user’s shifts (if policy requires).
API Contract (Draft)
invalid close | 404
Implementation Notes
consistent with Dishes.kt/Suppliers.kt.
performance.
dishes; 2-space indent; show active shift prominently in cashier
context.
Risks
for equality at boundaries.
coordinate change.
allow admin remediation.
Labels
type:feature area:shifts area:frontend area:backend area:auth
priority:medium