pixiCADeleteEvent
Deletes a customer account event (CustomerAccount entry) together with its invoice, bank matches and account matches, if deletion is allowed.
Deletes one event from the customer account (CustomerAccount), identified by its key CAref.
Steps:
- The common API envelope checks the call frequency limit. If the limit is exceeded, a
ResultCode/ResultTextrow with code502is returned and nothing else happens. - If
CArefis NULL, a row withReturnCode = 'ERROR'is returned. - Otherwise the internal procedure
Pixi_CA_DeleteEventruns with the user nameAPIinside a transaction:- The function
fPixi_CA_canIdeleteEventdecides whether the event may be deleted. If not, nothing is changed andSuccess = 0is returned. - If the event has a linked invoice (
InvoiceRef), the invoice is deleted viaPixi_DeleteInvoice. - Bank matches (
BankMatch) of the linked bank line (BanklineRef) are deleted. UpdateEmp/UpdateDateare stamped on the event and on allCustomerAccountMatchrows where the event isCAref1orCAref2. Those match rows are then deleted.- The
CustomerAccountrow itself is deleted. - Afterwards the code tries to clean up a linked
DTAUSrecord (only if its state allows deletion) or a linked manual booking (CustomerAccountManualBookings).
- The function
- A row with
Success(1 = deleted, 0 = not deleted) andErrorMessageis returned.
Notes
- All changes run in one transaction; on any error it is rolled back, the error is re-raised with
RAISERROR(severity 16, returned asSqlMessage) and a row withSuccess = 0and the error text is still returned. - The rules of
fPixi_CA_canIdeleteEventand the behaviour ofPixi_DeleteInvoiceare not attached; which events are deletable and whether the invoice deletion returns additional result sets cannot be determined from this code. - The lookup of the linked
DTAUSrecord and manual booking readsDTAUSref/ManualBookingReffromCustomerAccountafter that row has already been deleted, so in practice these subqueries find nothing. A code comment states that a trigger handles deleting fromDTAUSandCustomerAccountManualBookings; that trigger is not attached. - If deletion is not allowed, the internal procedure only issues a
PRINT('Event CANNOT Be Deleted'), which is not visible as a row; checkSuccess = 0. ResultCode/ResultTextoutput parameters carry the envelope result (200/OKon normal execution).- Reads use
NOLOCK, writes useROWLOCK. Each call updatesAPI_STATISTICS.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
CAref
Required
|
int | – |
Key of the customer account event ( Example: |
ResultCode
OUTPUT
|
char(3) string |
NULL |
Output: result code of the API envelope, |
ResultText
OUTPUT
|
varchar(1024) string |
NULL |
Output: result text of the API envelope, |
Result set 1 · If the call frequency limit is exceeded (code 502)
Status row from the API envelope; no deletion takes place.
| Column | Type | Description |
|---|---|---|
ResultCode
|
char(3) string |
|
ResultText
|
varchar(1024) string |
Message with the remaining wait time in milliseconds. |
Result set 2 · If CAref is NULL
Error row for a missing key.
| Column | Type | Description |
|---|---|---|
ReturnCode
|
varchar(5) string |
Always |
ErrorMessage
|
varchar(20) string |
|
Result set 3 · If CAref is given and the envelope returned 200
Result of the deletion attempt.
| Column | Type | Description |
|---|---|---|
Success
Nullable |
int |
|
ErrorMessage
Nullable |
nvarchar(4000) string |
Empty string on success or when deletion is not allowed; the SQL error text if an error occurred. |
Response example
<SqlRowSet1>
<row>
<Success>1</Success>
<ErrorMessage/>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| 502 | ({value}) Frequency quote exceeded. Next call to this function can be made in ca. {value} milliseconds | The call was made again before the minimum interval configured in `API_CONTROL` had passed. Wait the given time and retry. |
| ERROR | CAref cannot be NULL | `CAref` was not passed or is NULL. Pass the key of the customer account event. |
| RAISERROR | Pixi_CA_DeleteEvent: deleting of DTAUS record not allowed | A linked DTAUS record could not be deleted because its state does not allow deletion. The transaction is rolled back and a row with `Success = 0` follows. |
| RAISERROR | {value} | Any other SQL error during deletion (e.g. in `Pixi_DeleteInvoice`) is re-raised with its original text; the transaction is rolled back and `Success = 0` is returned with the same text. |
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:pixiCADeleteEvent>
<CAref>123456</CAref>
<!-- <ResultCode>?</ResultCode> -->
<!-- <ResultText>?</ResultText> -->
</ns1:pixiCADeleteEvent>
</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:pixiCADeleteEvent>
<CAref>123456</CAref>
<!-- <ResultCode>?</ResultCode> -->
<!-- <ResultText>?</ResultText> -->
</ns1:pixiCADeleteEvent>
</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 = [
'CAref' => '123456',
// 'ResultCode' => '?',
// 'ResultText' => '?',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiCADeleteEvent', $soapArguments);
- SQL object:
- dbo.pipiCADeleteEvent