Zum Inhalt springen

Settle two cash documents

POST
/settlements.create
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.

Media typeapplication/json
object
integrationId
required
number
importSource
required
Any of:
ImportSourceWrite
object
appId
required
string
/^[A-Za-z0-9._:-]{1,5}$/
rowId
required
string
/^[A-Za-z0-9._:-]{1,36}$/
values
required
SettlementWrite
One of: discriminator: integrationType
ComarchOptimaSettlementWrite
object
integrationType
required
string
Allowed value: comarch-optima
sides
required
array
>= 2 items <= 2 items
amount
required
number
> 0

Successful response

Media typeapplication/json
SettlementWriteResult
object
result
required
Settlement
One of: discriminator: integrationType
ComarchOptimaSettlement
object
id
required
number
number
required
string | null
date
required
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
amount
required
number
currency
required
string
exchangeDifferenceBase
required
number
sides
required
array
>= 2 items <= 2 items
importSource
required
Any of:
ImportSourceOutput
object
appId
required
string
rowId
required
string
createdAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
modifiedAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
modifiedBy
required
string | null
integrationId
required
number
integrationType
required
string
Allowed value: comarch-optima
ledgerSettlementItemId
required
number | null
automatic
required
boolean
warnings
required
Array<object>
CashWriteWarning
object
stage
required
string
Allowed values: ledgerSyncFailed
detail
required
string

Example

{
"result": {
"integrationType": "comarch-optima"
},
"warnings": [
{
"stage": "ledgerSyncFailed"
}
]
}

Bad request

Media typeapplication/json
error.BAD_REQUEST

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "BAD_REQUEST",
"message": "Bad request",
"issues": []
}

Unauthorized

Media typeapplication/json
error.UNAUTHORIZED

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "UNAUTHORIZED",
"message": "Unauthorized",
"issues": []
}

Payment required

Media typeapplication/json
error.PAYMENT_REQUIRED

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "PAYMENT_REQUIRED",
"message": "Payment required",
"issues": []
}

Forbidden

Media typeapplication/json
error.FORBIDDEN

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "FORBIDDEN",
"message": "Forbidden",
"issues": []
}

Not found

Media typeapplication/json
error.NOT_FOUND

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "NOT_FOUND",
"message": "Not found",
"issues": []
}

Conflict

Media typeapplication/json
error.CONFLICT

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "CONFLICT",
"message": "Conflict",
"issues": []
}

Unprocessable content

Media typeapplication/json
error.UNPROCESSABLE_CONTENT

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "UNPROCESSABLE_CONTENT",
"message": "Unprocessable content",
"issues": []
}

Too many requests

Media typeapplication/json
error.TOO_MANY_REQUESTS

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "TOO_MANY_REQUESTS",
"message": "Too many requests",
"issues": []
}

Internal server error

Media typeapplication/json
error.INTERNAL_SERVER_ERROR

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}

Service unavailable

Media typeapplication/json
error.SERVICE_UNAVAILABLE

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "SERVICE_UNAVAILABLE",
"message": "Service unavailable",
"issues": []
}