pixiSetInvoicePaid
Marks an invoice as paid by creating a manual booking event in the customer account and matching it against the invoice's open amount.
Wrapper around the internal procedure pixi_SetInvoicePaid. It returns a status row with Status and Message.
Steps of the internal procedure:
- Looks up the invoice in
InvoicesbyInvoiceNR. It reads the customer, the total, the paid sum, the currency and the exchange rate. - Determines the customer account entry of the invoice with
Pixi_CA_GetCustomerAccountforInvoice. The booking amount is the negatedOpenToMatchof that entry. - Validates the input in this order:
paidmust be1. Setting an invoice to unpaid is not supported.- The invoice must exist.
- The invoice must not be fully paid already (
total=PayedSum). eventIDmust be given.- The event must exist in
CustomerAccountEventswithIsManual = 1andOriginalAmountMultiply = 1, i.e. a manual, positive event. PaidDate(default: current date and time) must not lie in the future.
- Creates a manual booking event with
Pixi_CA_InsertManualBookingEvent:- The event uses the invoice's currency and exchange rate.
- The user name is
API. - The event is matched against the invoice's customer account entry.
On success the call returns Status = Success. If an error reaches the wrapper, it returns Status = Error with the error text.
Notes
PaidSumhas no effect on the booked amount. A value of0is replaced by NULL, but the parameter is not used otherwise. The booking always covers the full open amount (OpenToMatch) of the invoice's customer account entry.- The internal procedure runs in its own transaction, or in a savepoint if a transaction is already open.
XACT_ABORTis on, and the transaction is rolled back on error. - In its CATCH block the internal procedure calls
log.InsertErrorwith parameter1. That object is not attached. Whether it re-raises the error is therefore unknown. Only if it does will the wrapper return theErrorrow; otherwise a failed call could still reportSuccess. - The customer account lookup runs before the validation. For a non-existing invoice it is called with NULL keys.
InvoicesandCustomerAccountEventsare read withNOLOCK.- The tables written by
Pixi_CA_InsertManualBookingEventare not visible in the attached code. - The 'already paid' check compares
totalandPayedSumfor exact equality. A partially paid invoice is booked with its remaining open amount.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
InvoiceNR
Required
|
varchar(20) string |
– |
Number of the invoice to set to paid ( Example: |
paid
Required
|
bit boolean |
– |
Must be Allowed values
Example: |
PaidDate
|
datetime dateTime |
NULL |
Entry date of the booking. NULL uses the current date and time. Must not be in the future. Example: |
eventID
|
varchar(3) string |
NULL |
ID of the customer account event to book ( Example: |
PaidSum
|
money decimal |
NULL |
Paid amount. It is passed on but not used for the booking; the full open amount is always booked. Example: |
Result set 1 · On success
Status row confirming that the manual booking event was created.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(7) string |
Always |
Message
Nullable |
varchar(80) string |
Confirmation text containing the invoice number. |
Result set 2 · If an error reaches the wrapper's CATCH block
Status row with the error message.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(5) string |
Always |
Message
Nullable |
nvarchar(4000) string |
Text of the error ( |
Response example
<SqlRowSet1>
<row>
<Status>Success</Status>
<Message>Successfully created CA manual booking event for InvoiceNr RE2024001234</Message>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| Error | Feature "set invoice to unpaid" is not supported | `paid` was sent as `0`. Only setting to paid is supported. |
| Error | Invoice {InvoiceNr} does not exist | No invoice with the given number exists in `Invoices`. |
| Error | Invoice {InvoiceNr} is already set to paid | The invoice's paid sum already equals its total. |
| Error | Parameter @EventID is mandatory | `eventID` was not sent or is NULL. |
| Error | Event {eventID} either does not exist, is not manually added or is not positive | The event ID is not a manual, positive event in `CustomerAccountEvents`. Use an event with `IsManual = 1` and `OriginalAmountMultiply = 1`. |
| Error | Paid date is set into the future | `PaidDate` is later than the current server time. |
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:pixiSetInvoicePaid>
<InvoiceNR>RE2024001234</InvoiceNR>
<paid>1</paid>
<!-- <PaidDate>2024-05-14T10:30:00</PaidDate> -->
<!-- <eventID>MZE</eventID> -->
<!-- <PaidSum>119.00</PaidSum> -->
</ns1:pixiSetInvoicePaid>
</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:pixiSetInvoicePaid>
<InvoiceNR>RE2024001234</InvoiceNR>
<paid>1</paid>
<!-- <PaidDate>2024-05-14T10:30:00</PaidDate> -->
<!-- <eventID>MZE</eventID> -->
<!-- <PaidSum>119.00</PaidSum> -->
</ns1:pixiSetInvoicePaid>
</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',
'paid' => '1',
// 'PaidDate' => '2024-05-14T10:30:00',
// 'eventID' => 'MZE',
// 'PaidSum' => '119.00',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiSetInvoicePaid', $soapArguments);
- SQL object:
- dbo.pipiSetInvoicePaid