"""Revenue forecast domain values."""

from __future__ import annotations

from dataclasses import dataclass
from datetime import date, datetime
from decimal import Decimal


@dataclass(frozen=True)
class RevenueObservation:
    partition: str
    report_time: datetime
    today_revenue: Decimal
    overall_cpm: Decimal | None = None
    impressions: int | None = None
    dau: int | None = None
    fill_rate: Decimal | None = None
    revenue_change_pct: Decimal | None = None
    cpm_change_pct: Decimal | None = None
    exposure_change_pct: Decimal | None = None
    dau_change_pct: Decimal | None = None
    fill_rate_change_pct: Decimal | None = None
    source_modified_at: datetime | None = None


@dataclass(frozen=True)
class RevenueTrendWindow:
    report_time: datetime
    today_revenue: Decimal


@dataclass(frozen=True)
class RevenueForecast:
    report_time: datetime
    forecast_version: str
    parameter_version: str
    current_cumulative_revenue: Decimal
    speed_latest_weight: Decimal
    latest_interval_revenue: Decimal
    previous_interval_revenue: Decimal
    weighted_speed: Decimal
    remaining_multiplier_p10: Decimal
    remaining_multiplier_p50: Decimal
    remaining_multiplier_p90: Decimal
    parameter_sample_count: int
    forecast_revenue: Decimal
    forecast_lower: Decimal
    forecast_upper: Decimal
    target_cost_ratio: Decimal
    target_daily_cost: Decimal
    cost_reserve_date: date | None
    channel_costs: tuple[tuple[str, Decimal], ...]
    non_miniapp_reserved_cost: Decimal
    miniapp_target_daily_cost: Decimal
    status: str
    forecast_method: str = "weighted_30m_speed"
