# Package Packed for Refund Command

## <mark style="color:red;">Actors</mark>​ <a href="#actors" id="actors"></a>

* Akinon Order Management System (OMS)
* Akinon Omnitron System
* Integrated Application (ERP)

## <mark style="color:red;">Domain Objects​</mark> <a href="#domain-objects" id="domain-objects"></a>

* Packaging Order
* OMS Command (Packaging Order Command)

### <mark style="color:red;">Source and Target States for Use of Command​</mark> <a href="#source-and-target-states-for-use-of-command" id="source-and-target-states-for-use-of-command"></a>

PackagePackedForRefundCommand is used only for the following status transitions.

| Source Status | Enum Value | Target Status     | Enum Value |
| ------------- | ---------- | ----------------- | ---------- |
| Waiting       | 100        | Packed for Refund | 1100       |
| Out of Stock  | 920        | Packed for Refund | 1100       |

### <mark style="color:red;">Process</mark>​ <a href="#process" id="process"></a>

1. The OMS application copies orders from the Akinon Omnitron Application to itself to prepare delivery/distribution plans, generate packaging orders and transfer them to operation points.
2. The products in the order are distributed to the Packaging Orders by running the rules in the distribution scenarios designated by the brand.
3. Packaging Orders are transferred to the Akinon Instore App or the brand’s integrated software. (Packaging Orders Webhooks)
4. Packaging orders assigned to the Store/Warehouse commence in the Waiting or Out of Stock status. A package in the Waiting status may then be moved to the Out of Stock status by the store.
5. When packaging is being prepared for a refund, the transition to the Packed for Refund status is made by using the screens in the Akinon Instore application or when another piece of software that has been integrated into the OMS application triggers the predefined PackagePackedForRefundCommand. During this process:
   * Package record is moved to packed for refund
   * PackageItem record is moved to packed for refund
6. If the package source status is set to waiting, the reservations of the products in the package are deleted. Any discrepancy records are also deleted.
7. If the `sync_remote_order_status`parameter is not set to false during status transition, Omnitron is informed for orderitems with moved status records.
8. If there is a record in the `package.status.packed_for_refund` event type in the information services, webhook information stating that the package has been packed is sent to the defined URL address.

### <mark style="color:red;">Command Parameters and Prerequisites​</mark> <a href="#command-parameters-and-prerequisites" id="command-parameters-and-prerequisites"></a>

For each packaging order:

| Parameter             | Parameter Name | Parameter Type | Parameter Description                         | Requirement                                |
| --------------------- | -------------- | -------------- | --------------------------------------------- | ------------------------------------------ |
| Packaging Order ID    | package        | integer        | Dynamic for each order                        | Mandatory                                  |
| Command Transition ID | transition     | integer        | Prepared and reported during OMS installation | Optional if slug is given                  |
| Slug                  | slug           | slug           | Unique slug for stste transition              | Optional if Command Transition ID is given |

**Regardless of scenarios, the process of lowering and raising quotas continues, the quota amount continues to increase and decrease on a location basis. However, for these alterations to impact planning, the scenario rules must have the SELECT\_BY\_QUOTA value.**

* The maximum quota value specifies how many packages can be created from the respective location. The quota value is a user-unspecified parameter used for monitoring the maximum quota value and performing increase or decrease operations.
* max\_quota - quota = available\_quota
* If the available\_quota value is 0, no packages can be created. (To encounter this scenario, the SELECT\_BY\_QUOTA value must be chosen in the scenario rules.)
* For packages with a status below 400 and in the cancellation\_waiting state, the quota value increases by 1. (During this stage, when the package is in the waiting state, the quota amount is considered to increase by 1.)
* Upon packaging a package, the quota value decreases by 1. Consequently, the available\_quota increases, enhancing the likelihood of packaging from the respective location.
* In the event of a package cancellation, the quota amount decreases by 1 in a similar way.

***

### <mark style="color:red;">`POST`</mark> <mark style="color:red;">Package Packed for Refund​</mark> <a href="#post-package-packed-for-refund" id="post-package-packed-for-refund"></a>

**Path:** `https://{customer_api_url}-oms.akinon.net/api/v1/oms/packages/{package_id}/command/`

* ***Package ID***: XXX
* ***Transition ID***: NNN (set after OMS installation)
* ***Slug***: SSS (Unique Slug Value)

**Request Body​**

```
{
  "transition": NNN,
  "slug": SSS,
  "package": XXX
}
```

**Successful Response​**

**Status Code:** `204 No Content`
