pixiGetInvoiceLinesExtended
Returns invoice headers combined with their invoice lines in one flat result set, filtered by invoice, shop, order, customer, payment and date criteria.
Combines invoice header data and invoice line data into one call. Each result row is one invoice line, with all header, billing address and payment fields repeated on every line of the same invoice.
Parameter normalisation
- Empty strings are treated as
NULLfor all string and date filters;OrderNR = 0is treated asNULL. RowCountdefaults to 1000;NULL, 0 or negative values are also replaced by 1000.
Step 1 – candidate invoices (dynamic SQL, executed with sp_executesql)
Up to RowCount * 3 invoices are selected from Invoices (joined to Customers, left-joined to InvLines), ordered by invoice date. Only the filters that are set are added:
InvoiceNr: exact invoice number.ShopID:Customers.CustomerOf.PaymentType:Invoices.Payment.InvDateFrom/InvDateTo: invoice date strictly greater / strictly less than the value.UpdateDateFrom/UpdateDateTo: strictly greater / less than the value, onInvLines.UpdateDate(default) or onInvoices.UpdateDateifConsiderInvoiceUpdates = 1. Records withUpdateDateNULLnever match.OrderNR: the invoice has at least one invoice line linked to an order line of that Auftrag.OrderNRExternal: resolved to an internal order number viaOrderHeader.OrderNrExternal, then filtered likeOrderNR.OnlyUnpaidInvoices = 1: paid sum differs from the total, and there is no openCustomerAccountentry for the invoice markedDoNotRefund = 1(without bank line, DTAUS or manual booking reference).CustomerNrExternal:Customers.CustomerNrExternal.
Step 2 – headers and lines
- The first
RowCountcandidates (ordered by invoice date and invoice key) are loaded as headers. Only invoices with a matching currency, a payment code that exists inPaymentsand a billing address inAddressesare kept. - Lines are read from the view
PV_Invlines, which also contains pseudo lines:ItemKey = -2shipping costs,-1vouchers,-3manual invoices without lines. Supplier price and supplier number are taken fromSupplierPrice_Historyif present. - If
AddCCPPayID = 1, theccpPayIDvalues of all Aufträge on the invoice are concatenated with commas intoCcpPayID.
Step 3 – final filter and output
- Pseudo lines (
ItemKey-1, -2, -3) are only returned ifIncludeSpecialInvLines = 1. Statusfilters on the order line status of the line (AUSif the line has no status).IsReplacementOnly = 1returns only lines whose order line has statusMINor has anOrderHistoryentry with statusMIN(replacement deliveries).- At most
RowCountrows (lines) are returned, ordered by invoice date and invoice key. UpdateDatein the output is the line's update/create date (falling back to the invoice date) by default, or the invoice's update/create date ifConsiderInvoiceUpdates = 1.
Notes
- All reads use
NOLOCK, so uncommitted data can appear. RowCountlimits invoices and the final line rows. Because the finalTOPcounts lines, the lines of the last invoice can be cut off. For complete invoices, query byInvoiceNror use aRowCountwell above the expected number of lines.- Date bounds are exclusive (
>and<), not inclusive. - With the default
ConsiderInvoiceUpdates = 0, the update date filters work on invoice lines, so invoices without lines (e.g. manual invoices) never match them. - If
OrderNRExternalcannot be resolved inOrderHeader, the result is empty. If several orders share the external number, only one of them is used. - Lines whose
ItemKeyisNULL(invoice lines without order line or item) are dropped by theNOT IN (-1,-2,-3)test unlessIncludeSpecialInvLines = 1. - With
IsReplacementOnly = 1, pseudo lines are never returned because they have no order line. CcpPayIDis truncated to 50 characters.Currencyis always the constantEUR; the actual order currency is inOrderCurrency.OrderDatereturns1900-01-01if the line has no Auftrag (empty string converted to a date).EANUPCis0for lines without an Artikel.OrderNrappears twice in each row.Paidis 1 only if the paid sum equals the invoice total exactly.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
InvoiceNr
|
varchar(20) string |
NULL |
Exact invoice number. Empty string means no filter. Example: |
ShopID
|
varchar(3) string |
NULL |
Shop ID of the customer ( Example: |
PaymentType
|
char(1) string |
NULL |
Payment code of the invoice ( Example: |
OrderNR
|
int | NULL |
Internal order number; returns invoices with at least one line of this Auftrag. 0 means no filter. Example: |
OrderNRExternal
|
varchar(50) string |
NULL |
External order number; resolved to the internal order number via Example: |
InvDateFrom
|
datetime dateTime |
NULL |
Returns invoices with invoice date strictly after this value. Example: |
InvDateTo
|
datetime dateTime |
NULL |
Returns invoices with invoice date strictly before this value. Example: |
UpdateDateFrom
|
datetime dateTime |
NULL |
Update date strictly after this value, on invoice lines or on the invoice depending on Example: |
UpdateDateTo
|
datetime dateTime |
NULL |
Update date strictly before this value, on invoice lines or on the invoice depending on Example: |
RowCount
|
int | 1000 |
Maximum number of invoices and of returned rows. Example: |
AddCCPPayID
|
bit boolean |
0 |
If 1, fills Allowed values
Example: |
OnlyUnpaidInvoices
|
bit boolean |
0 |
If 1, returns only invoices whose paid sum differs from the total and that have no open Allowed values
Example: |
IncludeSpecialInvLines
|
bit boolean |
0 |
If 1, also returns pseudo lines for shipping costs ( Allowed values
Example: |
Status
|
varchar(3) string |
NULL |
Order line status of the line; lines without status count as Example: |
CustomerNrExternal
|
varchar(60) string |
NULL |
External customer number ( Example: |
IsReplacementOnly
|
bit boolean |
0 |
If 1, returns only lines whose order line has or had status Allowed values
Example: |
ConsiderInvoiceUpdates
|
bit boolean |
0 |
Selects which update date the update date filters and the output column Allowed values
Example: |
Result set 1 · Always (may be empty)
One row per invoice line with repeated invoice header, address and payment data, ordered by invoice date and invoice key.
| Column | Type | Description |
|---|---|---|
InvoiceNr
Nullable |
varchar(20) string |
Invoice number |
InvoiceDate
Nullable |
datetime dateTime |
Invoice date |
ShopID
Nullable |
varchar(3) string |
Shop of the customer |
PaymentAddressId
Nullable |
int |
Key of the billing address |
ShipmentAddressId
Nullable |
int |
Key of the shipping address |
CustKey
Nullable |
int |
Customer key |
Total
Nullable |
money decimal |
Invoice total (gross) |
VATSum
Nullable |
money decimal |
Total VAT incl. shipping and return costs |
VATHigh
Nullable |
money decimal |
VAT at standard rate incl. shipping and return costs |
VATLow
Nullable |
money decimal |
VAT at reduced rate incl. shipping and return costs |
TotalNoVAT
Nullable |
money decimal |
Net invoice total |
ShipCost
Nullable |
money decimal |
Shipping costs (gross) |
ShipCostNoVAT
Nullable |
numeric(17,2) decimal |
Shipping costs (net) |
Discount_Invoice
Nullable |
money decimal |
Voucher sum; gross for B2C, net otherwise |
Discount_InvLines
Nullable |
money decimal |
Total line discounts |
PaymentCode
Nullable |
varchar(1) string |
Payment code |
PaymentText
Nullable |
varchar(120) string |
Payment type text, falls back to the code |
PaymentDate
Nullable |
datetime dateTime |
Payment date |
Paid
Nullable |
bit boolean |
1 if paid sum equals the total |
TotalToPay
Nullable |
money decimal |
Invoice total |
PaidSum
Nullable |
money decimal |
Amount paid |
CcCardType
Nullable |
varchar(2) string |
Credit card type from billing address |
CcCardNr
Nullable |
varchar(25) string |
Credit card number |
CcCardName
Nullable |
varchar(60) string |
Card holder name |
CcCardExp
Nullable |
varchar(4) string |
Card expiry |
Account
Nullable |
varchar(10) string |
Bank account number |
Blz
Nullable |
varchar(8) string |
Bank code |
BankName
Nullable |
varchar(50) string |
Bank name |
AccountName
Nullable |
varchar(27) string |
Account holder |
TrackingID
Nullable |
varchar(8000) string |
Shipment tracking ID of the invoice |
ShipDate
Nullable |
datetime dateTime |
Scan-out date |
UpdateDate
Nullable |
datetime dateTime |
Line or invoice update/create date depending on |
ReminderLevel
Nullable |
int |
Dunning level |
OrderNr
Nullable |
int |
Internal order number of the line |
OrderNrExternal
Nullable |
varchar(50) string |
External order number |
Note
Nullable |
varchar(255) string |
Invoice note |
ShipVendor
Nullable |
varchar(3) string |
Shipping carrier |
CcpPayID
|
varchar(1024) string |
Comma-separated payment provider IDs (only with |
Currency
Nullable |
varchar(3) string |
Always |
OrderCurrency
Nullable |
varchar(3) string |
Currency code of the invoice |
TotalToPay_OrderCurr
Nullable |
money decimal |
Invoice total |
ReturnReason
Nullable |
varchar(100) string |
Return reason |
InvoiceKey
Nullable |
int |
Invoice key |
RefToInvoiceNr
Nullable |
varchar(20) string |
Referenced invoice number (e.g. for credit notes) |
RefToInvoiceKey
Nullable |
int |
Referenced invoice key |
Anrede
Nullable |
varchar(60) string |
Salutation (billing address) |
Name
Nullable |
varchar(121) string |
Name |
Name2
Nullable |
varchar(60) string |
Name line 2 |
FirstName
Nullable |
varchar(60) string |
First name |
LastName
Nullable |
varchar(60) string |
Last name |
CareOf
Nullable |
varchar(60) string |
Care of |
Address
Nullable |
varchar(110) string |
Address line |
Street
Nullable |
varchar(100) string |
Street |
HouseNr
Nullable |
varchar(12) string |
House number |
City
Nullable |
varchar(50) string |
City |
State
Nullable |
varchar(3) string |
State |
ZIP
Nullable |
varchar(10) string |
Postal code |
Country
Nullable |
varchar(3) string |
Country code |
CustomerNrExternal
Nullable |
varchar(60) string |
External customer number from the billing address |
Orderlinekey
Nullable |
int |
Order line key (-1/-2/-3 for pseudo lines) |
EANUPC
|
string |
EAN/UPC of the Artikel, |
ItemName
Nullable |
varchar(120) string |
Item name |
SpecialNote
Nullable |
varchar(8000) string |
Special note of the order line |
OrderDate
|
datetime dateTime |
Order date (or create date) of the Auftrag; 1900-01-01 if none |
OrderQty
Nullable |
int |
Ordered quantity |
ItemQty
Nullable |
int |
Invoiced quantity |
ItemPrice_Brutto
Nullable |
money decimal |
Gross item price |
ItemPrice_Netto
Nullable |
numeric(17,4) decimal |
Net item price |
ItemPrice_VAT
Nullable |
numeric(17,4) decimal |
VAT amount of the line |
SupplPrice
Nullable |
money decimal |
Supplier price (from price history if available) |
ItemNrSuppl
Nullable |
string |
Supplier item number |
ItemNrInt
Nullable |
string |
Internal item number |
SerialNr
Nullable |
varchar(50) string |
Serial number |
OrderNr
Nullable |
int |
Internal order number (duplicate of the earlier column) |
STATUS
Nullable |
varchar(3) string |
Order line status, |
FullPrice
Nullable |
money decimal |
Price before discount, falls back to gross price |
DiscountValue
Nullable |
money decimal |
Discount amount, 0 if none |
DiscountPerc
Nullable |
numeric(6,2) decimal |
Discount percent, 0 if none |
DF_Type
Nullable |
varchar(1) string |
Direct fulfillment type, |
DFShipDate
Nullable |
datetime dateTime |
Direct fulfillment ship date |
DFShipmentTrackingID
Nullable |
varchar(100) string |
Direct fulfillment tracking ID |
SubShopLogo
Nullable |
string |
Sub-shop logo of the Auftrag |
SubShopNAme
|
string |
Sub-shop name, empty if none |
Referrer
|
string |
Referrer of the Auftrag, empty if none |
Type
|
varchar(1) string |
|
ReturnCostsAmount
Nullable |
money decimal |
Return costs of the invoice |
InvLineKey
Nullable |
int |
Invoice line key, NULL for pseudo lines |
SupplNr
Nullable |
varchar(4) string |
Supplier number (from price history if available) |
BatchNumber
Nullable |
string |
Charge (batch number) of the order line |
BestBeforeDate
Nullable |
dateTime |
Best-before date of the order line |
IBAN
Nullable |
varchar(35) string |
IBAN |
BIC
Nullable |
varchar(11) string |
BIC |
Response example
<SqlRowSet1>
<row>
<InvoiceNr>RE2024001234</InvoiceNr>
<InvoiceDate>2024-01-10T14:22:00</InvoiceDate>
<ShopID>SHP</ShopID>
<CustKey>4711</CustKey>
<Total>119.00</Total>
<VATSum>19.00</VATSum>
<PaymentCode>R</PaymentCode>
<PaymentText>Rechnung</PaymentText>
<Paid>false</Paid>
<UpdateDate>2024-01-10T14:22:00</UpdateDate>
<OrderNr>123456</OrderNr>
<OrderNrExternal>WEB-100045</OrderNrExternal>
<CcpPayID/>
<Currency>EUR</Currency>
<OrderCurrency>EUR</OrderCurrency>
<InvoiceKey>98765</InvoiceKey>
<LastName>Muster</LastName>
<City>Berlin</City>
<Country>DE</Country>
<Orderlinekey>555001</Orderlinekey>
<EANUPC>4006381333931</EANUPC>
<ItemName>Kugelschreiber blau</ItemName>
<ItemQty>2</ItemQty>
<ItemPrice_Brutto>59.50</ItemPrice_Brutto>
<ItemPrice_Netto>50.0000</ItemPrice_Netto>
<STATUS>AUS</STATUS>
<Type>I</Type>
<InvLineKey>880011</InvLineKey>
</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:pixiGetInvoiceLinesExtended>
<!-- <InvoiceNr>RE2024001234</InvoiceNr> -->
<!-- <ShopID>SHP</ShopID> -->
<!-- <PaymentType>R</PaymentType> -->
<!-- <OrderNR>123456</OrderNR> -->
<!-- <OrderNRExternal>WEB-100045</OrderNRExternal> -->
<!-- <InvDateFrom>2024-01-01T00:00:00</InvDateFrom> -->
<!-- <InvDateTo>2024-02-01T00:00:00</InvDateTo> -->
<!-- <UpdateDateFrom>2024-01-15T08:00:00</UpdateDateFrom> -->
<!-- <UpdateDateTo>2024-01-16T08:00:00</UpdateDateTo> -->
<!-- <RowCount>500</RowCount> -->
<!-- <AddCCPPayID>1</AddCCPPayID> -->
<!-- <OnlyUnpaidInvoices>0</OnlyUnpaidInvoices> -->
<!-- <IncludeSpecialInvLines>1</IncludeSpecialInvLines> -->
<!-- <Status>AUS</Status> -->
<!-- <CustomerNrExternal>K-778899</CustomerNrExternal> -->
<!-- <IsReplacementOnly>0</IsReplacementOnly> -->
<!-- <ConsiderInvoiceUpdates>0</ConsiderInvoiceUpdates> -->
</ns1:pixiGetInvoiceLinesExtended>
</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:pixiGetInvoiceLinesExtended>
<!-- <InvoiceNr>RE2024001234</InvoiceNr> -->
<!-- <ShopID>SHP</ShopID> -->
<!-- <PaymentType>R</PaymentType> -->
<!-- <OrderNR>123456</OrderNR> -->
<!-- <OrderNRExternal>WEB-100045</OrderNRExternal> -->
<!-- <InvDateFrom>2024-01-01T00:00:00</InvDateFrom> -->
<!-- <InvDateTo>2024-02-01T00:00:00</InvDateTo> -->
<!-- <UpdateDateFrom>2024-01-15T08:00:00</UpdateDateFrom> -->
<!-- <UpdateDateTo>2024-01-16T08:00:00</UpdateDateTo> -->
<!-- <RowCount>500</RowCount> -->
<!-- <AddCCPPayID>1</AddCCPPayID> -->
<!-- <OnlyUnpaidInvoices>0</OnlyUnpaidInvoices> -->
<!-- <IncludeSpecialInvLines>1</IncludeSpecialInvLines> -->
<!-- <Status>AUS</Status> -->
<!-- <CustomerNrExternal>K-778899</CustomerNrExternal> -->
<!-- <IsReplacementOnly>0</IsReplacementOnly> -->
<!-- <ConsiderInvoiceUpdates>0</ConsiderInvoiceUpdates> -->
</ns1:pixiGetInvoiceLinesExtended>
</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 = [
// 'InvoiceNr' => 'RE2024001234',
// 'ShopID' => 'SHP',
// 'PaymentType' => 'R',
// 'OrderNR' => '123456',
// 'OrderNRExternal' => 'WEB-100045',
// 'InvDateFrom' => '2024-01-01T00:00:00',
// 'InvDateTo' => '2024-02-01T00:00:00',
// 'UpdateDateFrom' => '2024-01-15T08:00:00',
// 'UpdateDateTo' => '2024-01-16T08:00:00',
// 'RowCount' => '500',
// 'AddCCPPayID' => '1',
// 'OnlyUnpaidInvoices' => '0',
// 'IncludeSpecialInvLines' => '1',
// 'Status' => 'AUS',
// 'CustomerNrExternal' => 'K-778899',
// 'IsReplacementOnly' => '0',
// 'ConsiderInvoiceUpdates' => '0',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiGetInvoiceLinesExtended', $soapArguments);
- SQL object:
- dbo.pipiGetInvoiceLinesExtended