# Managing Deliveries

Every Order needs to have at least one Delivery with at least one DeliveryLineItem. A Delivery is a frame that specifies:

  • A desired delivery date
  • A delivery location
  • Which OrderLineItems and in which quantity should be delivered using the previously mentioned parameters. They will be defined using DeliveryLineItems.

As such it is necessary to create at least one Delivery and add specific line items to it by also creating DeliveryLineItems.

❗️ Orders that use the delivery mode complete don't need to specify their DeliveryLineItems individually. In that case we will create one DeliveryLineItem for each OrderLineItem of the order.

❗️ If using the delivery mode splitted all OrderLineItems of a given order and their full amounts need to be defined within Deliveries and their DeliveryLineItems for the order to be placeable

# Delivery Endpoints

In order to list, create, modify or delete a Delivery you need to use the following endpoints:

Endpoint Description
GET /orders/{order_id}/deliveries (opens new window) Returns all deliveries of the order with the respective order_id
GET /deliveries/{delivery_id} (opens new window) Returns the delivery with the respective delivery_id
POST /orders/{order_id}/deliveries (opens new window) Create a delivery attached to the order with the respective order_id
PATCH /deliveries/{delivery_id} (opens new window) Modify the delivery with the respective delivery_id
DELETE /deliveries/{delivery_id} (opens new window) Deletes the delivery with the respective delivery_id

# Delivery Attributes

Attribute Required Description
address_addressee
If no site is provided
The addressee of the delivery

Will be ignored if a site_id is provided
address_text
If no site is provided
The desired delivery address

Will be ignored if a site_id is provided
site_id The site that the delivery should be delivered to.
desired_delivery_date The desired delivery date for the delivery

If no value is provided the desired delivery date is as soon as possible.
delivery_line_items_attributes Delivery Line Items can be specified here already
references If you want, you can add additional references here, e.g. an internal delivery number.

By default it will include the Zaikio Procurement DeliveryId as the first element.

# Example: Create a delivery

The following request will create a new delivery for the order with the id: ab3a75a5-330e-5070-addf-bcd3f225e12e and the following criteria:

  • Desired Delivery Date shall be the 20-10-2021
  • The delivery should be delivered to Test Company, Test Street 1, 55155 Test-City
  • The delivery should include the OrderLineItem with the id: 3fa85f64-5717-4562-b3fc-2c963f66afa6 and an amount of 10

# Request

POST /orders/ab3a75a5-330e-5070-addf-bcd3f225e12e/deliveries

Body:
{
  "delivery": {
    "address_addressee": "Test Company",
    "address_text": "Test Street 1, 55155 Test-City",
    "desired_delivery_date": "20-10-2021",
    "delivery_line_items_attributes": [
      {
        "order_line_item_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "amount": 10
      }
    ]
  }
}

# Delivery Line Item Endpoints

In order to list, create, modify or delete DeliveryLineItems of any Delivery, you need to use the following endpoints:

❗️ As mentioned above already, you do not need to use these endpoint if your order is using the complete delivery mode

Endpoint Description
GET /deliveries/{delivery_id}/delivery_line_items (opens new window) Returns all delivery line items of the delivery with the provided delivery_id
GET /delivery_line_items/{delivery_line_item_id} (opens new window) Returns the delivery line item with the provided delivery_line_item_id
POST /deliveries/{delivery_id}/delivery_line_items (opens new window) Create a delivery line item attached to the delivery with the provided delivery_id
PATCH /delivery_line_items/{delivery_line_item_id} (opens new window) Modify the delivery line item with the provided delivery_line_item_id
DELETE /delivery_line_items/{delivery_line_item_id} (opens new window) Deletes the delivery line item with the provided delivery_line_item_id

# Delivery Line Item Attributes

Attribute Required Description
order_line_item_id The OrderLineItem that should be added to the DeliveryLineItem.

Needs to be a valid OrderLineItem of the Order that the Delivery belongs to.
amount The desired amount of the OrderLineItem

# Example: Create a delivery line item

The following request will create a new delivery line item for the delivery with the id: 0d73a950-481c-4e0e-ba3f-73c707f08ccb and the OrderLineItem with the id: 3fa85f64-5717-4562-b3fc-2c963f66afa6 with an amount of 10.

# Request

POST /deliveries/0d73a950-481c-4e0e-ba3f-73c707f08ccb/delivery_line_items

Body:
{
  "delivery_line_item": {
    "order_line_item_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "amount": 10
  }
}