(Quick Reference) Service: Update a loading

Description: Returns the updated loading in json format when successful. Returns a json response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/loadings/{id}

URL with external_id:

https://BASE_URL/api/VERSION/loadings/reference/{id}

Method: PUT

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
idThe ID of the desired loadingLong/Stringyes123
reference Stringyes 
warehouseId Long/Stringyes 
typeShould be equal to 1 for loading or 2 for unloadingIntegeryes1,2
reasonIdid of reason with type "3" ( warehouse transaction)Longno 

Loading details parameter :

Parameter name: loadingDetails

Parameter type: a json structure

NameDescriptionTypeRequiredExample values
itemUnitId Longyes 
quantity Integeryes 
serialNumbersList of serial numbers idJSON listno[750,711]
realQtyThe real available quantity in van stock, used when van unloading, by default, it is fixed to the available quantity.integerno20

Serial numbers is only used when van loading

For each loaded item, serial numbers are accepted with only one item unit.

If realQty parameter is specified, system will calculate the availability of requested quantity in relation to the real available quantity in van stock

Example:

{
	"reference": "10Crates",
	"warehouseId": 2,
	"type": 1,
	"loadingDetails": [{
		"itemUnitId": 1,
		"quantity": 10
	}]
}

Success Output

Status: HTTP/1.1 200 OK

{
      "id": 3,
      "reference": "10Crates",
      "warehouseReference": "entrepotA",
      "warehouse": {
        "id": 4,
        "reference": "entrepotA",
        "name": "entrepot A",
        "href": "/api/v1.0/warehouses/4"
      },
      "warehouseType": "1",
      "reason": {
        "id": 2,
        "name": "whse transaction",
        "href": "/api/v1.0/reasons/2"
      },
      "type": "1",
      "status": "1",
      "loadingDetails": [
        {
          "id": 8,
          "itemId": 495,
          "unitId": 1,
          "quantity": 10,
          "realAvailableQty": null,
     	  "availableQty": null,
          "href": "/api/v1.0/loadingDetails/8"
        }
      ],
      "organization": "entity1",
      "dateCreated": "2016-01-25T16:27:33Z",
      "lastUpdated": "2016-01-25T17:27:33Z"
}

Failure Output

Status: HTTP/1.1 404 Not Found

{
  "error": "not_found",
  "error_description": "The loading with the id 707 doesn't exist."
}

{
  "error": "not_found",
  "error_description": "The warehouse with the id 707 doesn't exist."
}

{
  "error": "not_found",
  "error_description": "The reason with the id 25 doesn't exist."
}

{
  "error": "not_found",
  "error_description": "The serial number with the id 1 doesn't exist."
}

Status: HTTP/1.1 400 Bad Request

{
  "error": "not_unique",
  "error_description": "reference already used"
}

{
  "error": "invalid_param_type",
  "error_description": "The type of parameter warehouseId you provided is not valid for this request."
}

{
  "error": "quantity_not_available",
  "error_description": "Quantity should be less than or equal to the available quantity"
}

{
  "error": "invalid_param_type",
  "error_description": "The type of parameter serial number id you provided is not valid for this request."
}

{
  "error": "invalid_serial_status",
  "error_description": "The serial number status with id 2704563 is sold, or already reserved in another loading."
}

{
  "error": "invalid_serial_number",
  "error_description": "The number of serial codes should be equal to the reserved quantity"
}