pixiAddReturnCaseLine
Adds a line for an invoice line to an existing return case, or creates a new empty return case if no return case ID is passed.
The call behaves differently depending on RET_ID.
RET_ID is NULL or 0
pixiCreateReturnCaseis executed withReturnDate,ReceiversCommentandEmployee. It creates a new return case header inRET_CASESwith statusNEWand returns itsRET_IDandRET_NUMBER.- No return line is added in this case. The new ID is not taken over internally. To add the line, the call has to be repeated with the returned
RET_ID.
RET_ID is set (not 0)
A row is inserted into RET_CASE_LINES only if all of these conditions are met:
- the invoice line
InvLineKeyexists and hasItemQty > 0; ItemQty >= QuantityToReturn;- the linked order line has status
AUS; - there is no credit note that refers to the same invoice (
RefToInvoiceKey) and contains a line for the same order line.
The new line gets these values:
- status
AOKifItemOk = 1, otherwiseDAM; - the customer comment, receiver comment and return reason, with
NULLstored as an empty string; - the quantity
QuantityToReturnand the reference to the invoice line; - create date
GETDATE()and create employee<Employee> (API), orAPIif no employee is given.
Afterwards the call always returns one row with the return case ID and the ID of the new line. If no line was inserted because a condition was not met, RET_LINE_ID is NULL.
Notes
- Pitfall: without
RET_IDonly an empty return case is created.InvLineKey,QuantityToReturn,ItemOk,ReturnReasonandCustomersCommentare ignored in that case. Use the returnedRET_IDin a second call. - The call raises no error if a condition fails. Check
RET_LINE_IDforNULLto detect that no line was inserted. - The code does not check whether the invoice line is already part of another return line. Repeated calls can create several return lines for the same invoice line, as long as each quantity is not larger than
ItemQty. - The code does not check whether the given
RET_IDexists, and it does not reject negative quantities. ReturnDateis only used when a new return case is created.ReceiversCommentis stored on the return case header when one is created, and on the line when a line is added.- If
ItemOkisNULL, the line gets statusDAM. - The invoice and order lines are read with
NOLOCK. - No explicit transaction is used.
Related calls
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
InvLineKey
Required
|
int | – |
Key of the invoice line ( Example: |
QuantityToReturn
Required
|
int | – |
Returned quantity. It must not be larger than the invoiced quantity Example: |
ItemOk
|
bit boolean |
1 |
Condition of the returned item. It determines the line status. Allowed values
Example: |
RET_ID
|
int | NULL |
ID of the existing return case that the line is added to. Example: |
ReturnReason
|
varchar(2048) string |
– |
Return reason stored on the line. Example: |
CustomersComment
|
varchar(2048) string |
– |
Comment of the customer, stored on the line. Example: |
ReceiversComment
|
varchar(2048) string |
– |
Comment of the receiving employee. It is stored on the new return case header, or on the line when a line is added. Example: |
Employee
|
varchar(50) string |
NULL |
Employee name. It is stored as Example: |
ReturnDate
|
datetime dateTime |
NULL |
Return date of a newly created return case. The default is the current date. It is ignored when Example: |
Result set 1 · If RET_ID is NULL or 0 (returned by pipiCreateReturnCase)
The newly created return case.
| Column | Type | Description |
|---|---|---|
RET_ID
|
int |
ID of the new return case. |
RET_NUMBER
Nullable |
string |
Number of the new return case. |
Result set 2 · If RET_ID is given and not 0
Result of adding the line.
| Column | Type | Description |
|---|---|---|
UPDATED_RETURN_ID
|
int |
ID of the return case (the passed |
RET_LINE_ID
Nullable |
numeric(38,0) decimal |
ID of the new return line. |
Response example
<SqlRowSet1>
<row>
<UPDATED_RETURN_ID>4711</UPDATED_RETURN_ID>
<RET_LINE_ID>98231</RET_LINE_ID>
</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:pixiAddReturnCaseLine>
<InvLineKey>123456</InvLineKey>
<QuantityToReturn>1</QuantityToReturn>
<!-- <ItemOk>1</ItemOk> -->
<!-- <RET_ID>4711</RET_ID> -->
<!-- <ReturnReason>Wrong size</ReturnReason> -->
<!-- <CustomersComment>Too small</CustomersComment> -->
<!-- <ReceiversComment>Packaging opened</ReceiversComment> -->
<!-- <Employee>JD</Employee> -->
<!-- <ReturnDate>2024-05-14T10:30:00</ReturnDate> -->
</ns1:pixiAddReturnCaseLine>
</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:pixiAddReturnCaseLine>
<InvLineKey>123456</InvLineKey>
<QuantityToReturn>1</QuantityToReturn>
<!-- <ItemOk>1</ItemOk> -->
<!-- <RET_ID>4711</RET_ID> -->
<!-- <ReturnReason>Wrong size</ReturnReason> -->
<!-- <CustomersComment>Too small</CustomersComment> -->
<!-- <ReceiversComment>Packaging opened</ReceiversComment> -->
<!-- <Employee>JD</Employee> -->
<!-- <ReturnDate>2024-05-14T10:30:00</ReturnDate> -->
</ns1:pixiAddReturnCaseLine>
</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 = [
'InvLineKey' => '123456',
'QuantityToReturn' => '1',
// 'ItemOk' => '1',
// 'RET_ID' => '4711',
// 'ReturnReason' => 'Wrong size',
// 'CustomersComment' => 'Too small',
// 'ReceiversComment' => 'Packaging opened',
// 'Employee' => 'JD',
// 'ReturnDate' => '2024-05-14T10:30:00',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiAddReturnCaseLine', $soapArguments);
- SQL object:
- dbo.pipiAddReturnCaseLine