- Updated PermissionRuleOct model to include company_id and modified unique constraint. - Updated Seal model to include company_id and modified unique constraint. - Added TYPE_CHECKING imports in reference data models for better type hinting. - Created new models for QClasses and SClasses in the a24 module. - Enhanced init_first_time.sh script for comprehensive system initialization, including Keycloak and PostgreSQL setup. - Updated documentation to reflect changes in API endpoints and database relationships.
46 lines
2.5 KiB
Python
46 lines
2.5 KiB
Python
from typing import TYPE_CHECKING
|
|
from sqlalchemy import DateTime, ForeignKeyConstraint, Index, Integer, PrimaryKeyConstraint, Time, UniqueConstraint, func, text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from sqlalchemy.orm.base import Mapped
|
|
from datetime import datetime, time as datetime_time
|
|
from core.database import Base
|
|
|
|
if TYPE_CHECKING:
|
|
from api.v1.modules.a76.pedmientos.models.pedimentos import Pedimentos
|
|
|
|
class PedimentoDates(Base):
|
|
__tablename__ = 'pedimento_dates'
|
|
__table_args__ = (
|
|
PrimaryKeyConstraint('id', name='pedimento_dates_pkey'),
|
|
ForeignKeyConstraint(['tenant_id'], ['a76.tenants.id'], name='fk_pedimento_dates_tenant'),
|
|
ForeignKeyConstraint(['company_id'], ['a76.company.id'], name='fk_pedimento_dates_company'),
|
|
ForeignKeyConstraint(['pedimento_id'], ['a76.pedimentos.id'], ondelete='CASCADE', name='fk_pedimento_dates'),
|
|
UniqueConstraint('tenant_id', 'company_id', 'pedimento_id', name='pedimento_dates_pedimento_id_key'),
|
|
Index('idx_pedimento_dates_pedimento_id', 'pedimento_id'),
|
|
{'schema': 'a76'}
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer)
|
|
tenant_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
|
company_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
|
|
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
|
|
entry_date: Mapped[datetime] = mapped_column(DateTime)
|
|
pedimento_date: Mapped[datetime] = mapped_column(DateTime)
|
|
payment_date: Mapped[datetime] = mapped_column(DateTime)
|
|
rectification_payment_date: Mapped[datetime] = mapped_column(DateTime)
|
|
extraction_date: Mapped[datetime] = mapped_column(DateTime)
|
|
submission_date: Mapped[datetime] = mapped_column(DateTime)
|
|
eucan_date: Mapped[datetime] = mapped_column(DateTime)
|
|
original_date: Mapped[datetime] = mapped_column(DateTime)
|
|
start_date: Mapped[datetime] = mapped_column(DateTime)
|
|
end_date: Mapped[datetime] = mapped_column(DateTime)
|
|
capture_date: Mapped[datetime] = mapped_column(DateTime)
|
|
capture_time: Mapped[datetime_time] = mapped_column(Time)
|
|
|
|
# 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_dates') |