"""
Modelos ORM para gestión de firmas
"""

from typing import Optional

from api.v1.common.base_models import TenantScopedMixin, TimestampMixin
from core.database import Base
from sqlalchemy import Integer, PrimaryKeyConstraint, String, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column


class Signature(Base, TenantScopedMixin, TimestampMixin):
    """
    Modelo para la tabla Signature - Firmas
    """

    __tablename__ = "signatures"  # GFirmas
    __table_args__ = (
        PrimaryKeyConstraint("id", name="signatures_pkey"),
        UniqueConstraint("code", "tenant_id", "company_id",
                         name="signatures_code_unique"),
        {"schema": "a76"},
    )

    # Primary key
    id: Mapped[int] = mapped_column(
        Integer, primary_key=True, autoincrement=True)

    # Signature code (unique)
    code: Mapped[str] = mapped_column(String(10), nullable=False)

    # Signature information
    signature: Mapped[Optional[str]] = mapped_column(String(1000))
    
    photo_path: Mapped[Optional[str]] = mapped_column(String(1000))

    def __repr__(self):
        return f"<Signature(id={self.id}, code={self.code})>"
