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

</aside>

Reports

Status: Live

💡 In plain words

Reports turn PaidHR's data into a table you can read, print or download.

Someone in HR picks what they want to see (a staff list, a payroll breakdown, a tax schedule), chooses the columns, filters down to the right people, and PaidHR builds the report. They can save it and run it again next month. A big report is built in the background, so they can carry on working and come back for it when it's ready. Each report is private to the person who asked for it.

Like building your own spreadsheet from a form: you tick the columns you want, say who to include, and PaidHR fills it in.

Who's involved: HR and finance admins (build, run and download reports), and support (can look up a stuck report by its reference to help).

In one paragraph

The Report Builder lets an admin build a report from scratch: pick a subject, choose columns, add filters, set a date, group and sort, and optionally add their own summary rows at the foot. A live sample preview shows the shape of the report over a handful of real people as it is built. A report can be saved and run again later, and a company's older custom reports are moved into the builder automatically the first time its saved reports are opened. There are three subjects to report on: people, a payroll run, and a payroll run as a journal entry. A company with sub-accounts can report across all of them at once. Running a report happens in the background: the request is queued, a worker builds it, progress is shown live, and the finished table or file is collected when ready. Separately, statutory reports produce the fixed government schedules (PAYE, pension, NHF, NSITF and more) from a chosen payroll run.

Key ideas

Term Meaning
Report / definition A saved recipe: subject, columns, filters, date, grouping, sorting and summary rows. Running it produces a table
Dataset (subject) What the report is about: employees (Employees), payroll (Payroll, one pay run), payroll_journal_entries (Payroll journal entry, a pay run as a balanced double-entry journal)
Report date / period Either "as at" one day, or a from–to range. A range with no end day runs up to the day it is run, so a saved year-to-date report stays current
Column A field in the report. Lookup (A column that holds hidden ids, like the department or group a person belongs to) columns can only be used to filter, never shown, because their ids mean nothing in a file
Filter Narrows who is included. Combined with and only. Operators depend on the column type (text, money/number, date, lookup, true/false)
Group and sort Up to 3 group levels (with optional subtotals and a grand total) and up to 5 sort columns
Summary row A named row at the foot, worked out with a small formula (SUM, AVG, MIN, MAX, COUNT, numbers, + - * / %, and ROW(id) to reuse an earlier row). At most 10 rows
Sample preview The report's shape over up to 12 of the account's real people, so it can be seen while it is built. If there is nobody to show, invented people stand in
Queued report / job A background run. Private to the person who asked for it. Statuses: queued, running, completed, failed
Accounts A company and its sub-accounts. One report can cover all of them (or one), each row saying which account it came from
Statutory report A fixed government schedule (PAYE, pension, NHF, NSITF and more) built from one payroll run, downloaded as Excel

How it works

A download runs in the background. The request is queued, a worker builds it, progress is pushed live, and the file is collected when ready.

flowchart LR
  A[Admin builds report,<br/>clicks Download] --> B{Checks pass?}
  B -->|no| X[Refusal message]
  B -->|yes| Q[Job queued<br/>status: queued]
  Q --> W[Worker claims job<br/>status: running]
  W --> F[Build table, then<br/>CSV, Excel or PDF]
  F --> S[File stored on the job<br/>status: completed]
  W -. live progress .-> P[Progress feed:<br/>Waiting to start, Gathering<br/>report data, Still working]
  S --> D[Admin collects<br/>and downloads the file]

A preview works the same way but returns the table as data rather than a file. The live sample preview while building is the exception: it is synchronous, reads no stored rows, and nothing in it can be downloaded.

Running, retries and failure

A worker runs two jobs at a time, polling every couple of seconds for the next queued job and claiming it atomically so two workers never take the same one. Each person may have one report running at a time, and a company ten. A job has at most 2 attempts: a run that crashes or is interrupted is retried once, and a job interrupted more than once is marked failed with "The report could not be generated. It was interrupted more than once. Please try again." A job that runs longer than 20 minutes times out. While a job runs, a heartbeat keeps the claim fresh and pushes a "Still working" progress update. On success the file (or preview JSON) is stored on the job; on failure the reason is kept and shown when the result is collected.

A finished result is kept for 7 days, then cleared. Collecting an expired report returns "That report is no longer available. Please generate it again." Collecting a report that is still running returns "That report is still being generated. Try again once it finishes." In the web app, a failed report shows the server's own message when it sent one; anything else (a dropped connection, an error with no message) shows the page's plain fallback message instead of technical text such as "Network Error" or "Request failed with status code 500".

Privacy and support lookup

A queued report is private to whoever asked for it. Every progress update and the result go only to that person, not the whole company. Support staff working through the Control Panel can look up any report in a company by the reference the person quotes (the job's key) to see its status and request, but never its result file. The download stays owner-only. A support lookup of someone else's report is logged.

Saved reports and the migration of old custom reports

Reports are saved by name (names must be unique within a company) and listed most-recently-changed first. A company can start a new report from a built-in sample (staff list, earnings detail, PAYE, NHF, NHIS, NSITF, union dues, pension by PFA, bank analysis, payroll journal entry, and annual year-to-date versions). The first time a company opens its saved reports, its older employee report builder templates are moved into the new builder automatically, keeping the same people and columns and the original history (who made it, when). A template that cannot be moved cleanly (for example a year-to-date filter with no fixed dates) is left on the old list rather than half-moved, with the reason recorded.

Currencies on payroll reports