|
Http Verb |
POST |
|---|---|
|
Url |
/work-orders/execution/r1/interventions/{interventionId}/arrival-on-site |
|
Permissions required |
|
|
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 sets the arrival date of a work order operation using its intervention Id.
The arrival date must be set after the intervention has been taken charge of. You can take charge of the intervention using this API: POST /work-orders/execution/r1/interventions/{interventionId}/taking-charge
In a team scenario, assistants follow the same rules as the foreman, but their intervention information is linked to the foreman's intervention.
The result of this API call can be viewed by calling GET /work-orders/execution/r1/interventions/outcomes/{outcomeId}and passing the intervention Id as the outcome Id in the path parameter.
It is possible to skip this step in the intervention process and directly call the following API POST /work-orders/execution/r1/interventions/{interventionId}/outcomes
Steps
Retrieve Intervention
We will refer to interventionFromInputId as the intervention record with intervention.id equal to interventionId provided in the path parameter of this API.
Example:
-
interventionFromInputId.statusIdwill be thestatusIdfield of the intervention withidequal tointerventionId. -
interventionFromInputId.outcomewill be the Intervention outcome of the intervention withidequal tointerventionId, that can be retrieved by calling GET /work-orders/execution/r1/interventions/outcomes/{outcomeId} .
-
Validate Intervention Status
-
Check if
interventionFromInputId.statusIdis ‘IN_CHARGE’.-
If not, return the error EXECUTION_002.
-
-
Check if
interventionFromInputId.workOrderOperationIdis null.-
If yes, return the error WORKORDERS_ORCHESTRATOR_006.
-
-
If
interventionFromInputId.outcome.takeInChargeDate != null,interventionFromInputId.outcome.takeInChargeDate < arrivalOnSiteDate:-
if not, return the error EXECUTION_004.
-
-
Check if
arrivalOnSiteDate < Date.now() + 1(it should be at most a date in the present, not in the future):-
if not return the error BASE_0016.
-
-
Check if workOrderHeader.isWoByOrder())
-
If TRUE ->operation.getParentOperation() != null → you can take in charge an intervention only if it is the one of the parent operation
-
if not return the error EXECUTION_005.
-
-
-
Handle Existing Interventions
-
Search for all intervention records associated with the same resource with
statusIdvalues ‘IN_CHARGE' or 'IN_EXECUTION’ andworkOrderOperationIdnot equal tointerventionFromInputId.workOrderOperationId -
We will refer to this list of intervention records as
interventionsToBeDeleted. -
For each
interventionin theinterventionsToBeDeletedlist:-
Set
intervention.arrivalDateto null -
Set
intervention.takeInChargeDateto null -
Set
intervention.startDateto null -
Change
intervention.statusIdto ‘SUBMITTED’ by passing the ‘SUBMIT’ action. -
Update
intervention.workOrderOperationId.statusId -
Update
intervention.workOrderOperationId.workOrderId.statusId -
Retrieve all records of
resourceAccountedHourentity withresourceAccountedHour.interventionIdequal tointervention.idandresourceAccountedHour.outcomeEndDateequal to null.-
For each record, set:
-
resourceAccountedHour.takeInChargeto null -
resourceAccountedHour.arrivalDateto null -
resourceAccountedHour.outcomeStartDateto null
-
-
-
-
-
Take In Charge the Intervention
-
If
interventionFromInputId.outcome.arrivalDateis null:-
Set
interventionFromInputId.outcome.arrivalDate=arrivalOnSiteDate -
If not, set
interventionFromInputId.outcome.takeInChargeDateequal tointerventionFromInputId.outcome.takeInChargeDateand setworkOrderOperationIDoperation.outcome.PdaLastArrivalDateequal tointerventionFromInputId.outcome.takeInChargeDate
-
-
If
interventionFromInputId.outcome.takeInChangeDateis null:-
Set
interventionFromInputId.outcome.takeInChangeDate=arrivalOnSiteDate
-
-
If
company.fsm.accounting.emptyAgendaResourceDeletionproperty is enabled, remove all emptyresourceAccountedHourassociated with the sameinterventionFromInputId, they will be removed ifresourceAccountedHour.spentTime,resourceAccountedHour.takeInChargeDateare null and ifresourceAccountedHour.resourceis different from the resource associated with theinterventionFromInputId -
Set
interventionFromInputId.statusIdto 'IN_EXECUTION' using the action 'ARRIVAL_ON_SITE'. -
Update
interventionFromInputId.workOrderOperationId.statusId -
Update
interventionFromInputId.workOrderOperationId.workOrderId.statusId
-
Header Parameters
Default.
Request Body Parameters
|
Field |
Validations |
Note |
|---|---|---|
|
arrivalOnSiteDate |
|
|
Response documentation
Response payload fields
Response error codes
NOT_FOUND, BASE_0001, BASE_0003, BASE_0010, BASE_0011, BASE_0016, WORKORDERS_ORCHESTRATOR_006 EXECUTION_002, EXECUTION_004