65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
# packages/v1/administrativo/models/ato_principal_model.py
|
|
|
|
from sqlalchemy import (
|
|
Column,
|
|
BigInteger,
|
|
Integer,
|
|
String,
|
|
DateTime,
|
|
Numeric,
|
|
Text,
|
|
ForeignKey,
|
|
CheckConstraint,
|
|
)
|
|
from sqlalchemy.dialects.postgresql import INET
|
|
from sqlalchemy.sql import func
|
|
from database.postgres import Base
|
|
|
|
|
|
class AtoPrincipal(Base):
|
|
"""
|
|
Representa o modelo da tabela 'ato_principal' no banco de dados PostgreSQL.
|
|
"""
|
|
|
|
__tablename__ = "ato_principal"
|
|
|
|
ato_principal_id = Column(BigInteger, primary_key=True, autoincrement=True, index=True)
|
|
|
|
origem_ato_principal_id = Column(
|
|
BigInteger,
|
|
ForeignKey("ato_principal.ato_principal_id", ondelete="SET NULL", onupdate="CASCADE"),
|
|
nullable=True,
|
|
)
|
|
|
|
identificacao_pedido_cgj = Column(BigInteger, nullable=False)
|
|
tipo_ato = Column(Integer, nullable=False)
|
|
codigo_selo = Column(String(50), nullable=False, unique=True)
|
|
codigo_ato = Column(String(50), nullable=False, unique=True)
|
|
nome_civil_ato = Column(String(255), nullable=False)
|
|
nome_serventuario_praticou_ato = Column(String(255), nullable=False)
|
|
data_solicitacao = Column(DateTime(timezone=True), nullable=False)
|
|
ip_maquina = Column(INET, nullable=True)
|
|
inteiro_teor = Column(Text, nullable=False)
|
|
valor_entrada = Column(Numeric(12, 2), nullable=True, default=0)
|
|
emolumento = Column(Numeric(12, 2), nullable=False)
|
|
taxa_judiciaria = Column(Numeric(12, 2), nullable=False)
|
|
fundos_estaduais = Column(Numeric(12, 2), nullable=False)
|
|
protocolo_protesto = Column(String(50), nullable=True)
|
|
protocolo_imovel = Column(String(50), nullable=True)
|
|
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), nullable=False)
|
|
|
|
# Constraints e índices adicionais
|
|
__table_args__ = (
|
|
CheckConstraint(
|
|
"(COALESCE(valor_entrada, 0) >= 0) AND (emolumento >= 0) AND (taxa_judiciaria >= 0) AND (fundos_estaduais >= 0)",
|
|
name="chk_valores_positivos",
|
|
),
|
|
)
|
|
|
|
def __repr__(self):
|
|
return (
|
|
f"<AtoPrincipal(id={self.ato_principal_id}, "
|
|
f"codigo_ato='{self.codigo_ato}', selo='{self.codigo_selo}', tipo={self.tipo_ato})>"
|
|
)
|