File size: 925 Bytes
29cbab9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import uuid
from decimal import Decimal
from typing import Optional, TYPE_CHECKING
from sqlmodel import Field, SQLModel, Relationship

if TYPE_CHECKING:
    from .team import Team
    from .procedure_type import ProcedureType

class TeamProcedureValue(SQLModel, table=True):
    """
    Intermediate table between Team and ProcedureType.
    Holds the custom contract pricing and goals for a specific team.
    """
    __tablename__ = "team_procedure_values"

    team_id: uuid.UUID = Field(foreign_key="teams.id", primary_key=True)
    procedure_type_id: int = Field(foreign_key="procedure_types.id", primary_key=True)
    
    custom_value: Decimal = Field(default=0, max_digits=10, decimal_places=2)
    custom_goal: Optional[int] = Field(default=None)

    # Relationships
    team: "Team" = Relationship(back_populates="procedure_values")
    procedure_type: "ProcedureType" = Relationship(back_populates="team_values")