pixiCanMergeOrders
Checks whether two orders can be merged and returns a flag and a reason code with text.
Validates whether the source order (SourceOrderNr) can be merged into the target order (TargetOrderNr). The call does not change any data.
The checks run in this order. The first check that fails sets CanMerge = 0 and the matching reason. The remaining checks are then skipped:
- Both orders exist: exactly two rows must exist in
OrderHeaderfor the two order numbers. Otherwise the reason is401. - Same customer:
CustRefof both orders must be equal. Otherwise the reason is402. - Orderline status: no orderline of either order may have a status other than
ANG. Otherwise the reason is403. - Payment type:
APaymentof the addresses referenced by the orders (AddrRef) must be equal and must not beK(credit card). Otherwise the reason is404. - Picklists: no orderline of either order may be on a picklist whose
PLHexpiryDateis in the future and whoseReservedOrderNris empty or 0. Otherwise the reason is405. - Currency and order type:
CurrencyIdmust match, otherwise the reason is406. ThenOrderTypemust match, otherwise the reason is407.
If all checks pass, the call returns CanMerge = 1 and Reason = '200 OK'. It always returns one row with CanMerge and Reason. The same values are set in the output parameters, and CanMerge is also the procedure's return value.
Notes
- All reads use
NOLOCK, so the result can be based on uncommitted data. Re-check right before the actual merge. - If
TargetOrderNrandSourceOrderNrare equal, only one header row is found, so the result is401. - A
NULLvalue inCustRef,APayment,CurrencyIdorOrderTypemakes the comparison fail and leads to the corresponding error code. - Orders without orderlines pass the status check (
403). - If an order's address (
AddrRef) is not found inAddresses, the join returns no row and the payment check (404) is effectively skipped. - The column
ReservedOrderNrin the picklist check is not qualified with a table name. From the code it is not clear whether it belongs toPLitemorplheader. - The reason text starts with an HTTP-like numeric code (
200,401–407), which is useful for programmatic evaluation.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
TargetOrderNr
Required
|
int | – |
Order number of the target order into which the source order would be merged. Example: |
SourceOrderNr
Required
|
int | – |
Order number of the source order that would be merged into the target order. Example: |
CanMerge
OUTPUT
|
int | NULL |
Output: 1 if the orders can be merged, otherwise 0. An input value is ignored. Allowed values
|
Reason
OUTPUT
|
varchar(128) string |
NULL |
Output: reason code with text, e.g. |
Result set 1 · Always
One row with the result of the merge check.
| Column | Type | Description |
|---|---|---|
CanMerge
|
int |
1 = orders can be merged, 0 = they cannot. |
Reason
|
varchar(128) string |
|
Response example
<SqlRowSet1>
<row>
<CanMerge>0</CanMerge>
<Reason>403 All involved orderlines must have status ANG</Reason>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| 0 | 401 Both orders must exist | One or both order numbers do not exist in `OrderHeader`, or both parameters contain the same order number. Pass two different, existing order numbers. |
| 0 | 402 Orders must belong to the same customer | The orders have different (or NULL) `CustRef` values. Only orders of the same customer can be merged. |
| 0 | 403 All involved orderlines must have status ANG | At least one orderline of either order has a status other than `ANG`. |
| 0 | 404 Payment types on both orders must match and not be a creditcard type | The payment types (`APayment`) of the order addresses differ, are NULL, or are `K` (credit card). |
| 0 | 405 None of the orderlines in either orders can be on picklists | At least one orderline is on a picklist that has not expired and has no reserved order number. |
| 0 | 406 Orders must have same currency | The orders have different `CurrencyId` values. |
| 0 | 407 Orders must have same order type | The orders have the same currency but different `OrderType` values. |
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:pixiCanMergeOrders>
<TargetOrderNr>100234</TargetOrderNr>
<SourceOrderNr>100235</SourceOrderNr>
<!-- <CanMerge>?</CanMerge> -->
<!-- <Reason>?</Reason> -->
</ns1:pixiCanMergeOrders>
</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:pixiCanMergeOrders>
<TargetOrderNr>100234</TargetOrderNr>
<SourceOrderNr>100235</SourceOrderNr>
<!-- <CanMerge>?</CanMerge> -->
<!-- <Reason>?</Reason> -->
</ns1:pixiCanMergeOrders>
</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 = [
'TargetOrderNr' => '100234',
'SourceOrderNr' => '100235',
// 'CanMerge' => '?',
// 'Reason' => '?',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiCanMergeOrders', $soapArguments);
- SQL object:
- dbo.pipiCanMergeOrders