|
Http Verb |
POST |
|---|---|
|
Url |
/work-orders/execution/r1/interventions/{interventionId}/taking-charge |
|
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 take in charge a work order operation by its intervention id.
A user can handle only one intervention at a time. If the user has already taken charge another intervention, this one will be reverted to its previous state (SUBMITTED)
Please note that the "taking in charge" action is exclusively performed by the foreman of the intervention. While the assistants in the team will have access to the details of the intervention, they will not take charge of it; only the foreman holds that responsibility.
In a team scenario, assistants follow the same rules as the foreman, but their intervention information are 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.
Examples:
-
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 one of ‘OPEN’, ‘FIXED’, ‘SUBMITTED’, or ‘ACCEPTED’.-
If not, return the error EXECUTION_002.
-
-
Check if
interventionFromInputId.workOrderOperationIdis null.-
If yes, return the error WORKORDERS_ORCHESTRATOR_006.
-
-
Check if Core System Setting field
"Outcome Minimum Date" < takeInChargeDate:-
if not, return the error EXECUTION_003.
-
-
Check if
takeInChargeDate < 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.outcome.arrivalDateto null -
Set
intervention.outcome.takeInChargeDateto null -
Set
intervention.outcome.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.outome.takeInChargeDateis null:-
Set
interventionFromInputId.outome.takeInChargeDateto the inputtakeInChargeDate -
If not, set
interventionFromInputId.outome.takeInChargeDateequal tointerventionFromInputId.outcome.takeInChargeDate(we leave it as it was) and setinterventionFromInputId.workOrderOperationId.lastPdaTakeInChargeDateequal tointerventionFromInputId.takeInChargeDate
-
-
Set
interventionFromInputId.statusIdto 'IN_CHARGE' using the action 'TAKE_IN_CHARGE'. -
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 -
Update
interventionFromInputId.workOrderOperationId.statusId -
Update
interventionFromInputId.workOrderOperationId.workOrderId.statusId
-
Header Parameters
Default.
Request Body Parameters
|
Field |
Validations |
Note |
|---|---|---|
|
takeInChargeDate |
|
|
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_003