dodil/erp-brick-consolidation

DODIL ERP brick: consolidation

src/brick_consolidation/domain/events.py

"""Domain events: one per workflow transition, named for what happened. An aggregate records them in
`.events`; nothing publishes them yet — a brick that needs another to react calls its seam.
Generated by `erp-compose scaffold` from module.yaml.
"""
from dataclasses import dataclass


@dataclass(frozen=True)
class GroupPeriodOpen:
    """open_group_period: group_period none → open. scope and methods fixed from the structure in force on the
    period's last day; for a year's first period the group carry-forward derived (CON-15)
    """
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodUpdated:
    """upload_reported_data: group_period open → open. rows stored with source upload, waiting for acceptance
    (CON-12)
    """
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodUpdatedFromOpen:
    """accept_reported_upload: group_period open → open. the rows become the company's reported data"""
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodCollected:
    """collect_group_data: group_period open → collected. reported data with gl's digest per company (CON-03)"""
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodUpdatedFromCollected:
    """recollect_group_data: group_period collected, translated, eliminated → collected. later steps stale; the
    next runs take run_no + 1 (CON-20)
    """
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodTranslated:
    """translate_currencies: group_period collected → translated. translated data and one translation-reserve
    entry per company, with the NCI share (CON-04)
    """
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodEliminated:
    """run_eliminations: group_period translated → eliminated. automatic entries for intercompany balances,
    revenue and expense, dividends, stock profit, investments, NCI and the equity method, keyed per task,
    pair and run (CON-05 to CON-09)
    """
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodSigned:
    """sign_off_group_close: group_period eliminated → signed. who, when and the digest recorded; statements
    materialised (CON-21)
    """
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class GroupPeriodCollectedFromSigned:
    """reopen_group_period: group_period signed → collected. recorded; the figures provisional; the next runs
    take run_no + 1
    """
    group_id: str
    period_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsJournalPosted:
    """post_cons_auto_entry: cons_journal none → posted. numbered in the group's book and year; a replay answers
    the entry posted; the previous run's entry for the key reversed
    """
    cons_journal_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsJournalProposed:
    """propose_cons_entry: cons_journal none → proposed. proposer recorded (email and sub); document type and
    period-specific flag recorded
    """
    cons_journal_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsJournalPostedFromProposed:
    """approve_cons_entry: cons_journal proposed → posted. numbered; a period-specific entry's reversal due at
    the next period's start
    """
    cons_journal_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsJournalRejected:
    """reject_cons_entry: cons_journal proposed → rejected"""
    cons_journal_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsJournalReversed:
    """reverse_cons_entry: cons_journal posted → reversed. a mirror entry keyed derived_id(cons_journal_id,
    'reversal'); neither deleted
    """
    cons_journal_id: str
    by: str = ""


@dataclass(frozen=True)
class StructureChangeProposed:
    """propose_structure_change: structure_change none → proposed. goodwill, NCI, gain or equity effect computed
    from the collected data and shown (CON-02, CON-16, CON-17)
    """
    change_id: str
    by: str = ""


@dataclass(frozen=True)
class StructureChangeEffective:
    """approve_structure_change: structure_change proposed → effective. the dated structure row written;
    historical amounts fixed; later periods' steps stale
    """
    change_id: str
    by: str = ""


@dataclass(frozen=True)
class StructureChangeRejected:
    """reject_structure_change: structure_change proposed → rejected"""
    change_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsMigrationRunLoaded:
    """load_cons_from_odoo: cons_migration_run none → loaded. group, structure per period, account rules and
    closed periods' consolidation journals written read-only, keyed on the Odoo record
    """
    cons_migration_run_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsMigrationRunReconciled:
    """reconcile_cons_migration: cons_migration_run loaded → reconciled. every migration.odoo.reconcile check
    computed on both sides
    """
    cons_migration_run_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsMigrationRunUpdated:
    """explain_cons_difference: cons_migration_run reconciled → reconciled"""
    cons_migration_run_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsMigrationRunUpdatedFromLoaded:
    """reload_cons_migration: cons_migration_run loaded, reconciled → loaded"""
    cons_migration_run_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsMigrationRunSigned:
    """sign_cons_reconciliation: cons_migration_run reconciled → signed. who, when and checksums recorded"""
    cons_migration_run_id: str
    by: str = ""


@dataclass(frozen=True)
class ConsMigrationRunDiscarded:
    """discard_cons_migration: cons_migration_run loaded, reconciled → discarded"""
    cons_migration_run_id: str
    by: str = ""