Skip to main content

HR Workflows

This page describes the business process workflows implemented in BonardaHR, covering state machines, permissions, business rules, and side effects for each workflow.


Summary

WorkflowInitial StateTerminal StatesApproval RequiredKey Side Effects
Time OffPENDINGAPPROVED, REJECTED, CANCELLEDYes (manager)Balance update, calendar event, email
TimesheetDRAFTAPPROVEDYes (manager)Hours recalculation, email reminders
Document SigningPENDINGSIGNED, DECLINEDNo (self-service)Forensic audit trail
Employee LifecycleACTIVETERMINATEDNo (HR action)Soft delete, cancel time-off

1. Time-Off Request Workflow

Status States

StatusDescriptionTransitions
PENDINGInitial state after creationEmployee can cancel; Manager/HR can approve or reject
APPROVEDRequest grantedEmployee can cancel
REJECTEDRequest deniedTerminal state
CANCELLEDCancelled by employeeTerminal state

State Diagram

[Employee Creates Request]
|
v
PENDING ──────────────────────────────────────┐
│ │
├── [Employee Cancel] ──────────────────> CANCELLED

├── [Manager Approve] ──> APPROVED
│ │
│ └── [Employee Cancel] ──> CANCELLED

└── [Manager Reject] ───> REJECTED

Permissions

ActionPermissionRoles
Create requestTIME_OFF_REQUEST_CREATEAll employees
View own requestsTIME_OFF_REQUEST_READ_OWNAll employees
View team requestsTIME_OFF_REQUEST_READ_TEAMMANAGER
View all requestsTIME_OFF_REQUEST_READ_ALLHR_MANAGER, ADMIN
Approve / RejectTIME_OFF_REQUEST_APPROVEMANAGER, HR_MANAGER, ADMIN

Business Rules

Request Creation

  • Validates that end_date >= start_date
  • Half-day requests must be a single day with a MORNING or AFTERNOON period
  • Calculates business days (weekdays only)
  • Checks for overlapping PENDING or APPROVED requests
  • Validates sufficient balance (unless type is unlimited)
  • Deducts from pending balance immediately on creation

Approval

  • Reviewer cannot be the requesting employee
  • Moves pending balance to used
  • Creates Outlook calendar event (if Microsoft integration is enabled)

Rejection

  • Returns the pending balance to available

Cancellation

  • Only PENDING or APPROVED requests can be cancelled
  • Only the requesting employee can cancel
  • Returns balance (pending or used) to available
  • Deletes the Outlook calendar event if the request was APPROVED

Attachment Requirements

Time-off types can require supporting documents:

RequirementBehaviour
NEVERNo attachment needed
ALWAYSAttachment always required
CONDITIONALRequired if business_days > attachmentRequiredAfterDays

Side Effects

EventSide Effect
Request createdManager receives email notification
Request reviewedEmployee receives email with decision
Request approvedOutlook calendar event created
Request cancelled (if approved)Outlook calendar event deleted

2. Timesheet Workflow

Status States

StatusDescriptionTransitions
DRAFTCreated but not submittedEmployee can edit and submit
SUBMITTEDAwaiting manager reviewManager can approve or reject
APPROVEDAccepted by managerTerminal state
REJECTEDReturned for correctionsEmployee can edit and resubmit

State Diagram

[Employee Creates Timesheet]
|
v
DRAFT

├── [Edit Entries / Clock In/Out]

└── [Submit] ──────> SUBMITTED

├── [Approve] ──> APPROVED

└── [Reject] ───> REJECTED

└── [Edit & Resubmit] ──> SUBMITTED

Permissions

ActionPermissionRoles
Create / Edit / SubmitTIMESHEET_CREATEAll employees
Clock In / OutTIMESHEET_CREATEAll employees
View own timesheetsTIMESHEET_READ_OWNAll employees
View team timesheetsTIMESHEET_READ_TEAMMANAGER
View all timesheetsTIMESHEET_READ_ALLHR_MANAGER, ADMIN
Approve / RejectTIMESHEET_APPROVEMANAGER, HR_MANAGER, ADMIN

Business Rules

Edit Window

  • Employees can edit the current week and the 2 preceding weeks
  • Future timesheets cannot be created
  • Timesheets older than 2 weeks are locked

Clock In / Out

  • Clock-in records the current timestamp
  • Clock-out calculates hours: (clockOut - clockIn) / 60, rounded to nearest 0.5
  • Automatically creates a timesheet entry for today if one does not exist

Submission

  • Only DRAFT or REJECTED timesheets can be submitted
  • Must have at least one time entry
  • Must be within the edit window

Review

  • Reviewer cannot be the submitting employee
  • REJECTED timesheets return to an editable DRAFT-equivalent state

Side Effects

  • Total hours recalculated after each entry change
  • Email reminders sent for overdue (unsubmitted) timesheets

3. Document Signing Workflow

Status States

StatusDescriptionFinal?
PENDINGAwaiting employee actionNo
SIGNEDEmployee signedYes
DECLINEDEmployee declinedYes

State Diagram

[HR Requests Signatures]
|
v
PENDING

├── [Sign] ──────> SIGNED

└── [Decline] ───> DECLINED

Permissions

ActionPermissionRoles
Share document / request signaturesDOCUMENT_SHAREHR_MANAGER, ADMIN
Sign own signature requestDOCUMENT_SIGN_OWNAll employees
View signature statusDOCUMENT_SIGN_READHR_MANAGER, ADMIN

Business Rules

Requesting Signatures

  • The document must have requiresSignature = true
  • Creates a document share if the employee does not already have access
  • Creates a PENDING signature record for each target employee

Signing

  • Only PENDING signatures can be signed
  • An employee can only sign their own signature request
  • Captures: signature data, timestamp, IP address, user agent

Declining

  • Only PENDING signatures can be declined
  • Employee must provide a decline reason
  • Immutable after declining

Forensic Audit Trail

Each signed or declined record captures:

FieldDescription
Signature dataDigital signature content
TimestampExact moment of signing or declining
IP addressClient IP at time of action
User agentBrowser and device info
Decline reasonMandatory if declined

4. Employee Lifecycle Workflow

Status States

StatusDescriptionSystem Access
ACTIVECurrently employedFull access
ON_LEAVEHas approved time-off today (computed)Read-only display state
INACTIVETemporarily suspendedNo access
TERMINATEDLeft companyNo access

State Diagram

[Create Employee]
|
v
ACTIVE ◄────────────────────────────────────┐
│ │
├── [Approved Time-Off Today] ──> ON_LEAVE ┘
│ (computed, not stored)

├── [Deactivate] ────────────────> INACTIVE
│ │
│ ┌────────── [Reactivate] ──────────┘
│ │
└───┴── [Terminate] ─────────────> TERMINATED (soft-deleted)

Effective Status

ON_LEAVE is a computed display state — it is not stored in the database. At runtime:

  • If stored status is ACTIVE AND the employee has an approved time-off request covering today → display as ON_LEAVE
  • Otherwise, display the stored status

Separation Types

TypeDescription
RESIGNATIONEmployee voluntarily left
TERMINATIONEmployment terminated
LAYOFFPosition eliminated
RETIREMENTEmployee retired
CONTRACT_ENDContract completed

Offboarding Process (terminateEmployee)

When an employee is terminated, the following happen atomically:

  1. Set exitDate, separationType, and separationReason
  2. Cancel all PENDING time-off requests
  3. Cancel APPROVED requests with dates after the exit date; return balances
  4. Delete future Outlook calendar events (if calendar sync is enabled)
  5. Soft-delete the employee record

HR-Only Fields

The following fields require the EMPLOYEE_EXIT_INFO_READ permission to view:

  • exitDate
  • separationType
  • separationReason

5. Field Value Audit Trail

Purpose

Every change to an employee's profile field creates an immutable audit record for compliance and dispute resolution.

Audit Record Structure

FieldDescription
employeeIdWhich employee was changed
fieldNameField name (e.g. "Mobile Phone")
sectionNameSection (e.g. "Contact Information")
previousValueOld value
newValueNew value
changedByEmployee who made the change
changedAtTimestamp
note

fieldName and sectionName are stored denormalised at the time of change — if a field or section is later renamed, historical audit records preserve the original names. This is intentional.

Field Editability Rules

EditableByWho Can Edit
SYSTEMNo one (auto-generated values)
HR_ONLYHR Manager and Admin only
EMPLOYEEEmployee (own profile) or HR

Cross-Cutting Concerns

Notification Triggers

TriggerRecipientsContent
Time-off request createdManagerRequest details and dates
Time-off request reviewedEmployeeDecision, reviewer, and notes
Timesheet overdueEmployeeReminder to submit

Calendar Integration

TriggerAction
Time-off approvedCreate Outlook event
Time-off cancelled (if approved)Delete Outlook event

Transaction Management

  • All workflow state transitions use @Transactional for ACID guarantees
  • Pessimistic locking is applied on balance rows during time-off approval to prevent double-deduction
  • Read-only transactions are used for all query operations