mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
refactor(billing): relocate Bill Derivation to domain/billing/ (cross-stage)
Bill / EnergyBreakdown / BillDerivation / sap_fuel were under domain/property_baseline/ only because Baseline was built first. The Modelling stage now needs them too, so move them (and their tests) to a neutral domain/billing/ — Fuel/FuelRates already live in the shared domain/fuel_rates/. Avoids a modelling -> property_baseline cross-stage import and a package name that wrongly implies ownership (ADR-0011, ADR-0014 amendment). Pure git mv + import rewrite across 10 files; 40 billing/baseline/repo tests pass, pyright strict clean. CONTEXT.md Bill Derivation location updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
75ba5dd744
commit
ced6287baa
14 changed files with 13 additions and 13 deletions
|
|
@ -118,7 +118,7 @@ The process that translates an Optimised Package into cert-field changes and pro
|
|||
_Avoid_: measure overrides (rejected during ADR-0009 grill — phantom mid-layer), package applier, retrofit simulator
|
||||
|
||||
**Bill Derivation**:
|
||||
The deterministic process that derives a Property's annual energy **bill**, composed into per-end-use sections (heating, hot water, lighting, appliances, cooking, pumps/fans, …) plus a **total**, by pricing **SAP10 Calculation**'s delivered kWh per end use at **current Fuel Rates** — each end use billed at its fuel's rate, rolled up per fuel for **standing charges** (metered fuels only — gas/electricity; oil/LPG/solid have none) minus **SEG** export credit on PV. Implemented by `BillDerivation` in `domain/property_baseline/` (deterministic, ADR-0006). Reads Fuel Rates from a committed static snapshot via `FuelRatesRepository` (no live ETL yet). **Distinct from the calculator's `total_fuel_cost_gbp`**, which is the SAP-rating notional cost at RdSAP Table 32 standardised prices (~half the real electricity price) — not what the household pays. Raises on a fuel it has no rate for (e.g. house coal, heat network). ADR-0014.
|
||||
The deterministic process that derives a Property's annual energy **bill**, composed into per-end-use sections (heating, hot water, lighting, appliances, cooking, pumps/fans, …) plus a **total**, by pricing **SAP10 Calculation**'s delivered kWh per end use at **current Fuel Rates** — each end use billed at its fuel's rate, rolled up per fuel for **standing charges** (metered fuels only — gas/electricity; oil/LPG/solid have none) minus **SEG** export credit on PV. Implemented by `BillDerivation` in `domain/billing/` (a cross-stage concern — the Baseline stage derives the current bill, the Modelling stage re-runs it on the post-package end-state for post-retrofit bills; deterministic, ADR-0006). Reads Fuel Rates from a committed static snapshot via `FuelRatesRepository` (no live ETL yet). **Distinct from the calculator's `total_fuel_cost_gbp`**, which is the SAP-rating notional cost at RdSAP Table 32 standardised prices (~half the real electricity price) — not what the household pays. Raises on a fuel it has no rate for (e.g. house coal, heat network). ADR-0014.
|
||||
_Avoid_: EPC Energy Derivation (renamed), EpcEnergyDerivationService (no "service" suffix), kWh prediction, baseline kWh, energy estimation
|
||||
|
||||
**UCL Correction**:
|
||||
|
|
|
|||
0
domain/billing/__init__.py
Normal file
0
domain/billing/__init__.py
Normal file
|
|
@ -6,7 +6,7 @@ from enum import Enum
|
|||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from domain.fuel_rates.fuel import Fuel
|
||||
from domain.property_baseline.sap_fuel import sap_code_to_fuel
|
||||
from domain.billing.sap_fuel import sap_code_to_fuel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from domain.sap10_calculator.calculator import SapResult
|
||||
|
|
@ -5,7 +5,7 @@ from typing import Final
|
|||
|
||||
from domain.fuel_rates.fuel import Fuel
|
||||
from domain.fuel_rates.fuel_rates import FuelRates
|
||||
from domain.property_baseline.bill import (
|
||||
from domain.billing.bill import (
|
||||
Bill,
|
||||
BillSection,
|
||||
BillSectionCost,
|
||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
from domain.property_baseline.bill import Bill
|
||||
from domain.billing.bill import Bill
|
||||
from domain.property_baseline.performance import Performance
|
||||
from domain.property_baseline.rebaseliner import RebaselineReason
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from typing import ClassVar, Optional, cast
|
|||
from sqlmodel import Field, SQLModel
|
||||
|
||||
from datatypes.epc.domain.epc import Epc
|
||||
from domain.property_baseline.bill import Bill, BillSection, BillSectionCost
|
||||
from domain.billing.bill import Bill, BillSection, BillSectionCost
|
||||
from domain.property_baseline.property_baseline_performance import PropertyBaselinePerformance
|
||||
from domain.property_baseline.performance import Performance
|
||||
from domain.property_baseline.rebaseliner import RebaselineReason
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ from datatypes.epc.domain.epc_property_data import (
|
|||
EpcPropertyData,
|
||||
RenewableHeatIncentive,
|
||||
)
|
||||
from domain.property_baseline.bill import EnergyBreakdown
|
||||
from domain.property_baseline.bill_derivation import BillDerivation
|
||||
from domain.billing.bill import EnergyBreakdown
|
||||
from domain.billing.bill_derivation import BillDerivation
|
||||
from domain.property_baseline.property_baseline_performance import PropertyBaselinePerformance
|
||||
from domain.property_baseline.performance import lodged_performance
|
||||
from domain.property_baseline.rebaseliner import Rebaseliner
|
||||
|
|
|
|||
0
tests/domain/billing/__init__.py
Normal file
0
tests/domain/billing/__init__.py
Normal file
|
|
@ -4,8 +4,8 @@ import pytest
|
|||
|
||||
from domain.fuel_rates.fuel import Fuel, UnpricedFuel
|
||||
from domain.fuel_rates.fuel_rates import FuelRate, FuelRates
|
||||
from domain.property_baseline.bill import BillSection, EnergyBreakdown, EnergyLine
|
||||
from domain.property_baseline.bill_derivation import BillDerivation
|
||||
from domain.billing.bill import BillSection, EnergyBreakdown, EnergyLine
|
||||
from domain.billing.bill_derivation import BillDerivation
|
||||
|
||||
|
||||
def _rates() -> FuelRates:
|
||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import pytest
|
||||
|
||||
from domain.fuel_rates.fuel import Fuel
|
||||
from domain.property_baseline.bill import BillSection, EnergyBreakdown
|
||||
from domain.billing.bill import BillSection, EnergyBreakdown
|
||||
from domain.sap10_calculator.calculator import SapResult
|
||||
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import pytest
|
||||
|
||||
from domain.fuel_rates.fuel import Fuel
|
||||
from domain.property_baseline.sap_fuel import sap_code_to_fuel
|
||||
from domain.billing.sap_fuel import sap_code_to_fuel
|
||||
from domain.sap10_calculator.exceptions import UnmappedSapCode
|
||||
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ from datatypes.epc.domain.epc_property_data import (
|
|||
RenewableHeatIncentive,
|
||||
)
|
||||
from domain.fuel_rates.fuel import Fuel
|
||||
from domain.property_baseline.bill import BillSection
|
||||
from domain.billing.bill import BillSection
|
||||
from domain.property_baseline.property_baseline_performance import PropertyBaselinePerformance
|
||||
from domain.property_baseline.performance import Performance
|
||||
from domain.property_baseline.rebaseliner import (
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from sqlalchemy import Engine
|
|||
from sqlmodel import Session
|
||||
|
||||
from datatypes.epc.domain.epc import Epc
|
||||
from domain.property_baseline.bill import Bill, BillSection, BillSectionCost
|
||||
from domain.billing.bill import Bill, BillSection, BillSectionCost
|
||||
from domain.property_baseline.property_baseline_performance import PropertyBaselinePerformance
|
||||
from domain.property_baseline.performance import Performance
|
||||
from repositories.property_baseline.property_baseline_postgres_repository import (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue