NextGen APIs

DELETE /work-orders/execution/r1/interventions/resources-accounted-hours

Http Verb

DELETE

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 removes the accounted hours of a resource related to a specific intervention and working hour type.

During the removal, also the record of Total Accounted Hours corresponding to the same resource and working hour type is updated or deleted.

Validations

  1. Check Intervention Validation Status:
    Check if the related intervention validation status record meets the following condition:

    • RescoureAccountedHour.validationStatusId = AUTOMATIC_VALIDATION

    • RescoureAccountedHour.validationStatusId = MANUALLY_VALIDATED

    If yes, return error WORKORDERS_ORCHESTRATOR_013.

  2. Check User Id:

    • Check if the userId of the API call matches with the ResourceAccountedHours.manualLockUserId of the record is intended to delete.

If not, return error WORKORDERS_ORCHESTRATOR_014.

  1. Intervention Status Check:

    • If ResourceAccountedHours.interventionId.workOrderOperationId.workOrderId.status is ALIGNED, CLOSED, or CANCELLED, return error WORKORDERS_ORCHESTRATOR_012..

Business Logic

  1. Total Spent Time Calculation:

    • Retrieve the TotalAccountedHour record with:

      • resourceId = requestBody.resourceId

      • workingHourType = requestBody.workingHourType

      • workOrderOperationId = requestBody.interventionId.workOrderOperationId

    • From the retrieved TotalAccountedHour record get the spentTime field and subtract the value of ResourcedAccountedHour.spentTime. TotalAccountedHour.spentTime goes to zero, the TotalAccountedHour record is deleted. This means that only on ResourcedAccountedHour record was present with same resourceId, workingHourType and workOrderOperationId.

  2. Delete ResourceAccountedHour record:

    • Delete retrieved ResourceAccountedHour record.


Header Parameters

Default.

Query String Parameters

Since it is a DELETE API, there is no request body, but since it is necessary to pass some parameter to identify the record to remove, it has been decided to add them as query params.

Field

Note

interventionId


resourceId


workingHourTypeId


Request Body Parameters

Response documentation

Response payload fields


Response error codes

BASE_0001, WORKORDERS_ORCHESTRATOR_013, WORKORDERS_ORCHESTRATOR_014