Model/infrastructure/postgres/product_table.py
Khalim Conn-Kowlessar 5dab7beae5 Map the default plan's selected measures onto the export row 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 23:29:26 +00:00

27 lines
1.1 KiB
Python

from __future__ import annotations
from typing import ClassVar, Optional
from sqlmodel import Field, SQLModel
class MaterialRow(SQLModel, table=True):
"""Defensive view of the externally-owned ``material`` catalogue table.
Declares only the columns the modelling backend reads to price a Measure
Option; other columns (r-values, labour breakdowns, etc.) are left off so
schema churn elsewhere doesn't ripple in. `total_cost` is the fully-loaded
cost per the row's `cost_unit` (GBP/m^2 for fabric measures).
"""
__tablename__: ClassVar[str] = "material" # pyright: ignore[reportIncompatibleVariableOverride]
id: int = Field(primary_key=True)
type: str
total_cost: Optional[float] = Field(default=None)
cost_unit: Optional[str] = Field(default=None)
description: Optional[str] = Field(default=None)
is_active: bool = Field(default=True)
# Whether a solar_pv Option's product bundle includes a battery; the Scenario
# Export reads it to pivot solar-with-battery to its own column (ADR-0065).
includes_battery: bool = Field(default=False)