- Introduced OpexValidationError for handling validation errors in processing opex calculations. - Implemented ProjectProcessingOpexRepository and ScenarioProcessingOpexRepository for managing project and scenario-level processing opex snapshots. - Enhanced UnitOfWork to include repositories for processing opex. - Updated sidebar navigation and scenario detail templates to include links to the new Processing Opex Planner. - Created a new template for the Processing Opex Planner with form handling for input components and parameters. - Developed integration tests for processing opex calculations, covering HTML and JSON flows, including validation for currency mismatches and unsupported frequencies. - Added unit tests for the calculation logic, ensuring correct handling of various scenarios and edge cases.
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
"""Domain-level exceptions for service and repository layers."""
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Sequence
|
|
|
|
|
|
class EntityNotFoundError(Exception):
|
|
"""Raised when a requested entity cannot be located."""
|
|
|
|
|
|
class EntityConflictError(Exception):
|
|
"""Raised when attempting to create or update an entity that violates uniqueness."""
|
|
|
|
|
|
class AuthorizationError(Exception):
|
|
"""Raised when a user lacks permission to perform an action."""
|
|
|
|
|
|
@dataclass(eq=False)
|
|
class ScenarioValidationError(Exception):
|
|
"""Raised when scenarios fail comparison validation rules."""
|
|
|
|
code: str
|
|
message: str
|
|
scenario_ids: Sequence[int] | None = None
|
|
|
|
def __str__(self) -> str: # pragma: no cover - mirrors message for logging
|
|
return self.message
|
|
|
|
|
|
@dataclass(eq=False)
|
|
class ProfitabilityValidationError(Exception):
|
|
"""Raised when profitability calculation inputs fail domain validation."""
|
|
|
|
message: str
|
|
field_errors: Sequence[str] | None = None
|
|
|
|
def __str__(self) -> str: # pragma: no cover - mirrors message for logging
|
|
return self.message
|
|
|
|
|
|
@dataclass(eq=False)
|
|
class CapexValidationError(Exception):
|
|
"""Raised when capex calculation inputs fail domain validation."""
|
|
|
|
message: str
|
|
field_errors: Sequence[str] | None = None
|
|
|
|
def __str__(self) -> str: # pragma: no cover - mirrors message for logging
|
|
return self.message
|
|
|
|
|
|
@dataclass(eq=False)
|
|
class OpexValidationError(Exception):
|
|
"""Raised when opex calculation inputs fail domain validation."""
|
|
|
|
message: str
|
|
field_errors: Sequence[str] | None = None
|
|
|
|
def __str__(self) -> str: # pragma: no cover - mirrors message for logging
|
|
return self.message
|