- Added monitoring metrics for project creation success and error handling in `ProjectRepository`. - Implemented similar monitoring for scenario creation in `ScenarioRepository`. - Refactored `run_monte_carlo` function in `simulation.py` to include timing and success/error metrics. - Introduced new CSS styles for headers, alerts, and navigation buttons in `main.css` and `projects.css`. - Created a new JavaScript file for navigation logic to handle chevron buttons. - Updated HTML templates to include new navigation buttons and improved styling for buttons. - Added tests for reporting service and routes to ensure proper functionality and access control. - Removed unused imports and optimized existing test files for better clarity and performance.
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
"""Scenario evaluation services including pricing integration."""
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Iterable
|
|
|
|
from models.scenario import Scenario
|
|
from services.pricing import (
|
|
PricingInput,
|
|
PricingMetadata,
|
|
PricingResult,
|
|
calculate_pricing,
|
|
)
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ScenarioPricingConfig:
|
|
"""Configuration for pricing evaluation within a scenario."""
|
|
|
|
metadata: PricingMetadata | None = None
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ScenarioPricingSnapshot:
|
|
"""Captured pricing results for a scenario."""
|
|
|
|
scenario_id: int
|
|
results: list[PricingResult]
|
|
|
|
|
|
class ScenarioPricingEvaluator:
|
|
"""Evaluate scenario profitability inputs using pricing services."""
|
|
|
|
def __init__(self, config: ScenarioPricingConfig | None = None) -> None:
|
|
self._config = config or ScenarioPricingConfig()
|
|
|
|
def evaluate(
|
|
self,
|
|
scenario: Scenario,
|
|
*,
|
|
inputs: Iterable[PricingInput],
|
|
metadata_override: PricingMetadata | None = None,
|
|
) -> ScenarioPricingSnapshot:
|
|
metadata = metadata_override or self._config.metadata
|
|
results: list[PricingResult] = []
|
|
for pricing_input in inputs:
|
|
result = calculate_pricing(
|
|
pricing_input,
|
|
metadata=metadata,
|
|
currency=scenario.currency,
|
|
)
|
|
results.append(result)
|
|
return ScenarioPricingSnapshot(scenario_id=scenario.id, results=results)
|