from datetime import date
from typing import Literal, Optional

from pydantic import BaseModel, Field


class DownloadedPartsReportRequest(BaseModel):
    date_from: date
    date_to: date
    class_from: Optional[str] = None
    class_to: Optional[str] = None
    print_class_mode: Literal['exported', 'downloaded'] = 'downloaded'
    exchange_rate_mode: Literal['invoice', 'pedimento_payment'] = 'invoice'
    currency_mode: Literal['dollars', 'pesos', 'both'] = 'both'
    temporality_mode: Literal['temporales', 'definitivos', 'ambos'] = 'temporales'
    weight_type_mode: Literal['kilos', 'libras', 'ambos'] = 'kilos'
    operation_mode: Literal['importacion', 'exportacion'] = 'importacion'
    # Optional filters
    material_type: Optional[str] = None
    invoice_type: Optional[str] = None
    parts: Optional[list[str]] = None
    pedimento_key: Optional[str] = None
    provider_id: Optional[int] = None
    sold_to_id: Optional[int] = None
    shipped_to_id: Optional[int] = None
    destination_customs: Optional[str] = None
    # Option flags
    include_series: bool = False
    print_class_total: bool = False
    include_totals_by_fraction: bool = False
    julian_date: bool = False
    show_item_description: bool = True
    include_exempt_fraction: bool = False
    show_export_fraction: bool = False
    include_rule_octava: bool = False
    include_american_fraction_and_country: bool = False
    respect_import_invoice_value_in_pesos: bool = False
    show_all_temporary_balances: bool = False


class DownloadedPartsReportSection(BaseModel):
    id: str
    title: str
    description: str


class DownloadedPartsReportBootstrap(BaseModel):
    report_key: str = Field(default="downloaded_parts")
    title: str = Field(default="Partes descargadas")
    description: str
    company_id: int
    tenant_id: int
    status: str = Field(default="draft")
    available_filters: list[str]
    next_steps: list[str]
    sections: list[DownloadedPartsReportSection]
