from core.database import Base
from sqlalchemy import CheckConstraint, PrimaryKeyConstraint, String
from sqlalchemy.orm import Mapped, mapped_column


class PedimentoTransportCatalog(Base):
    __tablename__ = "pedimento_transport_catalog"
    __table_args__ = (
        PrimaryKeyConstraint("code", name="pedimento_transport_catalog_pkey"),
        CheckConstraint(
            "payment_date_code IN ('E', 'P')",
            name="pedimento_transport_catalog_payment_date_code_chk",
        ),
        {"schema": "public", "extend_existing": True},
    )

    code: Mapped[str] = mapped_column(String(3), nullable=False)
    transport_en: Mapped[str] = mapped_column(String(80), nullable=False)
    transport_es: Mapped[str] = mapped_column(String(120), nullable=False)
    payment_date_code: Mapped[str] = mapped_column(String(1), nullable=False)

    def __repr__(self) -> str:
        return (
            f"<PedimentoTransportCatalog(code={self.code}, transport_en={self.transport_en}, "
            f"transport_es={self.transport_es}, payment_date_code={self.payment_date_code})>"
        )
