pixiReportTurnover
Returns net invoice turnover for the given day, the day before, the current month and the previous month, optionally filtered by shop.
Dashboard report that sums Total_Net of invoices (Invoices) into four turnover figures and returns them as one row.
Date handling
toDatedefaults to the current date and time. Its time part matters: the given day and the given month are counted only up totoDate, not to the end of that day.fromDatedefaults to the first day of the month beforetoDate. IffromDateis later thantoDate, it is set totoDate.- Only invoices with
InvDatebetween the start of the previous month andtoDateare considered at all.
Shop filter
An invoice is counted only if its customer (CustRef) has at least one address in Addresses with AddrShopID = ShopID. An empty or NULL ShopID includes all invoices that have any address.
The four figures
TurnoverNetGivenDate: iffromDateis in a different month thantoDate, invoices from the start of thetoDateday up totoDate; iffromDateis on the same day astoDate, invoices fromfromDatetotoDate.TurnoverNetDayBefore: iffromDateis in a different month, the whole day beforetoDate; additionally, iffromDatefalls on the day beforetoDate, invoices fromfromDateto the end of that day.TurnoverNetGivenMonth: iffromDateis in a different month, from the 1st of thetoDatemonth up totoDate; if in the same month, fromfromDateup totoDate.TurnoverNetPreviousMonth: iffromDateis before the previous month, the whole previous month; iffromDateis in the previous month, fromfromDateto the end of the previous month.
With the default fromDate the result is: today up to now, yesterday, month to date and the full previous month.
Currency
If the setting MultiCurrencyEnabled is 1, each invoice amount is divided by the exchange rate from pixi.ExchRate for the database exchange-rate source (DatabaseCurrencyExchRateSourceId) and home currency, matched by exchange-rate date and currency of the invoice's rate. dbCurrency then contains the database currency code. Otherwise the amounts are summed as stored and dbCurrency is NULL.
Notes
- All reads use
NOLOCK; figures may include uncommitted data. - The values are returned as strings (
varchar(30)). A figure is NULL (element missing in the row) if no invoice matches its period, e.g.TurnoverNetGivenDateandTurnoverNetDayBeforeare NULL whenfromDateis in the same month astoDatebut neither on that day nor on the day before.TurnoverNetPreviousMonthis NULL whenfromDatelies in the current month. - A
fromDateearlier than the start of the previous month has no extra effect, because older invoices are never loaded. - In multi-currency mode, invoices without a matching exchange rate record (or without
ExchRateId) are silently excluded because of inner joins. The number of decimal places in the string depends on the data type ofExchRate, which is not visible here. - If the setting
MultiCurrencyEnabledis missing (NULL), the code still takes the conversion branch, butdbCurrencyis returned as NULL. - On any SQL error the procedure only prints the message and returns
-1; no result set is returned. - The temporary table is dropped via
util.TempTableDrop(definition not attached).
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
fromDate
|
datetime dateTime |
NULL |
Start of the evaluation period. Defaults to the first day of the month before Example: |
toDate
|
datetime dateTime |
NULL |
Reference date and time (end of the period). Defaults to the current date and time. Example: |
ShopID
|
varchar(3) string |
– |
Shop filter: only invoices of customers with an address of this shop are counted. Empty means all shops. Example: |
Result set 1 · Always, unless an SQL error occurs
One row with the four net turnover figures and the database currency code.
| Column | Type | Description |
|---|---|---|
TurnoverNetGivenDate
Nullable |
varchar(30) string |
Net turnover on the given day (or from |
TurnoverNetDayBefore
Nullable |
varchar(30) string |
Net turnover on the day before |
TurnoverNetGivenMonth
Nullable |
varchar(30) string |
Net turnover of the month of |
TurnoverNetPreviousMonth
Nullable |
varchar(30) string |
Net turnover of the previous month (or from |
dbCurrency
Nullable |
varchar(3) string |
Database (home) currency code when |
Response example
<SqlRowSet1>
<row>
<TurnoverNetGivenDate>1523.40</TurnoverNetGivenDate>
<TurnoverNetDayBefore>4210.75</TurnoverNetDayBefore>
<TurnoverNetGivenMonth>58320.10</TurnoverNetGivenMonth>
<TurnoverNetPreviousMonth>112845.60</TurnoverNetPreviousMonth>
<dbCurrency>EUR</dbCurrency>
</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:pixiReportTurnover>
<!-- <fromDate>2024-05-01T00:00:00</fromDate> -->
<!-- <toDate>2024-06-15T18:00:00</toDate> -->
<!-- <ShopID>ABC</ShopID> -->
</ns1:pixiReportTurnover>
</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:pixiReportTurnover>
<!-- <fromDate>2024-05-01T00:00:00</fromDate> -->
<!-- <toDate>2024-06-15T18:00:00</toDate> -->
<!-- <ShopID>ABC</ShopID> -->
</ns1:pixiReportTurnover>
</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 = [
// 'fromDate' => '2024-05-01T00:00:00',
// 'toDate' => '2024-06-15T18:00:00',
// 'ShopID' => 'ABC',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiReportTurnover', $soapArguments);
- SQL object:
- dbo.pipiReportTurnover