# Working Logic of Scenarios

## <mark style="color:red;">Step 1: The Functioning of an Appropriate Scenario</mark>​ <a href="#step-1-the-functioning-of-an-appropriate-scenario" id="step-1-the-functioning-of-an-appropriate-scenario"></a>

In OMS, various scenarios can operate based on the order's channel information, shipping details, payment method, and customer type.

For creating a scenario for orders placed through a specific channel:

* The **Channel Condition Type** needs to be static, and the required channel information should be included.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2Fn2uJHqfXxnPtxRjbDdjh%2Fimage1%20(1).png?alt=media&#x26;token=d271266d-4787-42e6-939a-4c2802a99fc3" alt="" width="563"><figcaption></figcaption></figure>

To create a scenario for orders from all order channels;

* Simply select the **Channel Condition Type** as **Dynamic**.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FcTGmFEEkvt8k2PlQXE2T%2Fimage2.png?alt=media&#x26;token=ccd74b15-8a88-421a-b29c-3a657d129ba0" alt="" width="563"><figcaption></figcaption></figure>

For orders from all order channels but with a specific shipping company, you can create a scenario like in the example:

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FjPi98acHlNhC5UJU8kiQ%2Fimage.png?alt=media&#x26;token=38f53183-259e-4c38-9edf-387c80765a2b" alt="" width="563"><figcaption></figcaption></figure>

Orders from a specific order channel and with a particular shipping company can have a scenario created as shown below:

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F3AleDuifRO2m8ryNlKZR%2Fimage.png?alt=media&#x26;token=f8e67584-942c-4c2e-a58e-b71cc1debd90" alt="" width="563"><figcaption></figcaption></figure>

## <mark style="color:red;">Step 2: Adding Stock Locations To Rules​</mark> <a href="#step-2-adding-stock-locations-to-rules" id="step-2-adding-stock-locations-to-rules"></a>

* Packages can be created at locations entered in the Stock Location List.
* Packages can be generated at locations excluding those entered in the “Except Stock Location”.
* Packages can be created at locations in the same country/state/district/neighborhood as the order address based on the location type.
  * For this option to function correctly, the **OMS > Application Settings > GEOLOCATION\_DISCOVERY** and **GEOCODE\_PROVIDER\_SETTINGS** settings need to be included.
* Packages can be created at locations of the entered type with the Stock Location Type. For instance, when a store is selected, packages will form only at locations classified as stores, and when a warehouse is chosen, packages will form exclusively at locations labeled as warehouses.

## <mark style="color:red;">Step 3: Stock Location Ranking​</mark> <a href="#step-3-stock-location-ranking" id="step-3-stock-location-ranking"></a>

* It can be sorted in increasing/decreasing order based on importance.
* It can be sorted in increasing/decreasing order based on the stock amount returned from stores.
* It can be sorted in increasing/decreasing order based on the package density in stores.
* It can be sorted in increasing/decreasing order based on the distance from stores to delivery addresses.
  * For this option to function properly, the **Application Settings > GEOLOCATION\_DISCOVERY** and **GEOCODE\_PROVIDER\_SETTINGS** settings need to be included.
* Multiple sorting options can be added here. For instance, in the provided sorting, locations are arranged initially by importance and then by package density.<br>

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FaWfGmZhXH5Ens1QunpFi%2Fimage.png?alt=media&#x26;token=aa8892a9-f425-480e-a44a-6537e206ea06" alt="" width="563"><figcaption></figcaption></figure>

### <mark style="color:red;">OMS Scenario Examples​</mark> <a href="#oms-scenario-examples" id="oms-scenario-examples"></a>

#### <mark style="color:red;">Creating Single Package in the Warehouse​</mark> <a href="#creating-single-package-in-the-warehouse" id="creating-single-package-in-the-warehouse"></a>

* **Rule Name:** It could be "Bulk Packaging in the Warehouse" or "Single Package Creation in the Warehouse."
* The option for **Suitable for partial shipment** should **not** be checked.
* Only the **Warehouse** location should be added to the stock location list.
* The Warehouse location should be marked as the Packaging Center on the Stock Location Details page.
* Even if only one location is added, the location sequence should be selected. It can be sorted in increasing order of importance.
* After creating the rule, click on **Save Rule** and then on **Save Scenario**.
* The example of the rule can be found below:

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FCqiS3Tag8wFuxIbDXgTl%2Fimage.png?alt=media&#x26;token=bc8a7669-37f1-4927-a67f-41a7c964999b" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">Creating Single Package in the Store​</mark> <a href="#creating-single-package-in-the-store" id="creating-single-package-in-the-store"></a>

* **Rule Name**: It could be "Bulk Packaging in the Store" or "Single Package Creation in the Store."
* The option for **Suitable for partial shipment** should **not** be checked.
* **Only the desired stores where packaging is required** should be added to the stock location list.
* The added stores should be marked as the Packaging Center on the Stock Location Details page.
* Multiple stores can be added to this list. If the entire stock returns in a package from a specific store, OMS will create the package in that store.
* Since multiple stores are added, the location sequence should be selected. It can be sorted in increasing order of importance.
* After creating the rule, click on **Save Rule** and then on **Save Scenario**.
* The example of the rule can be found below:

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FcbzEJC0VIgL7EvQSl3xB%2Fimage.png?alt=media&#x26;token=541591f3-48b7-4064-8f81-abbd68072ad3" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">**Creating Partial Packages in the Store/Warehouse**</mark>

* **Rule Name:** It could be Partial Package Creation.
* The option for **Suitable for partial shipment** should be **checked**.
* **The desired stores where packaging is required** should be added to the stock location list.
* The added stores should be checked as the Packaging Center on the Stock Location Details page.
* Multiple stores can be added to this list. The logic behind this rule works as follows:
  * In a case where, 3 products are in the order.
  * Suppose Warehouse + Store 1 are added to the rule.
  * Consider that for two of the products in the order, stock is available in the warehouse, and for the remaining one, stock is available at Store 1 location.
  * In this scenario, when this rule works during the planning step, it will create Package P1 (2 products) in the warehouse and Package P2 (1 product) at Store 1 location.
* Since multiple stores are added, the location sequence should be selected. It can be sorted in increasing order of importance.
* After creating the rule, click on **Save Rule** and then on **Save Scenario**.
* The example of the rule can be found below:

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FnrbajFrVzMnbznkUVpa8%2Fimage.png?alt=media&#x26;token=f3b61e43-541f-4463-95b3-db3484184f7a" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">Product/Base Code-based Packaging​</mark> <a href="#productbase-code-based-packaging" id="productbase-code-based-packaging"></a>

This field is used when running a rule for specific products within an order. First, the condition type needs to be selected. There are two options for the condition type:

1. **SKU:** SKU numbers of specific products to be separately planned should be entered. Multiple SKU numbers can be entered.
2. **Product Base Code:** Base code numbers of specific products intended for separate planning should be entered. Multiple base code numbers can be entered.

For the rule to function as intended, the Partial Packaging option should also be **checked**. Additionally, the specific locations where these products are intended to be planned should be added to the stock location list.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F8tUhaapm0pQIDK12IbbY%2Fimage.png?alt=media&#x26;token=6cd212a8-cc6a-4025-a2be-a3df0aa7c2fb" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F1iI0ad3HKyZrFIeCtNng%2Fimage.png?alt=media&#x26;token=85098af4-8123-4a5c-a350-4bb87b95fc78" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">Product Preconditions​</mark> <a href="#product-preconditions" id="product-preconditions"></a>

This field is used to run a rule for bundle products within an order. There are three options available here:

1. **All Products**: This is the default value.
2. **Only Bundled Products:** Regardless of whether partial packaging is marked for bundled products within the order, they are still taken out from the same location.
3. **Excluding Bundled Products:** Even if partial packaging is marked for non-bundled products within the order, they are still taken out from the same location.
4. **Only Trade-in Products:** It excludes products marked for trade-in within the order. To use this condition, the **Application Settings > IS\_TRADEIN\_ENABLED** setting must be set to true.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FqvP27g8rj43DNkAbHInK%2Fimage.png?alt=media&#x26;token=e6e86f50-d629-44bc-b79a-41f3f48c5d96" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">Packing Marketplace Orders​</mark> <a href="#packing-marketplace-orders" id="packing-marketplace-orders"></a>

These rules are established for packaging orders from platforms like Trendyol, Hepsiburada, Amazon, Morhipo, and similar marketplaces.

The same scenario rules can be applied for orders coming from these channels, and the logic remains consistent. There are two key points to be noted:

1. The scenario should be selected according to the order channel, specifically as the marketplace channel.\
   ![](https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F2kwFcNXe3DuCygRbkQrF%2Fimage.png?alt=media\&token=63c38a38-4ea0-499b-8667-96b5009b4491)
2. The partial packaging process for orders from Hepsiburada and Trendyol needs to be examined. The process here progresses differently from the standard partial packaging process.

<mark style="color:red;">**Packing Trendyol & Hepsiburada Orders​**</mark>

For orders from these two channels, a single package can be created either in the warehouse or in the store. There's no difference in the process here. The example scenarios mentioned earlier can be applied.

For orders from these two channels, if multiple packages are desired, there are a few additional steps to be taken:

1. In the scenario, the Initial Status field is set to **Waiting Remote Action**.
2. From the Akinon **Settings > Webhooks** page, a new webhook is included with the type "order.fulfillment.multiple\_packages."

Following these procedures, a partial packaging rule similar to the one in the above example can be entered. The order gets split based not on the status "Waiting" of the resulting packages but on the status entered in the "Initial State" field in the scenario.

To explain the process with example;

* Consider an order, S1, as a Trendyol order containing three products.
* The scenario rule added was marked as suitable for Partial Packaging, and the order.fulfillment.multiple\_packages webhook was added.
* Warehouse + Store 1 are added to the rule.
* Consider that stock is available in the warehouse for two of the products in the order, while the remaining one has stock available at Store 1 location.
* In this scenario, when this rule works during the planning step, it will create Package P1 (2 products) in the warehouse, and Package P2 (1 product) at Store 1 location in the **Waiting Remote Action** status.
* The status of these packages and the information about the products within are communicated to Omnitron through the order.fulfillment.multiple\_packages webhook. Omnitron then informs Trendyol about the status of the packages and the product details.
* Trendyol cancels order S1 and forwards packages P1 and P2 as two new orders (S2, S3) to Omnitron.
* Omnitron initiates the cancellation of order S1. OMS responds to this cancellation request by canceling packages P1 and P2 associated with order S1.
* OMS retrieves the two newly sent orders, S2 and S3, from Omnitron and places them back into the planning process. New packages are formed for S2 and S3.
* The process continues until a single package is created.
* This process can be examined in more detail in the following document: [Trendyol - Partial Packaging Workflow](https://drive.google.com/file/d/1o3lBxuy4eEqTuP5QFVki5yQKHQU13tvq/view).
* Additionally, there is [Trendyol - Order Package Distribution Process and Setup Document](https://drive.google.com/file/d/1xKPDceZgT8ADx96YcE8hpIWX9T3yVFBF/view) for further information.

<mark style="color:red;">**Packing for Express Delivery / Same-Day Delivery / Next-Day Delivery Orders​**</mark>

* The scenario should include express delivery options!
* The shipping integrations for these couriers must be set up within the OMS!<br>

  <figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FOOl7QMVh9dQPMiUVSbw1%2Fimage.png?alt=media&#x26;token=1dc5c36b-b8fd-4ecb-b771-0167c639536a" alt="" width="563"><figcaption></figcaption></figure>
* **Rule Name:** Packing for Express Delivery Orders
* The Partial Packaging option should **not** be selected.
* **Only the stores where packaging is desired** should be added to the stock location list.
* The added stores here should be marked as **Express Delivery Available** or **Eligible for Express Delivery** on the "Stock Location Details" page.
* Multiple stores can be added to this list. If a store has sufficient stock for all items in the package, OMS will create the package at that store.
* As multiple stores are added, the location sequence should be selected. It can be arranged in increasing order of priority.
* Once this rule is created, it should be saved by clicking on the **Save Rule** and **Save Scenario** buttons.
* This process can be further explored in detail in the document [Akinon Express Delivery Process](https://drive.google.com/file/d/1xHMCWNbgxnf0zV8plUfInIVK059JVrtU/view).

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FwgsZEprb7XRrNsLqCQsz%2Fimage.png?alt=media&#x26;token=83d9cef5-6748-40be-b7d2-d4cd324e0f25" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">Transfer Scenario​</mark> <a href="#transfer-scenario" id="transfer-scenario"></a>

* For the Transfer scenario to function, a rule in the Distribution Scenario needs to be marked as **Transferable**.
* A new transfer scenario and transfer rule should be added.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F1Ls9iSvgBH7239Vy9s0Z%2Fimage.png?alt=media&#x26;token=be23bd83-e085-4706-bb41-a72144c8baf5" alt="" width="563"><figcaption></figcaption></figure>

* **Rule Name:** Locations Available for Transfer
* In the Rule's "Prerequisite" section, if chosen **According to Package Location**, it determines the locations to which the transfer will occur. This is the destination location for the transfer.
* In the lower section, only stores available for transfers should be added to the Stock Location list. This section represents the source location for the transfer.
* The added stores here should be marked as **Transfer Center** on the Stock Location Details page.
* Multiple stores can be added to the stock location section. OMS will initiate the transfer from the store where there is sufficient stock for the items in the package.
* As multiple stores have been added, a location hierarchy should be chosen and arranged in ascending order based on priority.
* After creating the rule in this manner, it's important to click on **Save Rule** and then on **Save Scenario** buttons.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FzLdd5xPqgGo9N0LpyMnr%2Fimage.png?alt=media&#x26;token=160e5ebe-ec61-432b-b0dd-da391962348e" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">Packaging Click & Collect Orders​</mark> <a href="#packaging-click--collect-orders" id="packaging-click--collect-orders"></a>

Click & Collect orders do not require any specific scenario for planning. OMS assigns the package to the "retail\_store" location provided with the order.

{% hint style="info" %}
The **Application Settings > IS\_CLICK\_AND\_COLLECT\_ENABLED** setting should be set to True.
{% endhint %}


---

# 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://docs.akinon.com/tutorials/oms/working-logic-of-scenarios.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.
