M8-T12: scope energy contracts
This commit is contained in:
+10
-2
@@ -163,8 +163,10 @@ class EnergyContract(Base):
|
||||
|
||||
``kind`` determines which price strategy is used (``manual`` for fixed
|
||||
dual-tariff rates entered by the user, ``tibber`` for dynamic API prices).
|
||||
Only one contract may be ``active`` at a time; the service layer enforces
|
||||
mutual exclusion. Specific pricing values live in ``EnergyContractVersion``
|
||||
A contract belongs to an energy ``scope`` (currently electricity; thermal
|
||||
profiles are reserved for the next milestone). Only one contract may be
|
||||
``active`` per scope; the service layer enforces mutual exclusion. Specific
|
||||
pricing values live in ``EnergyContractVersion``
|
||||
so that price changes can be tracked without modifying historical records.
|
||||
"""
|
||||
|
||||
@@ -180,6 +182,12 @@ class EnergyContract(Base):
|
||||
# migration simple and the strategy registry extensible.
|
||||
kind: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
|
||||
# Billing domain. The service registry derives this from ``kind`` so API
|
||||
# callers cannot move a pricing strategy into an incompatible domain.
|
||||
scope: Mapped[str] = mapped_column(
|
||||
String(32), nullable=False, default="electricity", index=True
|
||||
)
|
||||
|
||||
# Whether this is the currently active contract (at most one should be True).
|
||||
active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user