Staff change lifecycle¶
This document describes the side effects performed by the staff write endpoints (POST /staff, PUT /staff/{id}, DELETE /staff/{id}).
Create staff (POST /staff)¶
StaffService.save(...) performs the following steps:
- If
leaveEntitlementsis provided, each entitlement is normalized: leaveType.idis required and must exist.- The referenced leave type is marked
used=true(if not already). staffandtenantIdare attached to the entitlement row.- Period/proration rules are applied (see Leave entitlement proration).
- The staff record is saved.
jurisdictionIdidentifies the jurisdiction used for calendars and jurisdiction-based eligibility rules. - An
app_userrow is created for the staff member: loginNameusesstaff.loginNamewhen provided, otherwise falls back tostaff.id.- Initial password is set to the same value as the login name (stored encoded).
- User
activeistrueonly whenjoinDate <= today. - Duplicate login names fail with
DuplicateLoginNameException. - Tenant activity is updated via
tenantActivityService.touch(tenantId).
Update staff (PUT /staff/{id})¶
StaffService.update(...) performs the following steps:
- Load existing staff by ID, otherwise fail with
StaffNotFoundException. - Update mutable fields:
name,joinDate,termDate, andjurisdictionId. - If
workScheduleis present in request, replace it; if omitted, keep existing schedule. - If
leaveEntitlementsis present in request: - Normalize them using the same rules as create.
- Clear existing entitlement rows and replace with normalized rows.
- Save staff and touch tenant activity.
Notes:
- Updating staff does not update the linked
app_userlogin name/password/active state. - Proration is applied only to entitlement rows that are supplied in the update payload.
Delete staff (DELETE /staff/{id})¶
StaffService.delete(...) performs the following steps:
- Load existing staff by ID, otherwise fail with
StaffNotFoundException. - If the staff member is referenced by leave applications (as applicant or approver), fail with
StaffInUseException(409from controller). - Delete the staff row.
- Touch tenant activity.
Notes:
- Deleting staff does not delete the related
app_userrow. - Other database references (for example unresolved leave-approver links) can still block deletion at database-constraint level.