|
Http Verb |
POST |
|---|---|
|
Url |
/work-orders/execution/r1/interventions/resources-accounted-hours |
|
Permissions required |
Work Order Accounting Edit: fsm.core.workorder.accounting.edit |
|
Personally Identifiable Information (PII) |
No |
|
Sensitive Information |
No |
|
Last Modified Version |
r1 |
|
Released since |
2024 W3 (FSM 18.0) |
|
Deprecated since |
|
|
Removed since |
|
|
Tech Tags |
PAGINATION ORDERING-SERVER-SIDE |
Business Logic
This API saves the accounted hours of a resource related to a specific intervention.
Related APIs
-
Search Interventions: GET /work-orders/execution/r1/interventions
-
Search Resources: GET /workforce/resources/r1/resources
-
Search Existing Accounted Hours: GET /work-orders/execution/r1/interventions/resources-accounted-hours
-
Search Total Accounted Hours: GET /work-orders/execution/r1/interventions/total-accounted-hours
Validations
-
Duplicate Record Check:
Check if aResourceAccountedHoursrecord exists with:-
resourceId = requestBody.resourceId -
interventionId = requestBody.interventionId -
workingHourType = requestBody.workingHourType
If such a record exists, return error WORKORDERS_ORCHESTRATOR_010.
-
-
Spent Time Validation:
-
If
requestBody.lockSpentTime = trueandrequestBody.spentTime = null, return error WORKORDERS_ORCHESTRATOR_011. -
If
requestBody.lockSpentTime = trueandrequestBody.spentTime != null, the fieldsrequestBody.outcomeStartDateandrequestBody.outcomeEndDatewill be ignored by the business logic. In this case, theResourceAccountedHours.manualLockUserIdwill be assigned to the user making the API request. -
Otherwise, calculate a new
spentTimeby subtractingrequestBody.outcomeStartDatefromrequestBody.outcomeEndDate.
-
-
Intervention Status Check:
-
If
ResourceAccountedHours.interventionId.workOrderOperationId.workOrderId.statusisALIGNED,CLOSED, orCANCELLED, return error WORKORDERS_ORCHESTRATOR_012..
-
-
Date Validations:
-
If
requestBody.outcomeStartDateis null, return error BASE_0003. -
If
requestBody.outcomeEndDateis null, return error BASE_0003. -
If
requestBody.outcomeStartDate >= requestBody.outcomeEndDate, return error BASE_0012. -
If
requestBody.arrivalOnSiteDateis null orrequestBody.arrivalOnSiteDate > requestBody.outcomeStartDate, return error BASE_0012. -
If
requestBody.takeInChargeDateis null orrequestBody.takeInChargeDate > requestBody.arrivalOnSiteDate, return error BASE_0012. -
If
requestBody.takeInChargeDate < systemSettings.outcomeMinDate, return error BASE_0012. -
If
requestBody.outcomeEndDateis later than today, return error BASE_0012.
-
Business Logic
-
Total Spent Time Calculation:
-
Retrieve the
TotalAccountedHourrecord (if it exists) with:-
resourceId = requestBody.resourceId -
workingHourType = requestBody.workingHourType -
workOrderOperationId=requestBody.interventionId.workOrderOperationId
-
-
Add the
spentTime(from the request payload or calculated) to theTotalSpentTime.spentTime. -
If no record exists, create a new one with the fields
resourceId,workOrderOperationId,workingHourType, andspentTimepopulated.
-
-
Work Shift Check:
-
Search for a
WorkShiftrecord with:-
WorkShift.resourceId = requestBody.resourceId -
requestBody.takeInChargeDate < WorkShift.startDate < requestBody.takeInChargeDate + 1
-
-
If a record is found, set
ResourceAccountedHours.workShiftId = retrievedWorkShiftId.
-
Header Parameters
Default.
Request Body Parameters
|
Field |
Validations |
Note |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Response documentation
Response payload fields
|
Field |
Note |
|---|---|
|
id |
|
Response error codes
BASE_0001, BASE_0003, BASE_0012, WORKORDERS_ORCHESTRATOR_010, WORKORDERS_ORCHESTRATOR_011, WORKORDERS_ORCHESTRATOR_012,