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


class InvoiceType(Base):
    __tablename__ = "invoice_types"  # GTiposFactura
    __table_args__ = (
        PrimaryKeyConstraint("key", name="invoice_types_pkey"),
        {"schema": "public", "extend_existing": True},  # opcional
    )

    key: Mapped[str] = mapped_column(String(5), nullable=False)  # clave del tipo de factura
    description: Mapped[str] = mapped_column(String(50), nullable=False)  # descripción oficial (en español)    
    note: Mapped[str] = mapped_column(String(500))# observación o comentario adicional    
    type: Mapped[str] = mapped_column(String(15))# tipo (MATERIAL, fixed asset, both)
    operation: Mapped[str] = mapped_column(String(5))  # operación (imp, exp, both)

    def __repr__(self):
        return f"<InvoiceType(key={self.key}, description={self.description}, type={self.type}, operation={self.operation})>"
