"""
Schemas for Saldos Temporales report.
"""
from typing import Optional
from pydantic import BaseModel


class SaldosFilter(BaseModel):
    """
    Filter parameters for the Saldos Temporales CSV report.
    Maps directly to the UI options chosen by the user.
    """
    # Range / Period
    range_type: str = "pedimento"           # pedimento | payment_date | invoice_date | parts | classes
    start_date: Optional[str] = None        # identifier "from" (e.g. pedimento number or part string)
    end_date: Optional[str] = None          # identifier "to"
    date_start: Optional[str] = None        # Explicit start date
    date_end: Optional[str] = None          # Explicit end date

    # Column 2 – Filtros e Identificadores
    currency: str = "foreign"              # foreign | national
    report_type: str = "normal"            # normal | detailed | with_download
    exchange_rate: str = "invoice_date"    # invoice_date | payment_date
    omit_low_balance: bool = False
    balance_type: str = "normal"           # normal | repair | both
    level: str = "all"                     # partida | subpartida | all

    # Column 3 – Configuración Final
    end_date_as_cutoff: bool = False
    show_pending_series: bool = False
    include_asset_tag_images: bool = False
    use_large_asset_tag_icons: bool = False
    send_email: bool = False
    julian_date: bool = False
    include_regla_octava: bool = False
    shelter: bool = False

    # Print options (Column 1)
    print_part: bool = False
    print_class: bool = False

    # Optional identifiers populated from catalog selectors
    provider: Optional[str] = None
    buyer: Optional[str] = None
    asset_class: Optional[str] = None      # Clase
    asset_type: Optional[str] = None       # Parte
    location: Optional[str] = None
    pedimento_code: Optional[str] = None   # Clave de Pedimento

    # Security / scoping (set by the route, not by the UI)
    company_id: Optional[int] = None
    tenant_id: Optional[int] = None
