# Stock products

#### 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.

<table><thead><tr><th width="157">Delivery events</th><th width="114">chargeNumber</th><th width="140">orderedQuantity</th><th width="125">remainingQuantity</th><th width="95">quantity</th><th>chargeState</th></tr></thead><tbody><tr><td><strong>An order is registered</strong></td><td>C-000001</td><td>30</td><td>30</td><td>null</td><td><code>new</code></td></tr><tr><td>Partial <strong>delivery of 4 on C-000001</strong></td><td>C-000001</td><td>30</td><td>26</td><td>4</td><td><code>partialDelivery</code></td></tr><tr><td></td><td>C-000002</td><td>null</td><td>26</td><td>null</td><td><code>partialDelivery</code></td></tr><tr><td><strong>A new partial delivery of 10 on C-000002</strong></td><td>C-000001</td><td>30</td><td>26</td><td>4</td><td><code>partialDelivery</code></td></tr><tr><td></td><td>C-000002</td><td>null</td><td>16</td><td>10</td><td><code>partialDelivery</code></td></tr><tr><td></td><td>C-000003</td><td>null</td><td>16</td><td>null</td><td><code>partialDelivery</code></td></tr><tr><td><strong>A last closing delivery of the remaining amount of 16 is made on C-000003</strong></td><td>C-000001</td><td>30</td><td>26</td><td>4</td><td><code>partialDelivery</code></td></tr><tr><td></td><td>C-000002</td><td>null</td><td>16</td><td>10</td><td><code>partialDelivery</code></td></tr><tr><td></td><td>C-000003</td><td>null</td><td>0</td><td>16</td><td><code>ClosedPartalDelivery</code></td></tr></tbody></table>

#### **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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.younium.com/documentation/stock-products.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
