pixiDeleteInvoicePackage
Deletes a shipping package and its package lines from an invoice and updates the invoice's tracking IDs and package count.
Removes one package record (pixi.InvoicePackage) that belongs to an invoice (Rechnung), for example after a shipping label was cancelled.
The call runs these checks in order and returns a single Response row in every case:
- The package
PackageIdmust exist. Otherwise:400 Bad Request - Package ID does not exist. - The package must belong to the invoice
InvoiceKey. Otherwise:400 Bad Request - Invoice ID does not match the package. - The invoice must have more than one package. The last remaining package of an invoice cannot be deleted:
400 Bad Request - This is the last package for invoice and delete is not allowed.
If all checks pass:
- all package lines (
pixi.InvoicePackageLines) of the package are deleted, - the package itself is deleted,
- in
Invoicesthe package's tracking ID followed by;is removed fromShipmentTrackingID, andPackagesis set to the number of packages that remain for the invoice, 200 OKis returned.
Notes
- All changes run in a transaction (or a savepoint if the caller already has an open transaction). On any SQL error the changes are rolled back, the error is logged via
log.InsertErrorand500 Internal Server Erroris returned as a normal row, not as aSqlMessage. - The existence and count checks read
pixi.InvoicePackagewithNOLOCK, so concurrent changes may not be seen. - The tracking ID is only removed from
ShipmentTrackingIDwhen it is followed by;. A tracking ID at the end of the list without a trailing semicolon stays in the field.REPLACEremoves every occurrence of the pattern. - If the package has no
TrackingID(NULL), theREPLACEexpression yields NULL, soShipmentTrackingIDof the invoice is set to NULL. ReturnTrackingIdof the package is read but not removed from the invoice.- Passing NULL for
InvoiceKeyalways leads to the "does not match" response.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
PackageId
Required
|
int | – |
ID of the package to delete ( Example: |
InvoiceKey
Required
|
int | – |
Key of the invoice the package belongs to. Must match Example: |
Result set 1 · Always (exactly one row).
Status of the call in HTTP-like form.
| Column | Type | Description |
|---|---|---|
Response
|
varchar(100) string |
|
Response example
<SqlRowSet1>
<row>
<Response>200 OK</Response>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| 400 | 400 Bad Request - Package ID does not exist. | No package with the given `PackageId` exists. Check the package ID. |
| 400 | 400 Bad Request - Invoice ID does not match the package. | The package belongs to a different invoice than `InvoiceKey`, or `InvoiceKey` is NULL. Pass the invoice key of the package. |
| 400 | 400 Bad Request - This is the last package for invoice and delete is not allowed. | The invoice has only this one package; the last package of an invoice cannot be deleted. |
| 500 | 500 Internal Server Error | An unexpected SQL error occurred; all changes were rolled back and the error was logged. |
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:pixiDeleteInvoicePackage>
<PackageId>4711</PackageId>
<InvoiceKey>123456</InvoiceKey>
</ns1:pixiDeleteInvoicePackage>
</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:pixiDeleteInvoicePackage>
<PackageId>4711</PackageId>
<InvoiceKey>123456</InvoiceKey>
</ns1:pixiDeleteInvoicePackage>
</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 = [
'PackageId' => '4711',
'InvoiceKey' => '123456',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiDeleteInvoicePackage', $soapArguments);
- SQL object:
- dbo.pipiDeleteInvoicePackage