Skip to content

4. Behaviour ​

4.1 Business logic ​

Submitting a leave request:

Submit -> validate days -> check balance -> check policy -> create -> start approval workflow
  • Validate days: a rule rejects a request for fewer than one day. (This is in the capstone plugin and verified.)
  • Check balance and policy: a rule or a data service compares days with entitled minus used. Keep one owner per field.
  • Start approval: a rule on AFTER_UPDATE starts the workflow when status becomes PENDING_APPROVAL.

Comparing two dates. A rule can compare a field with another field of the same record using ${record.field}, for numbers and dates alike: { "field": "to_date", "op": "lt", "value": "${record.from_date}" } rejects an end date before the start date. (Fixed on 2026-09-25; before that, ordered comparison of dates failed with a server error.) The capstone plugin uses it, and its form also checks the order on screen.

See Business logic.

4.2 APIs ​

Every entity already has its API:

POST /api/v1/entities/lm_leave_request/records          create
GET  /api/v1/entities/lm_leave_request/records?page=0&size=20   list (paginated)
PUT  /api/v1/entities/lm_leave_request/records/{id}     update (send only changed fields)

Dates are sent as ISO timestamps (2026-10-01T00:00:00Z). Approve and reject are workflow decisions on the task, not custom endpoints. Add a plugin API only for what declarations cannot do (API Designer).

4.3 Workflow ​

Draft -> Submitted -> Manager approval -> HR approval -> Approved -> balance updated
                          |                  |
                       Rejected           Rejected

Stages manager, hr; a human approval task each; role-based approvers; a two-day SLA on the manager stage that moves the request to HR on breach; history kept. The rule's callback sets the request status to APPROVED or REJECTED at the end. See Workflows.

4.4 Events and automation ​

Leave request created -> notify manager
Leave approved -> update balance -> create attendance entry -> notify employee

Use a rule after update for record events, and workflow transitions for process events. Make actions idempotent (running twice must not deduct twice): update balance by setting used_days from a sum, not by adding one. Use events when others may react later; do not use them for a check that must block the save. See Events and automation.

4.5 Scheduled jobs ​

Every night 01:00 -> accrue leave -> update balances -> list exceptions

Cron, parameters, run history, manual run. See Jobs.

4.6 Queues and async ​

Import 5,000 employees: do not do it inside one request. Queue-style processing is Planned (Queues); today use a job or an integration flow with retry.

4.7 Notifications ​

Templates for email, in-app, SMS, WhatsApp, push; a workflow notification or a rule triggers them. Keep one template per event and translate it.

4.8 Integrations ​

Leave to payroll: a connector (REST, OAuth2), an integration flow that maps approved leave to the payroll format, retry, timeout, secrets stored write-only, failures raised to a workflow. See Integrations.

Next: Insight.