Before starting to create stock queries, please ensure that the necessary item and stock point queries have already been set up.
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.
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.
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.
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.