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


class AgencyTariffCode(Base):
    __tablename__ = "agency_tariff_codes"
    __table_args__ = (
        PrimaryKeyConstraint("id", name="agency_tariff_codes_pkey"),
        {"schema": "public", "extend_existing": True},
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    tariff_flag_code: Mapped[str] = mapped_column(String(10), nullable=False, index=True)
    agency_code: Mapped[str] = mapped_column(String(10), nullable=False, index=True)
    requirement_level: Mapped[str] = mapped_column(String(1), nullable=False) # M o R
    program_code: Mapped[str] = mapped_column(String(10), nullable=False, index=True)
    definition: Mapped[str] = mapped_column(String(500), nullable=False)

    def __repr__(self):
        return f"<AgencyTariffCode(id={self.id}, flag={self.tariff_flag_code}, agency={self.agency_code})>"
