from __future__ import annotations

from dataclasses import dataclass, field
from decimal import Decimal
from typing import Any, Literal, Optional


@dataclass(frozen=True, slots=True)
class ResolvedInvoiceItem:
    canonical_name: str
    tool_category: Optional[Literal["cancelar_vas_avulso", "vas_estrategico", "pro_rata"]]
    item_type: Literal["avulso", "estrategico", "bundle", "plano", "out_of_scope"]
    msisdn: str
    value: Optional[Decimal]
    section: str
    charge_date: Optional[str] = None
    raw_entry: dict[str, Any] = field(default_factory=dict)


@dataclass(frozen=True, slots=True)
class MentionedItem:
    desc: str
    msisdn: Optional[str] = None
    value: Optional[str] = None
    date: Optional[str] = None


def is_period_range(period: Any) -> bool:
    text = str(period)
    return " a " in text or "~" in text
