pixiReportStockValueHistEKPrice
Returns all items with a given item tag together with stock quantity at a cut-off date, last known purchase price, invoice discounts and resulting stock value.
Builds a stock valuation report based on historical purchase (EK) prices for all items that carry a specific item tag.
Steps:
- Looks up the item tag
@ItemTag(tag type1) and checks that the shop@ShopIDexists. If either is missing, the errorTag or Shop does not existis raised (see notes, execution is not stopped). - Selects all items linked to the tag. For each item it determines:
- Anschaffungsdatum: the date of the first bin log entry with a positive quantity (first put to stock, not limited by the date range).
- EK-Preis netto: the final price of the most recent supplier delivery line with a delivered quantity > 0 and a price > 0; if there is none, the item's supplier price is used.
- Calculates the stock quantity as the sum of all bin log movements of the item with an update date before
@DateTo(across all locations and bins). - Sums the discounts from invoice lines of invoices of shop
@ShopIDwith an invoice date in the range@DateFrom(inclusive) to@DateTo(exclusive). The discount per line is quantity × discount value, converted to a net amount by dividing by the high or low VAT rate of the invoice depending on the line's VAT code (H/L).- If the setting
MultiCurrencyEnabledis1, the discount is additionally converted into the database currency using the exchange rate of the database currency's exchange rate source for the invoice's exchange date and currency.
- If the setting
- Returns one row per tagged item with price, quantity, total purchase value, discounts and the resulting total (
EK Gesamt nettominusBewertungsabschläge).
The result has no explicit sort order.
Notes
- Error does not stop execution:
RAISERRORwith severity 16 is not followed by aRETURN. The caller receives the error message, but the procedure continues. With an unknown tag the result set is empty; with an unknown shop but a valid tag the items are still returned, only without discounts. @ShopIDis effectively required:NULLnever matches an existing shop and triggers the error.@DateToand@DateFromare effectively required: with@DateTo=NULLno stock is calculated and the price always falls back to the item's supplier price; with@DateFrom=NULLno discounts are found.- Purchase price pitfall: the date condition for the last delivery price compares the item's creation date with
@DateTo, not the delivery date. The price is therefore the most recent delivery price overall (including deliveries after@DateTo), as long as the item was created before@DateTo. - Stock is not restricted to a shop or location; all bin log movements are summed.
dbCurrencycontains the database currency code only ifMultiCurrencyEnabled=1; otherwise it isNULLand amounts are in the original invoice currency.- All reads use
NOLOCK, so results may include uncommitted data. - Column names contain spaces; in the SOAP/DataSet XML they appear encoded, e.g.
EK-Preis_x0020_netto.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
ShopID
|
varchar(3) string |
NULL |
Shop whose invoices are used for the discount calculation. Must exist, otherwise an error is raised. Example: |
ItemTag
|
varchar(50) string |
NULL |
Name of the item tag (tag type 1). Only items linked to this tag are reported. Must exist, otherwise an error is raised. Example: |
DateFrom
|
datetime dateTime |
NULL |
Start of the invoice date range for discounts (inclusive). Example: |
DateTo
|
datetime dateTime |
NULL |
Cut-off date (exclusive): end of the invoice date range and date up to which stock movements are summed. Example: |
Result set 1 · Always (empty if the tag does not exist or has no items)
One row per item linked to the tag, with stock valuation by historical purchase price.
| Column | Type | Description |
|---|---|---|
Artikel
Nullable |
varchar(255) string |
Item name. |
Artikelnummer
Nullable |
varchar(50) string |
Internal item number. |
Anschaffungsdatum
|
varchar(20) string |
Date of the first put to stock in format dd.mm.yyyy; empty string if unknown. |
EK-Preis netto
|
money decimal |
Last known net purchase price (latest delivery price or item supplier price); 0 if none. |
Anzahl
|
int |
Stock quantity before |
EK Gesamt netto
|
money decimal |
Purchase price × stock quantity; 0 if not computable. |
Bewertungsabschläge
|
money decimal |
Sum of net invoice line discounts in the date range for the shop; in database currency if multi-currency is enabled. |
Gesamt
|
money decimal |
|
dbCurrency
Nullable |
varchar(3) string |
Database currency code if |
Response example
<SqlRowSet1>
<row>
<Artikel>Bluetooth Kopfhörer X200</Artikel>
<Artikelnummer>BT-X200</Artikelnummer>
<Anschaffungsdatum>14.03.2022</Anschaffungsdatum>
<EK-Preis_x0020_netto>24.5000</EK-Preis_x0020_netto>
<Anzahl>40</Anzahl>
<EK_x0020_Gesamt_x0020_netto>980.0000</EK_x0020_Gesamt_x0020_netto>
<Bewertungsabschläge>35.2100</Bewertungsabschläge>
<Gesamt>944.7900</Gesamt>
<dbCurrency>EUR</dbCurrency>
</row>
<row>
<Artikel>USB-C Ladekabel 1m</Artikel>
<Artikelnummer>USBC-1M</Artikelnummer>
<Anschaffungsdatum/>
<EK-Preis_x0020_netto>2.1000</EK-Preis_x0020_netto>
<Anzahl>0</Anzahl>
<EK_x0020_Gesamt_x0020_netto>0.0000</EK_x0020_Gesamt_x0020_netto>
<Bewertungsabschläge>0.0000</Bewertungsabschläge>
<Gesamt>0.0000</Gesamt>
<dbCurrency>EUR</dbCurrency>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| RAISERROR | Tag or Shop does not exist | The item tag `@ItemTag` (type 1) was not found or `@ShopID` does not exist (including NULL). Execution continues afterwards. Pass an existing item tag name and shop ID. |
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:pixiReportStockValueHistEKPrice>
<!-- <ShopID>SHP</ShopID> -->
<!-- <ItemTag>Inventur2023</ItemTag> -->
<!-- <DateFrom>2023-01-01T00:00:00</DateFrom> -->
<!-- <DateTo>2024-01-01T00:00:00</DateTo> -->
</ns1:pixiReportStockValueHistEKPrice>
</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:pixiReportStockValueHistEKPrice>
<!-- <ShopID>SHP</ShopID> -->
<!-- <ItemTag>Inventur2023</ItemTag> -->
<!-- <DateFrom>2023-01-01T00:00:00</DateFrom> -->
<!-- <DateTo>2024-01-01T00:00:00</DateTo> -->
</ns1:pixiReportStockValueHistEKPrice>
</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 = [
// 'ShopID' => 'SHP',
// 'ItemTag' => 'Inventur2023',
// 'DateFrom' => '2023-01-01T00:00:00',
// 'DateTo' => '2024-01-01T00:00:00',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiReportStockValueHistEKPrice', $soapArguments);
- SQL object:
- dbo.pipiReportStockValueHistEKPrice