Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Before starting to create stock queries, please ensure that the necessary item and stock point queries have already been set up.

Items queries

Stock locations queries

Guidelines

Creation of a new query

To create a new query, click on the button “Add a stock location query”.

You'll need to give it a name, and then choose whether the query should inherit from another existing query or not.

If you choose to inherit from an existing query, you won't be asked for any additional parameters, as you'll get back all those set on the parent query.

However, if you choose to create a query without inheritance, you will be prompted for export and unification parameters. These parameters can be modified after creation, and a more detailed explanation is given in the following documentation.

Contents of a stock query

A stock query is a sum of aggregates representing a scope of stock locations on particular items, for which some elements are deducted. Then, settings adjust the response according to specific needs. Here is a diagram of a stock request.

Aggregates

Each aggregate represents a scope of stock locations on a scope of items. All aggregates are added together, so no stock location must be returned in two different aggregates, otherwise the stock response will be doubled.

When creating an aggregate, you need to define a name and then specify which stock locations and item queries will be used to represent the aggregate.

Stock locations and items queries

Once selected at the creation, queries are visible by unfolding the aggregate. The "Edit" button is used to modify the query and also to change the parameter “force usage of the filter requested” (details below). There's also a redirect button that opens another window on the item or stock location query.

(warning) Force usage of stock location/item filter requested.

When selecting stock locations and items queries, you must choose whether or not to activate it. It is important to understand this parameter, as it can have an impact on the results of the stock query.

When users uses the API GET /stock_export route, they won't necessarily want to retrieve all possible values, but only on particular items or stock locations. They can therefore use filters as shown below.

 Example of stock_export API call on "newquery" with items and stock location filters
GET /stock_export
{
    "site_id": "cxxx",
    "request_name": "newquery",
    "aggregates": {
        "*": {
            "item_filter": {
                "ids": [
                    "ITEM_001"
                ]
            },
            "endpoint_filter": {
                "ids": [
                    "STORE_001"
                ]
            }
        }
    }
}

If the Force usage of stock location/item filter requested parameter is enabled, filters will be taken into account. Otherwise, they will be ignored and all results will be returned.

 Does this filter need to be activated?
  • For items queries : We recommend you to activate it systematically. Some queries called by Onestock interfaces use item filters to boost performance.

  • For stock locations queries : We do not recommend activating it, except if the aggregate is used to target a specific stock location. This generally happens in two types of stock queries:

    • For Click and Collect orchestration - whether in the unified or detailed stock query, one aggregate should use the stock location query stores_cfs_not_sfs to target the specific destination store. The Onestock orchestrator will put the destination store in the “endpoint_filter”, the aggregate must therefore take it into consideration to return only that store and not all the others eligible for Collect From Store. All other aggregates (using stock location queries stores_sfs and warehouses_sfs for example) must not have this parameter activated, as they must return all other eligible stock locations.

    • For the Order In Store catalog - the detailed stock query used for “immediate pickup” should have only one single aggregate to target the store using the catalog. This aggregate must use a stock location query such as stores_ois. To display stock availability, the Store App call the stock_export route given the current store in the “endpoint_filter”. The parameter must therefore be activated in order to return only the stock of the current concerned.

Stock type filter

In most cases, there is only one type of stock set up in Onestock that represents available stock, so this filter can be ignored. But if the project uses several types of inventory (to manage future stocks, for example) this parameter can be useful, as it will only return the stock types you're interested in.

You can even filter on periods of future stock availability, as shown below.

Deductions

Deductions are elements that will be decremented from the stock results of the aggregate. There are 4 of them:

  • Types of unavailability:

  • Stock locations reservations:

  • Global buffers:

  • Stock locations buffers:

Settings

Text

Global reservations

Text

Unification

Text

Stock export

Text

Details

Text

Onestock advices

We advise you to use inheritance to build your queries.

First of all

Orchestration

Export

Example

This is what our stock point query tree looks like.

  • No labels