<aside> 🔁 Synced from GitHub #632c4d3fadcd. Edit in the paidhr-system-docs repository, not here: changes made in Notion are overwritten.

</aside>

Employee requests engine

Status: Live

💡 In plain words

Leave, loans, salary advances, document letters, exits, moves and suspensions all work the same way under the hood.

An employee (or HR on their behalf) asks for something. The company's rules for that type of request are checked. Then it goes to the right people to approve, one after another. When the last person approves, PaidHR does whatever that request needs, such as sending an email, adding a payroll deduction or producing a letter.

It's one front desk with one form tray for every kind of request. Only what happens after the final stamp differs.

Who's involved: the employee (asks), approvers (say yes, no, or send it back), and HR (sets the rules for each type).

In one paragraph

Leave, loans, salary advances, document requests, exits, redeployments and suspensions are not separate systems. Each is a row in one table, EmployeeRequests, with a type, a policy that sets its rules, and a status. They all move through the same review method and the same approval chains. Only the side effects of the final approval differ by type. Learn this page and you understand seven features.

Request types

Id Type Policy table Detail page
1 Leave LeavePolicies / LeavePolicyItems Leave
2 Loan LoanPolicies / LoanPolicyItems Loans & salary advance
3 Salary advance AdvancePolicies / AdvancePolicyItems Loans & salary advance
4 Document DocumentPolicies / DocumentPolicyItems Below
5 Exit ExitPolicies / ExitPolicyItems Exit
6 Redeployment RedeploymentPolicies / RedeploymentPolicyItems Below
7 Suspension — Below

Policy items hold the per-level rules: one row per pay band, pay grade or policy group (entitlement days, maximum loan amount, notice period…). When a person raises a request, the system finds the item that matches their band, grade or group.

Statuses

Id Status Meaning
3 New Submitted, waiting for review
1 Approved Every step approved
2 Declined An approver said no
5 Returned Sent back to the employee for correction
6 Withdrawn The employee pulled it back before a decision
4 Cancelled Cancelled after approval (for example leave that was not taken)

Lifecycle

stateDiagram-v2
  [*] --> New: employee or HR submits
  New --> New: a step approves, more steps remain
  New --> Approved: last step approves
  New --> Declined: any step declines
  New --> Returned: returned for correction
  Returned --> New: employee resubmits
  New --> Withdrawn: employee withdraws
  Approved --> Cancelled: cancelled / leave cut short
  Approved --> [*]

What happens when someone clicks Approve

RequestService.ReviewEmployeeRequest:

  1. Load the request, its view (which has the computed next approver), the person and the company settings.
  2. Leave overlap guard (leave only): if approving would put more people from a department away at once than allowed, the approver must give a reason and hold Can override leave overlap.
  3. May this person review? Yes if they are the named next reviewer, or hold the role of the next step, or are Primary/Secondary Admin.
  4. Already done? If approval workflows are on and no steps remain, refuse with "already fully reviewed".
  5. Record the review in spReviewEmployeeRequest (note, for payroll and deduct from payroll flags, survey id for exits). The procedure writes an EmployeeRequestReviews row and moves the step on.