Settle two cash documents
const url = 'https://api.sancho-wms.pl/v1/settlements.create';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"integrationId":1,"importSource":{"appId":"example","rowId":"example"},"values":{"integrationType":"comarch-optima","sides":["example"],"amount":1}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sancho-wms.pl/v1/settlements.create \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "integrationId": 1, "importSource": { "appId": "example", "rowId": "example" }, "values": { "integrationType": "comarch-optima", "sides": [ "example" ], "amount": 1 } }'Settles amount of two documents against each other: a transaction against a cash-flow item, a cash-flow item against its correction, or two transactions. importSource names the application the record comes from (appId) and its key there (rowId), which the ERP keeps as the record’s import mark. The ERP refuses a rowId it already holds, whatever the appId or letter case (422 duplicateDocument). A create is never replayed: after a lost answer, find the record by importAppId and importRowId before sending again. The amount may be part of either document, never more than what is left on it (settlementExceedsRemaining); both must be in the same currency (settlementCurrencyMismatch) and subject to settlement (settlementNotApplicable). The ERP keeps these amounts to two decimals, from 0.01 to 9999999999999.99. An amount within 0.00000001 of two decimals (a little more for very large amounts, where a number cannot be told apart more finely) is written rounded to two decimals: 0.30000000000000004 as 0.3, 0.010000001 as 0.01. An amount further from two decimals is 422 notSupported at its path, and so is one that rounds to zero or to more than 9999999999999.99. An ERP that keeps the ledger’s settlement items apart from its cash-flow items mirrors a settlement into the ledger itself in a company with double-entry books; when that fails the write still stands and warnings carries stage ledgerSyncFailed with the ERP’s own text.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
object
object
Responses
Section titled “Responses”Successful response
object
object
object
object
Example
{ "result": { "integrationType": "comarch-optima" }, "warnings": [ { "stage": "ledgerSyncFailed" } ]}Bad request
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "BAD_REQUEST", "message": "Bad request", "issues": []}Unauthorized
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "UNAUTHORIZED", "message": "Unauthorized", "issues": []}Payment required
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "PAYMENT_REQUIRED", "message": "Payment required", "issues": []}Forbidden
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "FORBIDDEN", "message": "Forbidden", "issues": []}Not found
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "NOT_FOUND", "message": "Not found", "issues": []}Conflict
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "CONFLICT", "message": "Conflict", "issues": []}Unprocessable content
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "UNPROCESSABLE_CONTENT", "message": "Unprocessable content", "issues": []}Too many requests
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "TOO_MANY_REQUESTS", "message": "Too many requests", "issues": []}Internal server error
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error", "issues": []}Service unavailable
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "SERVICE_UNAVAILABLE", "message": "Service unavailable", "issues": []}