"""
Custom exception types for the accounting financial reporting pipeline.

These exceptions allow callers (views, management commands, tests) to
distinguish accounting-domain errors from generic programming errors.
"""

from decimal import Decimal


class FinancialStatementImbalanceError(Exception):
    """Raised when Assets ≠ Liabilities + Equity in the SFP."""

    def __init__(self, difference: Decimal):
        self.difference = difference
        super().__init__(
            f"SFP balance equation violated. Difference: {difference}"
        )


class ReconciliationError(Exception):
    """Raised when IS net_income ≠ change in SFP equity."""

    def __init__(self, is_net_income: Decimal, equity_change: Decimal):
        self.is_net_income = is_net_income
        self.equity_change = equity_change
        self.difference = is_net_income - equity_change
        super().__init__(
            f"Cross-statement reconciliation failed. "
            f"IS net income: {is_net_income}, Equity change: {equity_change}, "
            f"Difference: {self.difference}"
        )
