iotoms Docs

Close a day cycle

POST
/api/v1/ops/day-cycles/{dayCycleId}/close

Closes the calling salesperson's open day cycle with the closing cash, end odometer reading, location and remarks. Fails if the day is already closed or the end odometer is lower than the start; the vehicle's odometer is updated and a cash-drawer close is logged.

How to use it

  1. Get the open dayCycleId with Get the active day cycle, signed in as the salesperson who started it.
  2. Send the counted closingCash, endOdometerKm (not below the start reading), GPS position and optional remarks.
  3. The day becomes CLOSED and cannot be closed again; the vehicle odometer is updated, a cash drawer close is logged and ops managers are notified.
  4. Stock left on the van is moved back to the default warehouse automatically; if that fails, a VAN_RETURN_TRANSFER_FAILED inventory exception is raised.

Authorization

BearerAuth
headerAuthorizationBearer <JWT>

Path Parameters

dayCycleId*string

ID of the caller's open day cycle, from Get the active day cycle. Only the salesperson who started it can close it.

Formatuuid

Header Parameters

Request Body

application/json
  1. body
closingCash*number

Cash counted at the end of the day, in the merchant's currency. Required.

endOdometerKm*integer

Odometer reading at day close, in kilometres. Required, positive, and not lower than the start reading.

Formatint32
gpsLat*number

Latitude where the day was closed, in decimal degrees. Required.

Formatdouble
gpsLon*number

Longitude where the day was closed, in decimal degrees. Required.

Formatdouble
gpsAccuracyMeters?|

Accuracy of the GPS fix in metres. Optional.

Formatint32
remarks?|

Optional closing notes from the salesperson.

Response Body

OK

*/*
  1. response
status*string

Outcome of the call: SUCCESS when the request worked, ERROR when it did not.

message*string

Short human-readable message describing the result, for logs or display; do not parse it.

data?

The day cycle as it now stands, or null from Get the active day cycle when no day is open.

Example Request
curl -X POST 'https://beta.iotoms.com/api/v1/ops/day-cycles/497f6eca-6276-4993-bfeb-53cbbbba6f08/close' \  -H 'Content-Type: application/json' \  -d '{  "closingCash": 0,  "endOdometerKm": 0,  "gpsLat": 0.1,  "gpsLon": 0.1}'
Example Response
{  "status": "string",  "message": "string",  "data": {    "dayCycleId": "bbed7a30-80be-4ccf-810d-a33c370a67d1",    "businessDate": "2019-08-24",    "status": "OPEN",    "startedAt": "2019-08-24T14:15:22Z",    "closedAt": "2019-08-24T14:15:22Z",    "vehicleLabel": "string",    "vehicleId": "c406adf4-e700-4483-ad7a-e7447a2941cb",    "vehicleType": "VAN",    "openingCash": 0,    "closingCash": 0,    "startOdometerKm": 0,    "endOdometerKm": 0,    "coveragePercent": 0,    "totalStores": 0,    "visitedStores": 0  }}