aeat.application.ledger._actions_lifecycle module

Lifecycle services for bucket-scoped manual ledger transactions.

Archive, stash, restore, remove, and reset operations mutate a loaded TransactionCatalogue, append bucket events, and return typed application reports. Removal and reset paths can also update an InvoiceCatalogue through an InvoiceCatalogueRepository when purchase-invoice evidence must be detached.

The public services return ManualLedgerTransactionResult, LedgerTransactionRemovalReport, or LedgerCatalogueResetReport.

archive_manual_transaction(*, bucket_id, transaction_id, actor, reason='', source_command='aeat app ledger archive', transaction_repository=None, bucket_event_repository=None, work_unit_repository=None, calculation_repository=None, occurred_at=None)[source]

Mark one bucket-scoped ledger transaction as archived.

Returns a ManualLedgerTransactionResult reflecting the archived transaction state.

Return type:

ManualLedgerTransactionResult

Parameters:
stash_manual_transaction(*, bucket_id, transaction_id, actor, reason='', source_command='aeat app ledger stash', transaction_repository=None, bucket_event_repository=None, work_unit_repository=None, calculation_repository=None, occurred_at=None)[source]

Mark one active bucket-scoped ledger transaction as stashed.

Returns a ManualLedgerTransactionResult reflecting the stashed transaction state.

Return type:

ManualLedgerTransactionResult

Parameters:
restore_manual_transaction(*, bucket_id, transaction_id, actor, reason='', source_command='aeat app ledger restore', transaction_repository=None, bucket_event_repository=None, work_unit_repository=None, calculation_repository=None, occurred_at=None)[source]

Restore one stashed or archived ledger transaction to active.

The clean inverse of archive_manual_transaction() and stash_manual_transaction(). Moves STASHED -> ACTIVE and ARCHIVED -> ACTIVE through the single-writer _transition_manual_transaction_lifecycle() primitive, so it inherits that primitive’s atomic catalogue-plus-event persistence, its lifecycle-lineage append, and the finalized-modelo guard: a row cited by a sealed (VERIFICADO_COMPLETO / PRESENTADO / PRESENTADO_SUPERSEDIDO) calculation revision is refused so a restore cannot silently change the input basis of an already-filed period. Split and merged lineage stays out of scope - only split_transaction() / merge_transactions() move those rows.

Returns a ManualLedgerTransactionResult reflecting the restored, now-active transaction state.

Raises:
  • TransactionValidationError – when the row is already active (with an instructive message), when the row is part of split lineage, or when a finalized-modelo reference blocks the restore.

  • TransactionNotFoundError – when no transaction matches transaction_id.

Return type:

ManualLedgerTransactionResult

Parameters:
mark_transaction_reviewed_excluded(*, bucket_id, transaction_id, actor, reason='', source_command='aeat app ledger exclude', transaction_repository=None, bucket_event_repository=None, work_unit_repository=None, calculation_repository=None, occurred_at=None)[source]

Mark one active ledger transaction as reviewed and excluded from filing.

Sets the transaction’s business_classification to REVIEWED_EXCLUDED — the operator’s assertion “I reviewed this, it is not filing-relevant, stop surfacing it.” The row stays ACTIVE and visible in the ledger with review status excluded, drops out of the review queue, and is omitted from every tax aggregation. The operator re-includes it by re-classifying the row (aeat app ledger classify).

The finalized-modelo guard refuses the exclusion when the row is cited by a sealed (VERIFICADO_COMPLETO / PRESENTADO / PRESENTADO_SUPERSEDIDO) calculation revision, so an exclusion cannot silently change the input basis of an already-filed period.

Returns a ManualLedgerTransactionResult carrying the uniform mutation quintet.

Raises:
Return type:

ManualLedgerTransactionResult

Parameters:
remove_manual_transaction(*, bucket_id, transaction_id, actor, reason='', dry_run=False, source_command='aeat app ledger remove', transaction_repository=None, bucket_event_repository=None, invoice_repository=None, work_unit_repository=None, calculation_repository=None, occurred_at=None)[source]

Remove one bucket-scoped ledger transaction after finalized-modelo checks.

Returns a LedgerTransactionRemovalReport indicating whether the transaction was removed or blocked by a finalized-modelo reference.

Return type:

LedgerTransactionRemovalReport

Parameters:
reset_ledger_catalogue(*, bucket_id, actor, reason='', dry_run=False, source_command='aeat app ledger reset', transaction_repository=None, bucket_event_repository=None, invoice_repository=None, work_unit_repository=None, calculation_repository=None, occurred_at=None)[source]

Reset one bucket’s ledger catalogue after finalized-modelo checks.

Returns a LedgerCatalogueResetReport.

Return type:

LedgerCatalogueResetReport

Parameters: