aeat.application.review._aggregator module

Cross-source review-queue aggregator.

Provides ReviewQueue, which combines the per-source adapters in aeat.application.review._adapters into one deterministically sorted tuple of aeat.application.review.ReviewItem values.

class ReviewQueue[source]

Bases: object

Static collector that aggregates pending review items across sources.

Combines the per-source adapters (transactions_pending(), invoices_pending(), drafts_pending()) into one deterministically sorted tuple. Severity is the primary sort key; since and item_id provide stable tiebreakers.

static collect(settings, *, bucket_id, kinds=None, modelo=None, state=ReviewState.PENDING, confidence_below=None)[source]

Return every pending review item that matches the filters.

Parameters:
  • settings (Settings) – Loaded aeat.core.config.Settings.

  • bucket_id (str) – Active bucket identifier used to scope the query to the correct operator profile.

  • kinds (frozenset[ReviewItemKind] | None) – Optional set of ReviewItemKind to include. None (default) means every kind. The argument is a frozenset so callers cannot mutate it after passing.

  • modelo (str | None) – Optional modelo filter. When set, items whose wrapped record has no modelo concept are excluded.

  • state (ReviewState) – ReviewState.PENDING (default) or ReviewState.ALL. ALL returns the same set as PENDING while the adapters emit pending review items.

  • confidence_below (Decimal | None) – Optional decision-confidence threshold. When set, the queue replaces the default transactions-pending source with transactions_low_confidence(): classified transactions whose classification_confidence is non-None and strictly less than the threshold. Other review kinds (invoices, findings) cannot satisfy a decision-confidence predicate and are excluded while this filter is active.

Return type:

tuple[TransactionReviewItem | InvoiceReviewItem | FindingReviewItem, ...]

Returns:

A tuple sorted by (severity desc, since asc, item_id asc).