Get or create a subledger account
const url = 'https://api.sancho-wms.pl/v1/ledgerAccounts.ensureSubledgerAccount';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"integrationId":1,"values":{"integrationType":"comarch-optima","fiscalYearId":1,"parentNumber":"example","entry":{"kind":"counterParty","id":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/ledgerAccounts.ensureSubledgerAccount \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "integrationId": 1, "values": { "integrationType": "comarch-optima", "fiscalYearId": 1, "parentNumber": "example", "entry": { "kind": "counterParty", "id": 1 } } }'Answers result, the account opened for entry below parentNumber as ledgerAccounts.get reads it, with warnings (empty for now), and opens the account when missing. parentNumber is the subledger parent that keeps one analytic account per counterparty (for example 202, or 202-1 where 202 is split); the new account takes its number and name from the counterparty card, by the company’s setting. Only a counterparty’s account is opened: entry.kind is counterParty and entry.id is the id counterParties.get takes. A parentNumber the chart does not have is 422 invalidReference at parentNumber. A parent that keeps no account per counterparty, or that splits its entries into groups, is 422 notSubledgerParentAccount, and the message names the subledger parents below it. An existing account for the entry that cannot take postings (inactive, or with analytic accounts below it) is 422 ledgerAccountNotPostable at parentNumber. A closed fiscal year is 422 periodLocked. An unknown entry.id is 404. proposedJournalEntry on accountingDocuments.create takes the same reference, { kind: "subledger", parentNumber, entry: { kind: "counterParty", id } }, and opens the account itself; call this to know the number first. 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.
Authorizations
Dział zatytułowany „Authorizations”Request Bodyrequired
Dział zatytułowany „Request Bodyrequired”object
object
object
Responses
Dział zatytułowany „Responses”Successful response
object
object
object
Example
{ "result": { "classification": "asset", "subledgerKind": "counterParty", "subledgerEntry": { "kind": "counterParty" }, "integrationType": "comarch-optima", "accountType": "asset" }, "warnings": [ { "stage": "placements" } ]}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": []}