from __future__ import annotations

from sqlalchemy import CheckConstraint, ForeignKey, Integer, Numeric, SmallInteger
from sqlalchemy.orm import Mapped, mapped_column, relationship

from src.db.base import Base


class RfProjectReportQuarter(Base):
    __tablename__ = "rf_project_report_quarter"
    __table_args__ = {"schema": "v3"}

    rf_project_report_line_id: Mapped[int] = mapped_column(
        Integer, ForeignKey("v3.rf_project_report_line.id"), primary_key=True
    )
    quarter: Mapped[int] = mapped_column(
        SmallInteger,
        CheckConstraint("quarter >= 1 AND quarter <= 4"),
        primary_key=True,
    )
    adj_by_items: Mapped[float | None] = mapped_column(Numeric)
    adj_increase: Mapped[float | None] = mapped_column(Numeric)
    actual_m1: Mapped[float | None] = mapped_column(Numeric)
    actual_m2: Mapped[float | None] = mapped_column(Numeric)
    actual_m3: Mapped[float | None] = mapped_column(Numeric)
    actual_spod: Mapped[float | None] = mapped_column(Numeric)

#     line: Mapped[RfProjectReportLine] = relationship(
#         "RfProjectReportLine", back_populates="quarters"
#     )
