pixiReport_LogisticQuality
Returns the distribution of recent orders by the number of days between order receipt and first shipment, as a logistics quality KPI.
Calculates how many days it took to ship recent orders and groups the orders by that number.
1. Order selection
An order is included if:
- its
Orderheader.CreateDateis at most@DaysBackdays ago; - it has at least one order line in status
ANGorAUS. If@ShopIDis not empty, the line'sOrdShopIdmust also match; - it has no line in status
ANG/AUS(created within@DaysBackdays, same shop filter) whose Artikel had no stock booked inInvBinItemLogbefore the line was created; - its customer is not locked (
HSLocked = 'Y'inCustomersHist).
The order's reference date is the earliest StatusChangeDate of an ANG entry in Orderhistory for its lines.
2. Stock check
The procedure collects all lines of the selected orders. It removes an order if, for one of its Artikel, the summed quantity of all collected lines is higher than the stock booked in InvBinItemLog up to the order's reference date. Only lines created up to that date and not shipped before it (or not shipped at all) are summed.
3. Date adjustments
- Weekend (with
DATEFIRST 1): orders from Friday after 14:59 move 3 days later. Saturday orders move 2 days later and Sunday orders 1 day later. The time of day stays the same. - Days without shipping: a day counts as a shipping day if it has more than 2 invoices with
total > 0within@DaysBackdays. An order whose original receipt day is not a shipping day gets a new reference date: the earliest invoice time of the next shipping day. This replaces the weekend adjustment.
4. Calculation
For each order, DaysToShip is the whole number of 24-hour periods from the adjusted reference date to the earliest ShipDate of its lines. Negative values are set to 0.
Unshipped orders are excluded, both from the grouping and from the total AllPackages.
5. Result
One row per DaysToShip value with:
- the number of orders;
- their share of
AllPackages; - the total
AllPackages.
A fixed extra row with DaysToShip = 99 and 0 orders is always added. Rows are sorted by DaysToShip ascending.
Notes
- The parameters
@OnlyItemsOnStockand@MinutesSinceRefreshare declared but not used by the code. @ShopIDfilters on the order line fieldOrdShopId, not on the order header.- The code comment says Friday from 14:00. The code uses
hour > 14, so the weekend shift starts at 15:00. - The comment calls the derived days "holidays" (days without shipment). The table actually contains days with more than 2 invoices. Orders created on any other day are moved to the first invoice time of the next such day. If no later shipping day exists, the reference date becomes NULL and the order counts as unshipped.
- If
CustomersHist.HCustRefcontains NULL values, theNOT INfilter excludes all orders. - The row with
DaysToShip = 99is a fixed marker row withNRofORders = 0andPercentage = 0. It is always returned, even if no order qualifies. Percentageis a fraction between 0 and 1, not a percent value.- Most reads use
NOLOCK, so the figures may include uncommitted data. The first read onOrderheaderdoes not useNOLOCK. - The procedure uses many correlated subqueries on
Orderhistory,OrderlinesandInvBinItemLog. Large values for@DaysBackcan be slow. - The procedure only writes to temporary tables.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
DaysBack
|
int | 14 |
Number of days back from today. Orders, order lines and invoices older than this are not considered. Example: |
OnlyItemsOnStock
|
bit boolean |
1 |
Declared but not used by the code. The stock checks are always applied. Example: |
ShopID
|
varchar(3) string |
– |
Shop filter on the order lines' Example: |
MinutesSinceRefresh
|
int | NULL |
Declared but not used by the code. |
Result set 1 · Always
Distribution of shipped orders by days to ship. A fixed marker row with DaysToShip = 99 is always included. Sorted by DaysToShip ascending.
| Column | Type | Description |
|---|---|---|
DaysToShip
Nullable |
int |
Whole days (24-hour periods) from the adjusted order receipt to the first shipment. |
NRofORders
|
int |
Number of orders shipped after this number of days. Always 0 in the marker row. |
Percentage
|
float decimal |
Share of |
AllPackages
Nullable |
float decimal |
Total number of evaluated, shipped orders. |
Response example
<SqlRowSet1>
<row>
<DaysToShip>0</DaysToShip>
<NRofORders>132</NRofORders>
<Percentage>0.825</Percentage>
<AllPackages>160</AllPackages>
</row>
<row>
<DaysToShip>1</DaysToShip>
<NRofORders>28</NRofORders>
<Percentage>0.175</Percentage>
<AllPackages>160</AllPackages>
</row>
<row>
<DaysToShip>99</DaysToShip>
<NRofORders>0</NRofORders>
<Percentage>0</Percentage>
<AllPackages>160</AllPackages>
</row>
</SqlRowSet1>
POST https://apigateway.descartes.com/tms/pixi/
Content-Type: text/xml; charset=utf-8
Authorization: Basic BASE64(USERNAME:PASSWORD)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiReport_LogisticQuality>
<!-- <DaysBack>14</DaysBack> -->
<!-- <OnlyItemsOnStock>1</OnlyItemsOnStock> -->
<!-- <ShopID>SH1</ShopID> -->
<!-- <MinutesSinceRefresh>?</MinutesSinceRefresh> -->
</ns1:pixiReport_LogisticQuality>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
curl -X POST 'https://apigateway.descartes.com/tms/pixi/' \
--user 'USERNAME:PASSWORD' \
--header 'Content-Type: text/xml; charset=utf-8' \
--data-binary @- <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiReport_LogisticQuality>
<!-- <DaysBack>14</DaysBack> -->
<!-- <OnlyItemsOnStock>1</OnlyItemsOnStock> -->
<!-- <ShopID>SH1</ShopID> -->
<!-- <MinutesSinceRefresh>?</MinutesSinceRefresh> -->
</ns1:pixiReport_LogisticQuality>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML
<?php
$soapClient = new SoapClient(null, [
'login' => 'USERNAME',
'password' => 'PASSWORD',
'location' => 'https://apigateway.descartes.com/tms/pixi/',
'uri' => 'https://apigateway.descartes.com/tms/pixi/',
]);
$arguments = [
// 'DaysBack' => '14',
// 'OnlyItemsOnStock' => '1',
// 'ShopID' => 'SH1',
// 'MinutesSinceRefresh' => '?',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiReport_LogisticQuality', $soapArguments);
- SQL object:
- dbo.pipiReport_LogisticQuality