SonaCORE

Referência / Quadra Core API

Accounting Periods

2 operações em Quadra Core API 0.5.0.

GET/v1/accounting-periods/{scope_id}

List an account's accounting periods

List the accounting periods of one account (``scope_id`` is an ``account_id`` — RFC-028 §1 D1 fixes the scope axis as an account, never a GL node).

⭐ **Two coverages, and which one you get is a property of the request.**

* No ``from``/``to`` → ``coverage: "materialized"``. Only months that carry a row. ⚠️ A month that has never been closed **has no row** (§2 D2), so it cannot appear here — an empty list means "nothing has ever been closed", never "nothing is open". * Both ``from`` and ``to`` → ``coverage: "enumerated"``. Every calendar month in the inclusive window, with ``OPEN`` materialised for the gaps. Capped at 120 months.

⭐ ``?state=OPEN`` without a window is a 400, on purpose: OPEN is the absence of a row, so there is no stored set of open months to return, and answering ``[]`` would be believed.

Raises: 400: INVALID_PERIOD, INVALID_QUERY 404: ACCOUNT_NOT_FOUND

Parâmetros

NomeTipoDetalhe
scope_idstringpathobrigatório
statestring, opcionalquery OPEN | CLOSED | REOPENED
fromstring, opcionalquery YYYY-MM
tostring, opcionalquery YYYY-MM

Respostas

StatusCorpoDetalhe
200AccountingPeriodListResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação
GET/v1/accounting-periods/{scope_id}/{yyyy_mm}

Read one accounting period (absence is OPEN)

One period's state and its close records.

⛔ **A month that has never been closed returns 200, not 404.** Nothing is written when a month begins, so absence *is* ``OPEN`` (RFC-028 §2 D2) and this read materialises it, with ``synthesized: true`` so a caller can tell a live answer from a stored one without re-implementing the state machine.

⛔ ``closes`` is append-only: reopening leaves every prior record in place, and closing again adds another. That is what makes a reopened period diffable against its previous close (§5 D5).

Raises: 400: INVALID_PERIOD 404: ACCOUNT_NOT_FOUND (the account — never the period)

Parâmetros

NomeTipoDetalhe
scope_idstringpathobrigatório
yyyy_mmstringpathobrigatório

Respostas

StatusCorpoDetalhe
200AccountingPeriodResponseResposta bem-sucedida
422HTTPValidationErrorErro de validação

Esquemas

Os modelos que as operações acima aceitam e devolvem. Campos opcionais estão marcados como tal; um campo tipado como outro modelo está documentado sob o nome dele.

AccountingPeriodListResponse

An account's accounting periods, in one of two explicit coverages.

CampoTipoDetalhe
coveragestringobrigatório'materialized' — only months carrying a row. ⚠️ A month that has never been closed has none (RFC-028 §2 D2), so it cannot appear: an empty list means 'nothing has ever been closed', never 'nothing is open'. 'enumerated' — every calendar month in the requested window, with OPEN filled in for the gaps. Supply both 'from' and 'to' for it.
itemsarray de AccountingPeriodResponse
scope_idstringobrigatório

AccountingPeriodResponse

One accounting period. ⛔ Never 404 — absence is OPEN (RFC-028 §2 D2).

CampoTipoDetalhe
close_seqintegerCloses performed so far; 0 while never closedPadrão 0
closesarray de objectEvery close record, in close order. ⛔ Append-only: reopening leaves prior records in place and closing again adds another, which is what makes a reopened period diffable against its previous close.
created_atstring, opcional
last_closed_atstring, opcional
last_closed_bystring, opcional
last_reopen_reasonstring, opcional
last_reopened_atstring, opcional
last_reopened_bystring, opcional
periodstringobrigatórioYYYY-MM in the América/São_Paulo accounting-day frame
reopen_countintegerHow many times this period has been reopenedPadrão 0
scope_idstringobrigatórioThe account this period belongs to (RFC-028 §1 D1)
statestringobrigatórioOPEN | CLOSED | REOPENED
state_historyarray de objectEvery state transition, in order
synthesizedbooleanobrigatórioTrue when this period has no stored row and was materialised as OPEN. Nothing is written when a month begins, so absence IS open — this flag is what lets a caller tell a live answer from a stored one.
updated_atstring, opcional
window_fromstring, opcionalFirst accounting day in the window
window_tostring, opcionalLast accounting day (inclusive)

HTTPValidationError

CampoTipoDetalhe
detailarray de ValidationError

ValidationError

CampoTipoDetalhe
ctxobject
inputnão declarado
locarray de string ou integerobrigatório
msgstringobrigatório
typestringobrigatório