from typing import TYPE_CHECKING from sqlalchemy import Date, DateTime, ForeignKeyConstraint, Index, Integer, PrimaryKeyConstraint, SmallInteger, String, Time, UniqueConstraint, func, text from sqlalchemy.orm import Mapped, mapped_column, relationship from sqlalchemy.orm.base import Mapped from datetime import datetime from core.database import Base if TYPE_CHECKING: from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos class PedimentoPayments(Base): __tablename__ = 'pedimento_payments' __table_args__ = ( ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id']), ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_payments'), PrimaryKeyConstraint('id', name='pedimento_payments_pkey'), UniqueConstraint('pedimento_id', name='pedimento_payments_pedimento_id_key'), Index('idx_pedimento_payments_pedimento_id', 'pedimento_id'), {'schema': 'a76'} ) id = mapped_column(Integer) pedimento_id = mapped_column(Integer, nullable=False) tenant_id = mapped_column(Integer, nullable=False, index=True) acknowledgment = mapped_column(String(20)) operation_number = mapped_column(String(14)) bank_code = mapped_column(Integer) cashier = mapped_column(String(2)) date = mapped_column(Date) time = mapped_column(Time) shift = mapped_column(String(1)) total_cash_paid = mapped_column(Integer) total_contributions = mapped_column(Integer) counter_payment = mapped_column(SmallInteger) pece_code = mapped_column(String(5)) payment_id = mapped_column(Integer) # Timestamps created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now()) updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now()) deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) pedimento: Mapped['Pedimentos'] = relationship('Pedimentos', back_populates='pedimento_payments')