dodil/erp-brick-tax
DODIL ERP brick: tax
src/brick_tax/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."""
from dataclasses import dataclass
@dataclass(frozen=True)
class CodeAdded:
"""add_code: tax_code none -> draft."""
tax_code: str
treatment: str = ""
by: str = ""
@dataclass(frozen=True)
class PackLoaded:
"""load_pack: tax_code none -> draft (or, for a migrated history code, straight to retired)."""
tax_code: str
by: str = ""
@dataclass(frozen=True)
class CodeActivated:
"""activate_code: tax_code draft -> active."""
tax_code: str
by: str = ""
@dataclass(frozen=True)
class RateScheduled:
"""schedule_rate: tax_code active -> active. A dated rate row; issued documents unchanged."""
tax_code: str
valid_from: object = None
rate_pct: str = ""
by: str = ""
@dataclass(frozen=True)
class RateApproved:
"""A second person approved a rate change."""
tax_code: str
valid_from: object = None
by: str = ""
@dataclass(frozen=True)
class RateWithdrawn:
"""withdraw_rate: a rate that never took effect."""
tax_code: str
valid_from: object = None
by: str = ""
@dataclass(frozen=True)
class CodeRetired:
"""retire_code: tax_code active -> retired. No new determinations; documents keep it."""
tax_code: str
by: str = ""
@dataclass(frozen=True)
class RegistrationRecorded:
"""record_not_registered / record_registered / register / deregister: a dated registration row."""
effective_from: object = None
status: str = ""
by: str = ""
@dataclass(frozen=True)
class TaxDetermined:
"""determine: document_tax none -> computed."""
document_ref: str
by: str = ""
@dataclass(frozen=True)
class CodeSuggested:
"""ai_suggest_code: document_tax computed -> computed. A proposed code with its reason; nothing is applied."""
document_ref: str
line_no: int = 0
tax_code: str = ""
by: str = ""
@dataclass(frozen=True)
class SuggestionDecided:
"""accept_suggestion: a person accepted or rejected the AI's code."""
document_ref: str
line_no: int = 0
accepted: bool = False
by: str = ""
@dataclass(frozen=True)
class LineOverridden:
"""override_line: a line's code changed, with a reason."""
document_ref: str
line_no: int = 0
tax_code: str = ""
by: str = ""
@dataclass(frozen=True)
class OverrideApproved:
"""approve_override: an override that lowers tax was approved."""
document_ref: str
line_no: int = 0
by: str = ""
@dataclass(frozen=True)
class TaxFrozen:
"""freeze: document_tax computed -> frozen. Never recomputed."""
document_ref: str
by: str = ""