from __future__ import annotations

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

from src.db.base import Base


class Booking(Base):
    __tablename__ = "booking"
    __table_args__ = (
        CheckConstraint("quarter BETWEEN 1 AND 4", name="ck_v3_booking_quarter"),
        CheckConstraint("source IN ('CKK','CONTRACT')", name="ck_v3_booking_source"),
        Index("ix_v3_booking_line", "line_id"),
        {"schema": "v3"},
    )

    id: Mapped[int] = mapped_column(primary_key=True)
    line_id: Mapped[int] = mapped_column(Integer, ForeignKey("v3.budget_line.id"))
    quarter: Mapped[int] = mapped_column(SmallInteger)
    source: Mapped[str] = mapped_column(String)
    booked_amount_ckk: Mapped[float | None] = mapped_column(Numeric)
    booked_amount_contract: Mapped[float | None] = mapped_column(Numeric)

#     line = relationship("BudgetLine")
