Files
group_fqcd_jr/app/model/risk_questionnaire.py

41 lines
1.9 KiB
Python

"""ORM mappings for existing risk-assessment and profile-projection tables."""
from datetime import datetime
from typing import Any
from sqlalchemy import JSON, BigInteger, Boolean, DateTime, Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from app.model.base import Base
class RiskAssessment(Base):
__tablename__ = "fin_risk_assessment"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
customer_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
questionnaire_version: Mapped[str] = mapped_column(String(32), nullable=False)
answers: Mapped[dict[str, int]] = mapped_column(JSON, nullable=False)
total_score: Mapped[int] = mapped_column(Integer, nullable=False)
investor_type: Mapped[str] = mapped_column(String(8), nullable=False)
assessed_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
valid_until: Mapped[datetime] = mapped_column(DateTime, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
class ProfileSnapshot(Base):
__tablename__ = "profile_snapshots"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
profile_uuid: Mapped[str | None] = mapped_column(String(36), unique=True)
customer_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
version: Mapped[int] = mapped_column(BigInteger, nullable=False)
snapshot: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
generation_basis: Mapped[dict[str, Any] | None] = mapped_column(JSON)
snapshot_hash: Mapped[str | None] = mapped_column(String(64))
is_current: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
current_customer_id: Mapped[int | None] = mapped_column(BigInteger)
generated_at: Mapped[datetime | None] = mapped_column(DateTime)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)