WORKFORCEOS
FRONTEND GUIDE FOR AI CODING AGENTS - PART 12 - PayrollReporting Service
This document is a part of a REST API guide for the workforceos project. It is designed for AI agents that will generate frontend code to consume the project’s backend.
This document provides extensive instruction for the usage of payrollReporting
Service Access
PayrollReporting service management is handled through service specific base urls.
PayrollReporting service may be deployed to the preview server, staging server, or production server. Therefore,it has 3 access URLs. The frontend application must support all deployment environments during development, and the user should be able to select the target API server on the login page (already handled in first part.).
For the payrollReporting service, the base URLs are:
- Preview:
https://workforceos.prw.mindbricks.com/payrollreporting-api - Staging:
https://workforceos-stage.mindbricks.co/payrollreporting-api - Production:
https://workforceos.mindbricks.co/payrollreporting-api
Tenant URL Prefix and Header Forwarding
Tenant context is resolved by frontend routing strategy:
- preview/test: URL prefix
/{tenantCodename}(example:/babil/products) - production: tenant subdomain (example:
babil.appname...)
Then backend API calls must always claim target tenant with header:
headers["mbx-company-codename"] = tenantCodenameFromUrl;
URL prefix/subdomain is frontend-only tenant selection. Use header forwarding for all tenant-scoped calls to payrollReporting service.
Scope
PayrollReporting Service Description
Handles payroll report records for employees based on calculated hours, overtime, absences from attendance/leave. Provides summary views by user/period/department, allows payment status entry (not processing). Employees can view their own reports. Company tenant scoped and RBAC-enforced.
PayrollReporting service provides apis and business logic for following data objects in workforceos application. Each data object may be either a central domain of the application data structure or a related helper data object for a central concept. Note that data object concept is equal to table concept in the database, in the service database each data object is represented as a db table scheme and the object instances as table rows.
payrollReport Data Object: Represents a calculated payroll report for a single employee and pay period. Contains total hours worked, overtime, absences, calculated salary based on shift attendance, bonuses/deductions, and manual payment status (no actual payment processing).
PayrollReporting Service Frontend Description By The Backend Architect
This service exposes all payroll calculation/reporting logic and APIs for frontend consumption. Payroll reports can be browsed by period, filtered by user/department. Employees see only their own reports; admins/managers may view/filter all for company or department. Payroll calculations always reflect real shift/attendance/leave data; bonus/deduction/payment status can be manually entered. Payroll rows/fields must not be edited except as per permissions, and updates are logged. Provide clear field-level UI and summary breakdowns in UX.
API Structure
Object Structure of a Successful Response
When the service processes requests successfully, it wraps the requested resource(s) within a JSON envelope. This envelope includes the data and essential metadata such as configuration details and pagination information, providing context to the client.
HTTP Status Codes:
- 200 OK: Returned for successful GET, LIST, UPDATE, or DELETE operations, indicating that the request was processed successfully.
- 201 Created: Returned for CREATE operations, indicating that the resource was created successfully.
Success Response Format:
For successful operations, the response includes a "status": "OK" property, signaling that the request executed successfully. The structure of a successful response is outlined below:
{
"status":"OK",
"statusCode": 200,
"elapsedMs":126,
"ssoTime":120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName":"products",
"method":"GET",
"action":"list",
"appVersion":"Version",
"rowCount":3,
"products":[{},{},{}],
"paging": {
"pageNumber":1,
"pageRowCount":25,
"totalRowCount":3,
"pageCount":1
},
"filters": [],
"uiPermissions": []
}
products: In this example, this key contains the actual response content, which may be a single object or an array of objects depending on the operation.
Additional Data
Each API may include additional data besides the main data object, depending on the business logic of the API. These will be provided in each API’s response signature.
Error Response
If a request encounters an issue—whether due to a logical fault or a technical problem—the service responds with a standardized JSON error structure. The HTTP status code indicates the nature of the error, using commonly recognized codes for clarity:
- 400 Bad Request: The request was improperly formatted or contained invalid parameters.
- 401 Unauthorized: The request lacked a valid authentication token; login is required.
- 403 Forbidden: The current token does not grant access to the requested resource.
- 404 Not Found: The requested resource was not found on the server.
- 500 Internal Server Error: The server encountered an unexpected condition.
Each error response is structured to provide meaningful insight into the problem, assisting in efficient diagnosis and resolution.
{
"result": "ERR",
"status": 400,
"message": "errMsg_organizationIdisNotAValidID",
"errCode": 400,
"date": "2024-03-19T12:13:54.124Z",
"detail": "String"
}
PayrollReport Data Object
Represents a calculated payroll report for a single employee and pay period. Contains total hours worked, overtime, absences, calculated salary based on shift attendance, bonuses/deductions, and manual payment status (no actual payment processing).
PayrollReport Data Object Frontend Description By The Backend Architect
A single payroll report instance summarizes one employee’s working period, showing hours, overtime, paid absences, bonus and deduction fields, as well as manual payment status. Employees may view their own reports but only designated payroll admins/managers control updates to payment status. All main hour and absence fields are always calculated from system records—never entered manually. Each instance is uniquely defined by (userId, periodStart, periodEnd).
PayrollReport Data Object Properties
PayrollReport data object has got following properties that are represented as table fields in the database scheme. These properties don’t stand just for data storage, but each may have different settings to manage the business logic.
| Property | Type | IsArray | Required | Secret | Description |
|---|---|---|---|---|---|
userId |
ID | false | Yes | No | Reference to the user/employee this report summarizes (auth:user.id). |
periodStart |
Date | false | Yes | No | Start date of reporting/payroll period (inclusive). |
periodEnd |
Date | false | Yes | No | End date of the reporting/payroll period (inclusive). |
totalHoursWorked |
Double | false | Yes | No | Total hours worked during this period (summed from attendance data, auto-calculated). |
overtimeHours |
Double | false | Yes | No | Total overtime hours for period (auto-calculated from attendance, company policy). |
absenceDays |
Integer | false | Yes | No | Total days absent during period (from leave & attendance). Auto-calculated. |
bonus |
Double | false | No | No | Manual bonus to add for this period (optional entry by admin/manager only). |
deduction |
Double | false | No | No | Manual deduction for this period (optional entry by admin/manager only). |
salaryCalculated |
Double | false | Yes | No | Auto-calculated salary for the period: base salary, hours, overtime, bonuses, and deductions. Always calculated, never direct entry. |
paymentStatus |
Enum | false | Yes | No | Manual entry tracking payment status for this period (‘paid’, ‘unpaid’, ‘partial’, ‘pending’). |
paymentDate |
Date | false | No | No | Manual entry of actual date payment was made for this period (optional, admins/managers only). |
notes |
String | false | No | No | Optional notes (manual, internal)—remark/history on payment changes, bonuses, or irregularities. |
companyId |
ID | false | Yes | No | An ID value to represent the tenant id of the company |
- Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.
Enum Properties
Enum properties are defined with a set of allowed values, ensuring that only valid options can be assigned to them. The enum options value will be stored as strings in the database, but when a data object is created an additional property with the same name plus an idx suffix will be created, which will hold the index of the selected enum option. You can use the {fieldName_idx} property to sort by the enum value or when your enum options represent a hiyerarchy of values. In the frontend input components, enum type properties should only accept values from an option component that lists the enum options.
- paymentStatus: [paid, unpaid, partial, pending]
Relation Properties
userId
Mindbricks supports relations between data objects, allowing you to define how objects are linked together. The relations may reference to a data object either in this service or in another service. Id the reference is remote, backend handles the relations through service communication or elastic search. These relations should be respected in the frontend so that instaead of showing the related objects id, the frontend should list human readable values from other data objects. If the relation points to another service, frontend should use the referenced service api in case it needs related data. The relation logic is montly handled in backend so the api responses feeds the frontend about the relational data. In mmost cases the api response will provide the relational data as well as the main one.
In frontend, please ensure that,
1- instaead of these relational ids you show the main human readable field of the related target data (like name), 2- if this data object needs a user input of these relational ids, you should provide a combobox with the list of possible records or (a searchbox) to select with the realted target data object main human readable field.
- userId: ID
Relation to
user.id
The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.
Required: Yes
Filter Properties
userId periodStart periodEnd paymentStatus companyId
Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria. These properties are automatically mapped as API parameters in the listing API’s.
-
userId: ID has a filter named
userId -
periodStart: Date has a filter named
periodStart -
periodEnd: Date has a filter named
periodEnd -
paymentStatus: Enum has a filter named
paymentStatus -
companyId: ID has a filter named
companyId
Default CRUD APIs
For each data object, the backend architect may designate default APIs for standard operations (create, update, delete, get, list). These are the APIs that frontend CRUD forms and AI agents should use for basic record management. If no default is explicitly set (isDefaultApi), the frontend generator auto-discovers the most general API for each operation.
PayrollReport Default APIs
| Operation | API Name | Route | Explicitly Set |
|---|---|---|---|
| Create | createPayrollReport |
/v1/payrollreports |
Yes |
| Update | updatePayrollReport |
/v1/payrollReports/:payrollReportId |
Yes |
| Delete | none | - | Auto |
| Get | getPayrollReport |
/v1/payrollReports/:payrollReportId |
Yes |
| List | listPayrollReports |
/v1/payrollreports |
Yes |
When building CRUD forms for a data object, use the default create/update APIs listed above. The form fields should correspond to the API’s body parameters. For relation fields, render a dropdown loaded from the related object’s list API using the display label property.
API Reference
Create Payrollreport API
[Default create API] — This is the designated default create API for the payrollReport data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Create a payroll report for a user and period; auto-calculates hours, overtime, absences, salary from attendance/leave. Allowed for admins/managers. Enforces report uniqueness and ownership. Manual entry only allowed for paymentStatus/bonus/deduction/notes (not raw hours/salary).
API Frontend Description By The Backend Architect
This API creates a payroll report for the chosen employee for a pay period, auto-deriving all work hour data from canonical attendance and leave logs. Admins/managers may set payment status, bonus, deduction and notes upon creation, but all time fields are system-calculated. Creating a payroll report when one exists for user/period will update the report (idempotent).
Rest Route
The createPayrollReport API REST controller can be triggered via the following route:
/v1/payrollreports
Rest Request Parameters
The createPayrollReport api has got 8 regular request parameters
| Parameter | Type | Required | Population |
|---|---|---|---|
| userId | ID | true | request.body?.[“userId”] |
| periodStart | Date | true | request.body?.[“periodStart”] |
| periodEnd | Date | true | request.body?.[“periodEnd”] |
| bonus | Double | false | request.body?.[“bonus”] |
| deduction | Double | false | request.body?.[“deduction”] |
| notes | String | false | request.body?.[“notes”] |
| paymentStatus | Enum | false | request.body?.[“paymentStatus”] |
| paymentDate | Date | false | request.body?.[“paymentDate”] |
| userId : The userId for whom to generate the payroll report. | |||
| periodStart : Payroll period start date (inclusive). | |||
| periodEnd : Payroll period end date (inclusive). | |||
| bonus : Optional manual bonus. | |||
| deduction : Optional manual deduction. | |||
| notes : Notes for this payroll report. | |||
| paymentStatus : Manual status (paid, unpaid, partial, pending). | |||
| paymentDate : Manual date of payment, if any. |
REST Request To access the api you can use the REST controller with the path POST /v1/payrollreports
axios({
method: 'POST',
url: '/v1/payrollreports',
data: {
userId:"ID",
periodStart:"Date",
periodEnd:"Date",
bonus:"Double",
deduction:"Double",
notes:"String",
paymentStatus:"Enum",
paymentDate:"Date",
},
params: {
}
});
REST Response
This route’s response is constrained to a select list of properties, and therefore does not encompass all attributes of the resource.
{
"status": "OK",
"statusCode": "201",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "payrollReport",
"method": "POST",
"action": "create",
"appVersion": "Version",
"rowCount": 1,
"payrollReport": {
"user": {
"fullname": "String",
"avatar": "String"
},
"isActive": true
}
}
Update Payrollreport API
[Default update API] — This is the designated default update API for the payrollReport data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Update paymentStatus/paymentDate, bonus, deduction, or notes for a payroll report. All worked hours/absence/salary remain auto-calculated. Only payroll admins/managers allowed. All changes are logged for audit.
API Frontend Description By The Backend Architect
Allows admins/managers to update the payment status, payment date, bonus, deduction, and report notes for an existing payroll period for an employee. No update to hours, absences, or salary is accepted directly (these remain auto-calculated on update). All updates are logged for audit trail. Editing salary must trigger recalculation with new bonuses/deductions if provided.
Rest Route
The updatePayrollReport API REST controller can be triggered via the following route:
/v1/payrollReports/:payrollReportId
Rest Request Parameters
The updatePayrollReport api has got 6 regular request parameters
| Parameter | Type | Required | Population |
|---|---|---|---|
| payrollReportId | ID | true | request.params?.[“payrollReportId”] |
| bonus | Double | false | request.body?.[“bonus”] |
| deduction | Double | false | request.body?.[“deduction”] |
| notes | String | false | request.body?.[“notes”] |
| paymentStatus | Enum | false | request.body?.[“paymentStatus”] |
| paymentDate | Date | false | request.body?.[“paymentDate”] |
| payrollReportId : ID of payroll report to update. | |||
| bonus : Update bonus. | |||
| deduction : Update deduction. | |||
| notes : Update notes. | |||
| paymentStatus : Update payment status. | |||
| paymentDate : Update payment date. |
REST Request To access the api you can use the REST controller with the path PATCH /v1/payrollReports/:payrollReportId
axios({
method: 'PATCH',
url: `/v1/payrollReports/${payrollReportId}`,
data: {
bonus:"Double",
deduction:"Double",
notes:"String",
paymentStatus:"Enum",
paymentDate:"Date",
},
params: {
}
});
REST Response
This route’s response is constrained to a select list of properties, and therefore does not encompass all attributes of the resource.
{
"status": "OK",
"statusCode": "200",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "payrollReport",
"method": "PATCH",
"action": "update",
"appVersion": "Version",
"rowCount": 1,
"payrollReport": {
"user": {
"fullname": "String",
"avatar": "String"
},
"isActive": true
}
}
Get Payrollreport API
[Default get API] — This is the designated default get API for the payrollReport data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Get a specific payroll report and its calculated details for a pay period and employee. Employees may fetch only their own; admins/managers may fetch any for their company.
API Frontend Description By The Backend Architect
Fetches a payroll report for the given id. Enriches response with user (employee) summary, covering total hours, overtime, absences, salary, payment status and optional bonuses/deductions/notes. Employees can’t see reports not their own; admin/manager may fetch any within company.
Rest Route
The getPayrollReport API REST controller can be triggered via the following route:
/v1/payrollReports/:payrollReportId
Rest Request Parameters
The getPayrollReport api has got 1 regular request parameter
| Parameter | Type | Required | Population |
|---|---|---|---|
| payrollReportId | ID | true | request.params?.[“payrollReportId”] |
| payrollReportId : ID of payroll report to fetch. |
REST Request To access the api you can use the REST controller with the path GET /v1/payrollReports/:payrollReportId
axios({
method: 'GET',
url: `/v1/payrollReports/${payrollReportId}`,
data: {
},
params: {
}
});
REST Response
This route’s response is constrained to a select list of properties, and therefore does not encompass all attributes of the resource.
{
"status": "OK",
"statusCode": "200",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "payrollReport",
"method": "GET",
"action": "get",
"appVersion": "Version",
"rowCount": 1,
"payrollReport": {
"user": {
"fullname": "String",
"avatar": "String"
},
"isActive": true
}
}
List Payrollreports API
[Default list API] — This is the designated default list API for the payrollReport data object. Frontend generators and AI agents should use this API for standard CRUD operations.
List payroll reports for employees. Employees can view their own; managers/admins can filter and list by user/period/department for the company.
API Frontend Description By The Backend Architect
Lists all payroll reports accessible to the calling user in their company scope. Employees see only their own payroll history; company admins/managers can filter by user, payroll period, payment status for reporting or payroll review. Supports pagination and can be enriched per-user/department via selectJoin.
Rest Route
The listPayrollReports API REST controller can be triggered via the following route:
/v1/payrollreports
Rest Request Parameters
The listPayrollReports api has got 4 regular request parameters
| Parameter | Type | Required | Population |
|---|---|---|---|
| userId | ID | false | request.query?.[“userId”] |
| periodStart | Date | false | request.query?.[“periodStart”] |
| periodEnd | Date | false | request.query?.[“periodEnd”] |
| paymentStatus | Enum | false | request.query?.[“paymentStatus”] |
| userId : Filter by employee userId. | |||
| periodStart : Filter period - date on or after | |||
| periodEnd : Filter period - date on or before | |||
| paymentStatus : Filter by payment status. |
REST Request To access the api you can use the REST controller with the path GET /v1/payrollreports
axios({
method: 'GET',
url: '/v1/payrollreports',
data: {
},
params: {
userId:'"ID"',
periodStart:'"Date"',
periodEnd:'"Date"',
paymentStatus:'"Enum"',
}
});
REST Response
This route’s response is constrained to a select list of properties, and therefore does not encompass all attributes of the resource.
{
"status": "OK",
"statusCode": "200",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "payrollReports",
"method": "GET",
"action": "list",
"appVersion": "Version",
"rowCount": "\"Number\"",
"payrollReports": [
{
"user": [
{
"fullname": "String",
"avatar": "String"
},
{},
{}
],
"isActive": true
},
{},
{}
],
"paging": {
"pageNumber": "Number",
"pageRowCount": "NUmber",
"totalRowCount": "Number",
"pageCount": "Number"
},
"filters": [],
"uiPermissions": []
}
After this prompt, the user may give you new instructions to update the output of this prompt or provide subsequent prompts about the project.