Skip to main content

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 User and any custom role): limited to themselves and their team. "Team" = the employee plus everyone under them in the leader hierarchy (Employee.Leader, recursive; stored procedure USP_GET_EMPLOYEE_TEAM_MEMBER).
  • Team leader = an employee with people under them (other employees have them as Leader). Login's isApprover is 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.

  1. The employeeId you 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.
  2. 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.
  3. 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 isLeadersCanApproveApplication is 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:

ListNon-admin sees
Leave, WFH, overtime, fuel allowance, compensationYou and your team. Ids you send can only narrow it.
Missed punch (thumb), extra pay, resignation, clarificationOnly you, even for team leaders.
All reports (Report/…)Only you.
Helpdesk requests, remindersOnly the ones you created.
Instructions, holidays, documentsEveryone 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/longitude are 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 selected projectId's coordinates.
    • Otherwise (outside, 3 Other site, no GPS, or a location without coordinates): the tenant's default punch status (thumbApplicationDefaultStatus in settings, often Pending).
  • 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_ALLOW refuses it when the employee is inactive or has an approved leave covering that date (despite the wording, there is no day-count limit; the applicationLimitDays setting 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/GetEmployeeWithCode returns 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.