from typing import TYPE_CHECKING, Optional, List
from datetime import date
from sqlalchemy import (
    Integer, String, Date, Numeric, Boolean, 
    PrimaryKeyConstraint, ForeignKeyConstraint
)
from sqlalchemy.orm import Mapped, mapped_column, relationship
from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
from core.database import Base

if TYPE_CHECKING:
    from api.v1.modules.a24.inv.inv_parts.models import InvPart

class InvPartAphisRouting(Base, TenantScopedMixin, TimestampMixin):
    """Módulo: routing"""
    __tablename__ = "inv_aphis_routing"
    __table_args__ = (
        PrimaryKeyConstraint("id", name="inv_aphis_routing_pkey"),
        ForeignKeyConstraint(["aphis_general_id"], ["a24.inv_aphis_general.id"]),
        {"schema": "a24", "extend_existing": True},
    )
    id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
    aphis_general_id: Mapped[int] = mapped_column(Integer, nullable=False)
    
    # --- CAMPOS ROUTING ---
    type: Mapped[Optional[str]] = mapped_column(String(50))
    country: Mapped[Optional[str]] = mapped_column(String(50))
    name: Mapped[Optional[str]] = mapped_column(String(100))

    aphis_general: Mapped["InvPartAphisGeneral"] = relationship(back_populates="routing")
