cadrumo.application.ledger.check_query module

Whether a ledger is ready, and what is standing in the way.

Readiness draws on two independent sources: the preflight issues that block modelo calculation, and the one-sided invoice links that mean the two catalogues disagree with each other. A ledger is ready only when both are clean, and that conjunction is the decision this module owns.

It had been made three times in the CLI verb – once per branch, spelled differently each time (report.ready and not links, not issues and not links, not links). The three agree today only because the preflight’s ready happens to be not issues; nothing held them together, and a second frontend asking “is my ledger ready” would have had to pick one of the three spellings to copy.

Choosing the periods to check is the other decision here. With no period given the sweep covers every year the ledger actually spans, derived from the transactions themselves rather than a calendar assumption, and each year is checked over its annual period.

class LedgerCheckV1(**data)[source]

Bases: BaseModel

One readiness verdict with the findings that produced it.

Parameters:

data (Any)

bucket_id: str
periods: tuple[str, ...]
checked_transaction_count: NonNegativeInt
issues: tuple[LedgerPreflightIssue, ...]
ready: bool
ledger_check_years(transactions)[source]

Return every filing year the stored transactions actually fall in.

Derived from the rows rather than assumed from a calendar, so a sweep never reports on a year the operator has no ledger for, and never misses one they do. booked_date is required, so the fallback always yields a date.

Core types: TransactionCatalogue.

Return type:

tuple[int, ...]

Parameters:

transactions (TransactionCatalogue)

read_ledger_check(*, bucket_id, transactions, ports, operation, period=None)[source]

Assess one ledger’s readiness over a period, or over everything it spans.

Parameters:
  • bucket_id (str) – The owning profile bucket.

  • transactions (TransactionCatalogue) – The live ledger to assess.

  • ports (InvoiceCatalogueReadPorts) – Required invoice and transaction catalogue read capabilities.

  • operation (PinnedAuthorityOperation) – Caller-owned generation-pinned authority for preflight facts.

  • period (Period | None) – One period to check; when omitted, every year the ledger spans is swept over its annual period.

Return type:

LedgerCheckV1

Returns:

The verdict, the periods it covers, and the findings behind it.

Core types: TransactionCatalogue.