34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from sqlalchemy import CheckConstraint, ForeignKey, Index, Integer, Numeric, String
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src.db.base import Base
|
|
|
|
|
|
class LimitTemplate(Base):
|
|
__tablename__ = "limit_template"
|
|
__table_args__ = (
|
|
CheckConstraint(
|
|
"row_type IN ('SECTION','GROUP','LEAF')",
|
|
name="ck_v3_limit_template_row_type",
|
|
),
|
|
Index("ix_v3_limit_template_parent", "parent_id"),
|
|
{"schema": "v3"},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
parent_id: Mapped[int | None] = mapped_column(Integer, ForeignKey("v3.limit_template.id"))
|
|
sort_order: Mapped[int] = mapped_column(Integer)
|
|
row_type: Mapped[str] = mapped_column(String)
|
|
section_no: Mapped[str | None] = mapped_column(String)
|
|
expense_item_code: Mapped[str | None] = mapped_column(String)
|
|
name: Mapped[str] = mapped_column(String)
|
|
unit: Mapped[str | None] = mapped_column(String)
|
|
limit_with_vat: Mapped[float | None] = mapped_column(Numeric)
|
|
limit_without_vat: Mapped[float | None] = mapped_column(Numeric)
|
|
|
|
# parent = relationship("LimitTemplate", remote_side="LimitTemplate.id")
|
|
# children: Mapped[list[LimitTemplate]] = relationship("LimitTemplate")
|
|
# form_limits: Mapped[list[FormLimit]] = relationship("FormLimit")
|