Zum Inhalt springen

Create ledger accounts

POST
/ledgerAccounts.create
curl --request POST \
--url https://api.sancho-wms.pl/v1/ledgerAccounts.create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "integrationId": 1, "values": { "integrationType": "comarch-optima", "fiscalYearId": 1, "parentNumber": "example", "levels": [ { "segment": "example", "name": "example" } ] } }'

Gets or creates analytic accounts below an existing account, one level after another: parentNumber “402” with levels “01” and “05” ends at 402-01-05. Each level is looked up by its number first, so a retry writes nothing more and an existing level keeps its name. Answers result, the last level’s account as ledgerAccounts.get reads it after the write, with warnings (empty for now). A synthetic account is never created: a missing parentNumber is 422 invalidReference at parentNumber. A subledger parent is 422 subledgerParentAccount (its analytic accounts are opened one per entry; use /ledgerAccounts.ensureSubledgerAccount), an account that already holds postings or an opening balance is 422 ledgerAccountHasEntries, and a closed fiscal year is 422 periodLocked. An account exists in the fiscal year it was created in only. A company without double-entry books (bookkeeping kpir or ryczalt) has no chart and answers 422 with the reason notDoubleEntry. Opening accounts also needs the ERP’s general-ledger module on the integration’s login (ledgerLicensed on accounting.profile), even when every account already exists: 422 ledgerNotLicensed without it.

Media typeapplication/json
object
integrationId
required
number
values
required
LedgerAccountWrite
One of: discriminator: integrationType
ComarchOptimaLedgerAccountWrite
object
integrationType
required
string
Allowed value: comarch-optima
fiscalYearId
required
integer
> 0 <= 9007199254740991
parentNumber
required
string
>= 1 characters <= 50 characters
levels
required
Array<object>
>= 1 items
object
segment
required
string
>= 1 characters <= 20 characters /^[^-]+$/
name
required
string
>= 1 characters <= 50 characters

Successful response

Media typeapplication/json
LedgerAccountWriteResult
object
result
required
LedgerAccount
One of: discriminator: integrationType
ComarchOptimaLedgerAccount
object
id
required
number
fiscalYearId
required
number | null
parentId
required
number | null
number
required
string
name
required
string
level
required
number
classification
required
string
Allowed values: asset liability equity revenue expense offBalance other
isPostable
required
boolean
isSettlementAccount
required
boolean
active
required
boolean
currency
required
string
subledgerKind
required
Any of:
string
Allowed values: counterParty bank employee shareholder taxAuthority other fixedAsset product
subledgerEntry
required
Any of:
object
kind
required
string
Allowed values: counterParty bank employee shareholder taxAuthority other fixedAsset product
id
required
number
integrationId
required
number
integrationType
required
string
Allowed value: comarch-optima
accountType
required
string
Allowed values: asset liability assetLiability revenue cost offBalance revenueCost
segment
required
string
isAnalytical
required
boolean
warnings
required
Array<object>
WriteWarning
object
stage
required
string
Allowed values: placements documents tags participants images assetExtras
detail
required
string

Example

{
"result": {
"classification": "asset",
"subledgerKind": "counterParty",
"subledgerEntry": {
"kind": "counterParty"
},
"integrationType": "comarch-optima",
"accountType": "asset"
},
"warnings": [
{
"stage": "placements"
}
]
}

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": []
}