"""Type-safe enumeration definitions for the adjustment file pipeline. Defines string enums for columns, batch states, error codes, file types, events, and database tables used throughout the validation and preparation workflow. Key Enums: - AdjustmentColumn/AdjustmentFileColumn: Internal and external column names - BatchStatus: Lifecycle states (PENDING → VALIDATING → ERROR/success) - BatchErrorCode: Error categorization for database tracking - DuckDBTable: Table names for validation workflow - EventType: EventBridge routing (initialized, prepared) - FileType: Supported formats (CSV, XLSX, Parquet) """ from enum import StrEnum class AdjustmentColumn(StrEnum): """Internal database column names mapped to AdjustmentFileColumn display names.""" ACCOUNT_ID = 'account_id' ACCOUNT_NAME = 'account_name' ACTIVITY_MONTH = 'activity_month' ACTIVITY_YEAR = 'activity_year' ADJUSTMENT_TYPE = 'adjustment_type' AMOUNT = 'amount' APPLY_TO_FLOWTHROUGH = 'apply_to_flowthrough' CLIENT_FACING_COMMENT = 'client_facing_comment' CONTRACT_ID = 'contract_id' CONTRACT_NAME = 'contract_name' CURRENCY = 'currency' DISTRIBUTION_TYPE = 'distribution_type' INTERNAL_NOTE = 'internal_note' STATEMENT_MONTH = 'statement_month' STATEMENT_YEAR = 'statement_year' UPC = 'upc' class AdjustmentFileColumn(StrEnum): """External column names from user-uploaded files. Columns marked '*' are required.""" ACCOUNT_ID = 'account id *' ACCOUNT_NAME = 'account name' ACTIVITY_MONTH = 'activity month *' ACTIVITY_YEAR = 'activity year *' ADJUSTMENT_TYPE = 'adjustment type *' AMOUNT = 'amount *' APPLY_TO_FLOWTHROUGH = 'apply to flowthrough' CLIENT_FACING_COMMENT = 'client facing comments *' CONTRACT_ID = 'contract id *' CONTRACT_NAME = 'contract name' CURRENCY = 'currency *' DISTRIBUTION_TYPE = 'distribution type' INTERNAL_NOTE = 'internal note' STATEMENT_MONTH = 'statement month *' STATEMENT_YEAR = 'statement year *' UPC = 'upc' class BatchErrorCode(StrEnum): """Error codes for batch failures, mapped to exceptions in errors.py.""" # Default UNKNOWN_ERROR = 'UNKNOWN_ERROR' # Batch errors BATCH_STATE_ERROR = 'BATCH_STATE_ERROR' # File errors CHECKSUM_MISMATCH = 'CHECKSUM_MISMATCH' FILE_NOT_FOUND = 'FILE_NOT_FOUND' FILE_PARSING_ERROR = 'FILE_PARSING_ERROR' FILE_SIZE_EXCEEDED = 'FILE_SIZE_EXCEEDED' FILE_INTEGRITY_ERROR = 'FILE_INTEGRITY_ERROR' FILE_SYSTEM_ERROR = 'FILE_SYSTEM_ERROR' INVALID_FILE_TYPE = 'INVALID_FILE_TYPE' # Validation errors EMPTY_FILE = 'EMPTY_FILE' MISSING_HEADERS = 'MISSING_HEADERS' ROW_COUNT_EXCEEDED = 'ROW_COUNT_EXCEEDED' class BatchStatus(StrEnum): """Batch lifecycle states: PENDING → VALIDATING → ERROR/success.""" ERROR = 'error' PENDING = 'pending' VALIDATING = 'validating' class DuckDBTable(StrEnum): """DuckDB table names for reference data and temporary validation tables.""" ACCOUNT = 'account' ACCOUNT_CONTRACT = 'account_contract' ACCOUNT_PAYMENT_TERM = 'account_payment_term' ACCOUNT_UPCS = 'account_upcs' CLOSE_BALANCE_STATUS = 'close_balance_status' CURRENCY_CODE = 'currency_code' FLAT_CONTRACT_TERM = 'flat_contract_term' REF_ADJUSTMENT_TYPE = 'reference_adjustment_type' STATEMENT_PERIOD = 'statement_period' # Tables created during validation ADJUSTMENT_FILE = 'adjustment_file' STAGING_ADJUSTMENT_DETAIL = 'staging_adjustment_detail' UPC_LOOKUP = 'upc_lookup' class Environment(StrEnum): """Deployment environments with local/managed detection properties.""" DEV = 'dev' QA = 'qa' UAT = 'uat' PROD = 'prod' @property def is_local(self) -> bool: """Check if in a local development environment.""" return self == Environment.DEV @property def is_managed(self) -> bool: """Check if in a managed (QA, Prod, UAT) environment.""" return self in (Environment.QA, Environment.UAT, Environment.PROD) class EventType(StrEnum): """EventBridge event types for batch lifecycle: initialized → prepared.""" ADJUSTMENT_BATCH_INITIALIZED = 'adjustment_batch.initialized' ADJUSTMENT_BATCH_PREPARED = 'adjustment_batch.prepared' class FileType(StrEnum): """Supported file formats with automatic detection: CSV, XLSX, Parquet.""" CSV = 'csv' PQT = 'parquet' XLSX = 'xlsx' class TargetType(StrEnum): """Entity types referenced in EventBridge event metadata.""" WORKSHEET_ADJUSTMENT_BATCH = 'worksheet_flowthrough_batch'