PerfilFinancieroCliente — clientes.trx_perfil_financiero_cliente¶
Perfil financiero anual del cliente.
"""``clientes.trx_perfil_financiero_cliente``: perfil financiero anual del cliente."""
import uuid
from datetime import date
from decimal import Decimal
from sqlalchemy import (
BigInteger,
CheckConstraint,
Date,
ForeignKeyConstraint,
Index,
Integer,
Numeric,
SmallInteger,
UniqueConstraint,
text,
)
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base
from app.models.mixins import AuditMixin
class PerfilFinancieroCliente(AuditMixin, Base):
__tablename__ = "trx_perfil_financiero_cliente"
__table_args__ = (
UniqueConstraint(
"empresa_id", "id", name="uq_trx_perfil_financiero_empresa_id"
),
UniqueConstraint(
"empresa_id",
"cliente_id",
"anio",
name="uq_trx_perfil_financiero_cliente_anio",
),
ForeignKeyConstraint(
["empresa_id", "cliente_id"],
["clientes.mae_clientes.empresa_id", "clientes.mae_clientes.id"],
name="fk_trx_perfil_financiero_cliente",
),
CheckConstraint(
"anio BETWEEN 1900 AND 2100", name="ck_trx_perfil_financiero_anio"
),
CheckConstraint(
"ingreso IS NULL OR ingreso >= 0", name="ck_trx_perfil_financiero_ingreso"
),
CheckConstraint(
"egreso IS NULL OR egreso >= 0", name="ck_trx_perfil_financiero_egreso"
),
CheckConstraint(
"anios_operaciones IS NULL OR anios_operaciones >= 0",
name="ck_trx_perfil_financiero_anios_operaciones",
),
CheckConstraint(
"anios_comerciales IS NULL OR anios_comerciales >= 0",
name="ck_trx_perfil_financiero_anios_comerciales",
),
CheckConstraint(
"cantidad_empleados IS NULL OR cantidad_empleados >= 0",
name="ck_trx_perfil_financiero_cantidad_empleados",
),
CheckConstraint(
"cantidad_sucursales IS NULL OR cantidad_sucursales >= 0",
name="ck_trx_perfil_financiero_cantidad_sucursales",
),
CheckConstraint(
"cantidad_vendedores IS NULL OR cantidad_vendedores >= 0",
name="ck_trx_perfil_financiero_cantidad_vendedores",
),
CheckConstraint(
"cantidad_clientes IS NULL OR cantidad_clientes >= 0",
name="ck_trx_perfil_financiero_cantidad_clientes",
),
Index(
"ix_trx_perfil_financiero_empresa_cliente_anio",
"empresa_id",
"cliente_id",
"anio",
),
{"schema": "clientes"},
)
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
primary_key=True,
server_default=text("gen_random_uuid()"),
)
empresa_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
cliente_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), nullable=False)
anio: Mapped[int] = mapped_column(SmallInteger, nullable=False)
fecha_declaracion: Mapped[date | None] = mapped_column(Date, nullable=True)
ingreso: Mapped[Decimal | None] = mapped_column(Numeric(16, 2), nullable=True)
egreso: Mapped[Decimal | None] = mapped_column(Numeric(16, 2), nullable=True)
utilidad_bruta: Mapped[Decimal | None] = mapped_column(
Numeric(16, 2), nullable=True
)
utilidad_operativa: Mapped[Decimal | None] = mapped_column(
Numeric(16, 2), nullable=True
)
anios_operaciones: Mapped[int | None] = mapped_column(
SmallInteger, nullable=True
)
anios_comerciales: Mapped[int | None] = mapped_column(
SmallInteger, nullable=True
)
cantidad_empleados: Mapped[int | None] = mapped_column(Integer, nullable=True)
cantidad_sucursales: Mapped[int | None] = mapped_column(Integer, nullable=True)
cantidad_vendedores: Mapped[int | None] = mapped_column(Integer, nullable=True)
cantidad_clientes: Mapped[int | None] = mapped_column(Integer, nullable=True)