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
ManualLedgerTransactionResultreflecting the archived transaction state.- Return type:
- Parameters:
bucket_id (str)
transaction_id (str)
actor (str)
reason (str)
source_command (str)
transaction_repository (TransactionCatalogueRepositoryProtocol | None)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
work_unit_repository (WorkUnitCatalogueRepositoryProtocol | None)
calculation_repository (CalculationRevisionCatalogueRepositoryProtocol | None)
occurred_at (datetime | None)
- 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
ManualLedgerTransactionResultreflecting the stashed transaction state.- Return type:
- Parameters:
bucket_id (str)
transaction_id (str)
actor (str)
reason (str)
source_command (str)
transaction_repository (TransactionCatalogueRepositoryProtocol | None)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
work_unit_repository (WorkUnitCatalogueRepositoryProtocol | None)
calculation_repository (CalculationRevisionCatalogueRepositoryProtocol | None)
occurred_at (datetime | None)
- 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()andstash_manual_transaction(). MovesSTASHED -> ACTIVEandARCHIVED -> ACTIVEthrough 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 - onlysplit_transaction()/merge_transactions()move those rows.Returns a
ManualLedgerTransactionResultreflecting 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:
- Parameters:
bucket_id (str)
transaction_id (str)
actor (str)
reason (str)
source_command (str)
transaction_repository (TransactionCatalogueRepositoryProtocol | None)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
work_unit_repository (WorkUnitCatalogueRepositoryProtocol | None)
calculation_repository (CalculationRevisionCatalogueRepositoryProtocol | None)
occurred_at (datetime | None)
- 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_classificationtoREVIEWED_EXCLUDED— the operator’s assertion “I reviewed this, it is not filing-relevant, stop surfacing it.” The row staysACTIVEand visible in the ledger with review statusexcluded, 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
ManualLedgerTransactionResultcarrying the uniform mutation quintet.- Raises:
TransactionValidationError – when the row is not
ACTIVE, when it is alreadyREVIEWED_EXCLUDED, or when a finalized-modelo reference blocks the exclusion.TransactionNotFoundError – when no transaction matches
transaction_id.
- Return type:
- Parameters:
bucket_id (str)
transaction_id (str)
actor (str)
reason (str)
source_command (str)
transaction_repository (TransactionCatalogueRepositoryProtocol | None)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
work_unit_repository (WorkUnitCatalogueRepositoryProtocol | None)
calculation_repository (CalculationRevisionCatalogueRepositoryProtocol | None)
occurred_at (datetime | None)
- 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
LedgerTransactionRemovalReportindicating whether the transaction was removed or blocked by a finalized-modelo reference.- Return type:
- Parameters:
bucket_id (str)
transaction_id (str)
actor (str)
reason (str)
dry_run (bool)
source_command (str)
transaction_repository (TransactionCatalogueRepositoryProtocol | None)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
invoice_repository (InvoiceCatalogueRepositoryProtocol | None)
work_unit_repository (WorkUnitCatalogueRepositoryProtocol | None)
calculation_repository (CalculationRevisionCatalogueRepositoryProtocol | None)
occurred_at (datetime | None)
- 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:
- Parameters:
bucket_id (str)
actor (str)
reason (str)
dry_run (bool)
source_command (str)
transaction_repository (TransactionCatalogueRepositoryProtocol | None)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
invoice_repository (InvoiceCatalogueRepositoryProtocol | None)
work_unit_repository (WorkUnitCatalogueRepositoryProtocol | None)
calculation_repository (CalculationRevisionCatalogueRepositoryProtocol | None)
occurred_at (datetime | None)