"""Registre comptable central.""" import uuid from datetime import date, datetime, timezone from sqlalchemy import Date, DateTime, ForeignKey, Numeric, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.core.database import Base class TransactionComptable(Base): __tablename__ = "transactions_comptables" id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4) groupe_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("groupes.id"), nullable=False) date_transaction: Mapped[date] = mapped_column(Date, nullable=False) type: Mapped[str] = mapped_column(String(40), nullable=False) compte: Mapped[str] = mapped_column(String(40), nullable=False) montant: Mapped[float] = mapped_column(Numeric(10, 2), nullable=False) sens: Mapped[str] = mapped_column(String(10), nullable=False) # debit ou credit source_table: Mapped[str | None] = mapped_column(String(80)) source_id: Mapped[uuid.UUID | None] = mapped_column(nullable=True) note: Mapped[str | None] = mapped_column(Text) cree_par: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("membres.id")) cree_le: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))