pixiReportCustomerSales
Returns invoiced item lines with customer, country, net line total, currency and last sale date, filtered by item, shop, payment type, customer and invoice date.
Sales report on invoice line level. The header comment describes it as a customer evaluation for customer BAF, so it was written for a specific installation.
Parameter handling
ItemNrSuppl,ShopID,PaymentTypeandCustomerNrExternal: an empty string is treated likeNULL, which means no filter.DateFrom: if it isNULLor earlier than 1990-01-01, the current date and time minus one day is used.DateTo: if it isNULLor earlier than 1990-01-01, the current date and time is used.
Filters (all combined with AND)
ItemNrSupplmust match the item's supplier item number (Items.ItemNrSuppl).ShopIDmust match the invoice shop (Invoices.InvShopID).PaymentTypemust match the payment type stored on the billing address (Addresses.APayment), not the payment type of the invoice.CustomerNrExternalmust match the external customer number of the billing address.- The invoice date must satisfy
InvDate >= DateFromandInvDate < DateTo. The upper bound is exclusive.
Output One row is returned per invoice line. Each row contains:
- the item's supplier number and EAN;
- company (
CareOf), name and external customer number from the billing address; - the quantity;
- the net line total;
- the ISO3 country codes of the billing address and the shipping address;
- the currency code of the invoice;
LastSaleDate: the latest invoice date of any invoice that contains the item.
The net line total is calculated like this: the unit price of the line is divided by 1 + VAT rate, rounded to 2 decimals and then multiplied by the quantity. The VAT rate is the invoice's high rate for VAT code H, the low rate for L, and 0 for any other code.
The result has no defined sort order.
Notes
- All tables are read with
NOLOCK, so uncommitted data can appear in the result. - Without date parameters, the report covers exactly the last 24 hours up to the moment of the call. This is a rolling window, not the previous calendar day. To get whole days, pass
DateToas midnight of the day after the last day you want. - All joins are inner joins. Lines are left out if the invoice has no billing or shipping address, if a country cannot be resolved in
Countries, or if the invoice currency is not found inpixi.Currency. LastSaleDateignores all filters, including the date range. It always shows the latest invoice date of the item across all invoices. Because it is a correlated subquery per row, large date ranges can be slow.- The net calculation uses
VATHighPerc/VATLowPercdirectly as1 + rate. The result is only correct if these rates are stored as fractions (e.g. 0.19). - The unit net price is rounded before it is multiplied by the quantity, so small rounding differences against the invoice totals are possible.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
ItemNrSuppl
|
varchar(50) string |
NULL |
Supplier item number ( Example: |
ShopID
|
varchar(3) string |
NULL |
Shop ID of the invoice ( Example: |
PaymentType
|
char(1) string |
NULL |
Payment type code compared with Example: |
CustomerNrExternal
|
varchar(60) string |
NULL |
External customer number of the billing address. Example: |
DateFrom
|
datetime dateTime |
NULL |
Start of the invoice date range (inclusive). If it is Example: |
DateTo
|
datetime dateTime |
NULL |
End of the invoice date range (exclusive). If it is Example: |
Result set 1 · Always (can be empty)
One row per invoice line that matches the filters.
| Column | Type | Description |
|---|---|---|
ItemNrSuppl
Nullable |
varchar(50) string |
Supplier item number of the item. |
EANUPC
Nullable |
string |
EAN/UPC of the item. |
Company
Nullable |
string |
Company of the billing address ( |
CustomerName
Nullable |
string |
Name of the billing address. |
CustomerNrExternal
Nullable |
varchar(60) string |
External customer number of the billing address. |
Qty
Nullable |
int |
Invoiced quantity of the line ( |
ItemTotal_Net
Nullable |
decimal(10,2) decimal |
Net line total: unit price without VAT, rounded to 2 decimals, multiplied by the quantity. |
CountryCodeISO3_Billing
Nullable |
string |
ISO3 country code of the billing address. |
CountryCodeISO3_Shipping
Nullable |
string |
ISO3 country code of the shipping address. |
LastSaleDate
Nullable |
datetime dateTime |
Latest invoice date of any invoice containing this item, independent of the filters. |
CurrencyCode
Nullable |
string |
Currency code of the invoice ( |
Response example
<SqlRowSet1>
<row>
<ItemNrSuppl>BAF-10045</ItemNrSuppl>
<EANUPC>4006381333931</EANUPC>
<Company>Muster GmbH</Company>
<CustomerName>Max Mustermann</CustomerName>
<CustomerNrExternal>K-204711</CustomerNrExternal>
<Qty>2</Qty>
<ItemTotal_Net>33.60</ItemTotal_Net>
<CountryCodeISO3_Billing>DEU</CountryCodeISO3_Billing>
<CountryCodeISO3_Shipping>AUT</CountryCodeISO3_Shipping>
<LastSaleDate>2024-03-28T14:12:05</LastSaleDate>
<CurrencyCode>EUR</CurrencyCode>
</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:pixiReportCustomerSales>
<!-- <ItemNrSuppl>BAF-10045</ItemNrSuppl> -->
<!-- <ShopID>SHP</ShopID> -->
<!-- <PaymentType>R</PaymentType> -->
<!-- <CustomerNrExternal>K-204711</CustomerNrExternal> -->
<!-- <DateFrom>2024-03-01T00:00:00</DateFrom> -->
<!-- <DateTo>2024-04-01T00:00:00</DateTo> -->
</ns1:pixiReportCustomerSales>
</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:pixiReportCustomerSales>
<!-- <ItemNrSuppl>BAF-10045</ItemNrSuppl> -->
<!-- <ShopID>SHP</ShopID> -->
<!-- <PaymentType>R</PaymentType> -->
<!-- <CustomerNrExternal>K-204711</CustomerNrExternal> -->
<!-- <DateFrom>2024-03-01T00:00:00</DateFrom> -->
<!-- <DateTo>2024-04-01T00:00:00</DateTo> -->
</ns1:pixiReportCustomerSales>
</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 = [
// 'ItemNrSuppl' => 'BAF-10045',
// 'ShopID' => 'SHP',
// 'PaymentType' => 'R',
// 'CustomerNrExternal' => 'K-204711',
// 'DateFrom' => '2024-03-01T00:00:00',
// 'DateTo' => '2024-04-01T00:00:00',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiReportCustomerSales', $soapArguments);
- SQL object:
- dbo.pipiReportCustomerSales