Accounting Periods
2 operações em Quadra Core API 0.5.0.
/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
| Nome | Tipo | Detalhe |
|---|---|---|
| scope_id | string | pathobrigatório |
| state | string, opcional | query OPEN | CLOSED | REOPENED |
| from | string, opcional | query YYYY-MM |
| to | string, opcional | query YYYY-MM |
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 200 | AccountingPeriodListResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro de validação |
/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
| Nome | Tipo | Detalhe |
|---|---|---|
| scope_id | string | pathobrigatório |
| yyyy_mm | string | pathobrigatório |
Respostas
| Status | Corpo | Detalhe |
|---|---|---|
| 200 | AccountingPeriodResponse | Resposta bem-sucedida |
| 422 | HTTPValidationError | Erro 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.
| Campo | Tipo | Detalhe |
|---|---|---|
| coverage | string | obrigató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. |
| items | array de AccountingPeriodResponse | |
| scope_id | string | obrigatório |
AccountingPeriodResponse
One accounting period. ⛔ Never 404 — absence is OPEN (RFC-028 §2 D2).
| Campo | Tipo | Detalhe |
|---|---|---|
| close_seq | integer | Closes performed so far; 0 while never closedPadrão 0 |
| closes | array de object | Every 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_at | string, opcional | |
| last_closed_at | string, opcional | |
| last_closed_by | string, opcional | |
| last_reopen_reason | string, opcional | |
| last_reopened_at | string, opcional | |
| last_reopened_by | string, opcional | |
| period | string | obrigatórioYYYY-MM in the América/São_Paulo accounting-day frame |
| reopen_count | integer | How many times this period has been reopenedPadrão 0 |
| scope_id | string | obrigatórioThe account this period belongs to (RFC-028 §1 D1) |
| state | string | obrigatórioOPEN | CLOSED | REOPENED |
| state_history | array de object | Every state transition, in order |
| synthesized | boolean | obrigató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_at | string, opcional | |
| window_from | string, opcional | First accounting day in the window |
| window_to | string, opcional | Last accounting day (inclusive) |
HTTPValidationError
| Campo | Tipo | Detalhe |
|---|---|---|
| detail | array de ValidationError |
ValidationError
| Campo | Tipo | Detalhe |
|---|---|---|
| ctx | object | |
| input | não declarado | |
| loc | array de string ou integer | obrigatório |
| msg | string | obrigatório |
| type | string | obrigatório |