CatPrioridadesRequerimiento — fuerza_ventas.cat_prioridades_requerimiento¶
Catálogo de niveles de prioridad para requerimientos comerciales de visitas (ALTA, MEDIA, BAJA, URGENTE).
import uuid
from datetime import datetime
from typing import Optional
from sqlalchemy import (
BigInteger,
Boolean,
Index,
Integer,
String,
UniqueConstraint,
text,
)
from sqlalchemy.dialects.postgresql import TIMESTAMP, UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base
class CatPrioridadesRequerimiento(Base):
"""
Catálogo de niveles de prioridad para requerimientos comerciales de visitas (ALTA, MEDIA, BAJA, URGENTE).
"""
__tablename__ = "cat_prioridades_requerimiento"
__table_args__ = (
UniqueConstraint(
"empresa_id",
"id",
name="uq_cat_prioridades_req_empresa_id",
),
UniqueConstraint(
"empresa_id",
"codigo",
name="uq_cat_prioridades_req_empresa_codigo",
),
Index(
"ix_cat_prioridades_req_empresa_activo",
"empresa_id",
"is_activo",
),
{
"schema": "fuerza_ventas",
"comment": "Catálogo de niveles de prioridad para requerimientos comerciales de visitas (ALTA, MEDIA, BAJA, URGENTE).",
},
)
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
primary_key=True,
server_default=text("gen_random_uuid()"),
comment="Identificador único UUID",
)
empresa_id: Mapped[int] = mapped_column(
BigInteger,
nullable=False,
comment="Identificador BIGINT de la empresa en core.identidad (RLS)",
)
codigo: Mapped[str] = mapped_column(String(20), nullable=False, comment="Código de prioridad")
nombre: Mapped[str] = mapped_column(String(50), nullable=False, comment="Nombre descriptivo")
descripcion: Mapped[Optional[str]] = mapped_column(String(255), nullable=True, comment="Descripción")
# Auditoría General
is_activo: Mapped[bool] = mapped_column(
Boolean,
nullable=False,
server_default=text("true"),
comment="Estado lógico del registro",
)
created_at: Mapped[datetime] = mapped_column(
TIMESTAMP(timezone=True),
nullable=False,
server_default=text("now()"),
comment="Fecha de creación",
)
updated_at: Mapped[datetime] = mapped_column(
TIMESTAMP(timezone=True),
nullable=False,
server_default=text("now()"),
comment="Fecha de última actualización",
)
deleted_at: Mapped[Optional[datetime]] = mapped_column(
TIMESTAMP(timezone=True),
nullable=True,
comment="Fecha de eliminación lógica",
)
created_by: Mapped[Optional[uuid.UUID]] = mapped_column(
UUID(as_uuid=True),
nullable=True,
comment="Usuario creador",
)
updated_by: Mapped[Optional[uuid.UUID]] = mapped_column(
UUID(as_uuid=True),
nullable=True,
comment="Usuario modificador",
)