Server rules: who may see, create and approve what
These rules are enforced by the server on branch feature/mobile-changes of HRMS.WebAPI (commits c0a76d3, 6a0a880, d8d059d, b36ffa6, 90cfb6e). The app should apply the same rules to its UI, so users never see a button the server will refuse.
Roles
- Admin: the role named
Admin. Unrestricted. - Everyone else (role
Userand any custom role): limited to themselves and their team. "Team" = the employee plus everyone under them in the leader hierarchy (Employee.Leader, recursive; stored procedureUSP_GET_EMPLOYEE_TEAM_MEMBER). - Team leader = an employee with people under them (other employees have them as
Leader). Login'sisApproveris a separate designation flag ("can approve"); the app uses it to decide whether to show Approvals, the server uses the team.
Applications: create and edit
Applies to leave, WFH, missed punch (thumb), overtime, fuel allowance, compensation, extra pay, resignation and clarification.
- The
employeeIdyou send, and on edit the employee on the stored record, must be you or someone in your team. Otherwise:You can't create or change applications for this employee. - Status rules:
- Saving as Pending (0) is always allowed. This covers new applications and editing or resubmitting your own (an approved or rejected application goes back to Pending).
- For punches (thumb applications) the tenant's default punch status is also allowed, because a new punch gets it anyway.
- Any other status (Approved/Rejected), or editing an application that is already approved/rejected while keeping that status, needs approval rights (below). Otherwise:
This application is already approved or rejected. Only an approver can change it.
- Employees: always send
status: 0(leaveStatus,status,overtimeStatus, …) when creating or editing.
Applications: approve and reject
Update…Status endpoints (and setting a non-Pending status through CreateOrUpdate) are allowed for:
- Admin, for anyone; or
- a team leader for members of their team, never for their own applications, and only when the tenant setting
isLeadersCanApproveApplicationis on (Setting/GetAllSettings).
Otherwise: You can't approve or reject these applications. One refused id fails the whole batch.
Show the approve/reject UI only when isApprover && isLeadersCanApproveApplication, only on other people's Pending items. This is the same rule the web app uses.
Applications: get by id and delete
Allowed for your own and your team's records (Admin: any). Otherwise: You can't view or delete this application.
Lists
Send employeeIds: null. The server decides the scope:
| List | Non-admin sees |
|---|---|
| Leave, WFH, overtime, fuel allowance, compensation | You and your team. Ids you send can only narrow it. |
| Missed punch (thumb), extra pay, resignation, clarification | Only you, even for team leaders. |
All reports (Report/…) | Only you. |
| Helpdesk requests, reminders | Only the ones you created. |
| Instructions, holidays, documents | Everyone in the tenant. |
Mobile clock in / clock out (MobileQuick)
For a punch with thumbSource: 2 (MobileQuick):
- The server ignores the phone's date and time and uses server-local now.
- It ignores the status you send and decides it from GPS:
- Approved when
latitude/longitudeare within 200 m of where the employee says they work:thumbApplicationFromType: 1(Office): the employee's assigned location (Employee.LocationId→ location coordinates), or the employee's own coordinates when "use employee location" is set on their profile.thumbApplicationFromType: 2(Project site): the selectedprojectId's coordinates.
- Otherwise (outside,
3Other site, no GPS, or a location without coordinates): the tenant's default punch status (thumbApplicationDefaultStatusin settings, often Pending).
- Approved when
- The punch is never blocked (decision D4). The app shows its own geofence warning and asks for a remark when outside, but the final status is the one the API returns.
Missed-punch requests use thumbSource: 1 (Mobile) with the date and time the user picks; they get the tenant default status like any other request.
Other rules worth knowing
- "Limit Days Exceeded" errors (punches, clarifications): the SQL function
GET_APPLICATION_ENTRY_ALLOWrefuses it when the employee is inactive or has an approved leave covering that date (despite the wording, there is no day-count limit; theapplicationLimitDayssetting is not used by the API code). It applies to clock-ins too. - Overlapping leave is refused by the leave service when a non-rejected leave already covers the dates (see the errors on Apply leave).
- Employee picker: for non-admins
Employee/GetEmployeeWithCodereturns only themselves. - Personal records (notifications, profile photo, own details, family members, investment declarations, helpdesk request status): non-admins may act only on their own; see Known API gaps → Security for the exact messages.