Stock products

Guide on how to work with stock products using the AP v2

Stock Product Charges Overview

A stock product is defined by a set of charges, characterized by:

  • Charge Type: OneOff

  • Price Model: Quantity

Each product has one or more charges, especially if it is partially delivered. The delivery status is defined by certain fields:

  • ChangeState: Reflects the delivery status in the UI with values such as:

    • New

    • PartialDelivery

    • ClosedPartialDelivery

  • orderedQuantity: Set only with the first charge, indicating the total quantity ordered.

  • Quantity: Shows the delivered quantity. An undelivered charge will have no specified quantity.

  • RemainingQuantity: Indicates the quantity yet to be delivered.

  • Modified and Created

Delivery and Partial Deliveries

When a delivery is made, it affects the charge currently open for delivery. In cases of partial delivery, a new charge is created to reflect the remaining quantity pending delivery. The example below illustrates how charges are impacted by delivery events and their grouped results after each delivery event. null is the UI will be represented as an empty field.

Delivery events
chargeNumber
orderedQuantity
remainingQuantity
quantity
chargeState

An order is registered

C-000001

30

30

null

new

Partial delivery of 4 on C-000001

C-000001

30

26

4

partialDelivery

C-000002

null

26

null

partialDelivery

A new partial delivery of 10 on C-000002

C-000001

30

26

4

partialDelivery

C-000002

null

16

10

partialDelivery

C-000003

null

16

null

partialDelivery

A last closing delivery of the remaining amount of 16 is made on C-000003

C-000001

30

26

4

partialDelivery

C-000002

null

16

10

partialDelivery

C-000003

null

0

16

ClosedPartalDelivery

Order version and status

Fetching Sales Orders and Subscriptions

The API endpoints used for fetching sales orders and subscriptions always retrieve the latest version. The handling of stock products is consistent across both; the distinction lies in how order statuses are managed.

  • Sales Orders: A sales order with a delivered stock product, whether open or closed, will have a status of partiallyDelivered.

  • Subscriptions: A subscription containing a stock product remains unchanged by deliveries.

To obtain detailed information about deliveries and their status, refer to the related order charges.

Cases to help parse information from the API.

Identify if a partial delivery is closed?

  • If any of the charges have changeState ClosedPartalDelivery

  • This charge will also have a remainingQuantity value of 0 and the quantity equal to the amount that was last delivered.

Identify if a charge is open for delivery?

  • If any of the charges have no quantity, meaning the quantity is null. Tt’s open to being delivered and the remainingQuantity will be the remaining amount that can be delivered.

Identify if no deliveries have been made?

  • There will be only one charge with changeState new and with no quantity.

  • orderedQuantity also equals remainingQuantity

Identify how many deliveries were made?

  • The number of deliveries will be the same as the number of charges, with a quantity that’s not null

Identify the total quantity that’s been delivered?

  • It is the same as the sum of all charges quantity.

  • If this sum equals orderedQuantity. This means all have been delivered

Last updated

Was this helpful?