54 lines
2.8 KiB
Python
54 lines
2.8 KiB
Python
"""Persistence models for goals and their client-facing goal books."""
|
|
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
from typing import Any
|
|
|
|
from sqlalchemy import JSON, BigInteger, DateTime, Integer, Numeric, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.model.base import Base
|
|
|
|
|
|
class ClientFacingContent(Base):
|
|
"""Unchanged baseline content-review resource used by goal books."""
|
|
|
|
__tablename__ = "client_facing_content"
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
customer_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
|
content_type: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
draft_content: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
|
|
generated_by_portal: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
review_status: Mapped[str] = mapped_column(String(16), nullable=False)
|
|
reviewer_user_id: Mapped[int | None] = mapped_column(BigInteger)
|
|
reviewed_at: Mapped[datetime | None] = mapped_column(DateTime)
|
|
published_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)
|
|
|
|
|
|
class AdvisorInvestmentGoal(Base):
|
|
"""Collected goal version; only a confirmed version feeds advisory tools."""
|
|
|
|
__tablename__ = "advisor_investment_goal"
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
|
goal_no: Mapped[str] = mapped_column(String(36), unique=True, nullable=False)
|
|
customer_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
|
status: Mapped[str] = mapped_column(String(24), nullable=False)
|
|
annualized_return_lower_pct: Mapped[Decimal] = mapped_column(Numeric(7, 4), nullable=False)
|
|
annualized_return_upper_pct: Mapped[Decimal] = mapped_column(Numeric(7, 4), nullable=False)
|
|
max_drawdown_pct: Mapped[Decimal] = mapped_column(Numeric(7, 4), nullable=False)
|
|
liquidity_requirement: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
investment_horizon_months: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
benchmark_name: Mapped[str] = mapped_column(String(128), nullable=False)
|
|
notes: Mapped[str | None] = mapped_column(Text)
|
|
source: Mapped[str] = mapped_column(String(16), nullable=False)
|
|
goal_book_content_id: Mapped[int] = mapped_column(BigInteger, nullable=False, unique=True)
|
|
created_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
|
confirmed_by: Mapped[int | None] = mapped_column(BigInteger)
|
|
confirmed_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)
|