mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Map a Calico roof-covering row to a renewal year 🟩
CalicoMapper maps each roof-covering row onto a ROOF element with a MATERIAL aspect, setting renewal_year = export_year + remaining_life (Calico's Decent-Homes-derived years-remaining anchored to the export year, so the absolute renewal year is stable across re-runs). source="Calico". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
99280b6a64
commit
61a12c43a0
1 changed files with 47 additions and 2 deletions
|
|
@ -1,11 +1,56 @@
|
|||
from typing import Any, Optional
|
||||
from datetime import date
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from domain.condition.aspect_condition import AspectCondition
|
||||
from domain.condition.element import Element
|
||||
from domain.condition.mapping.calico.calico_element_map import CALICO_ELEMENT_MAP
|
||||
from domain.condition.mapping.mapper import Mapper
|
||||
from domain.condition.property_condition_survey import PropertyConditionSurvey
|
||||
from domain.condition.records.calico.calico_asset_condition import CalicoAssetCondition
|
||||
from domain.condition.records.calico.calico_property import CalicoProperty
|
||||
|
||||
SOURCE = "Calico"
|
||||
|
||||
|
||||
class CalicoMapper(Mapper):
|
||||
def map_asset_conditions_for_property(
|
||||
self, client_property_data: Any, survey_year: Optional[int] = None
|
||||
) -> PropertyConditionSurvey:
|
||||
raise NotImplementedError
|
||||
assert isinstance(client_property_data, CalicoProperty)
|
||||
|
||||
elements: List[Element] = []
|
||||
for instance, asset in enumerate(client_property_data.assets, start=1):
|
||||
mapping = CALICO_ELEMENT_MAP[asset.path]
|
||||
elements.append(
|
||||
Element(
|
||||
element_type=mapping.elementType,
|
||||
element_instance=instance,
|
||||
aspect_conditions=[
|
||||
AspectCondition(
|
||||
aspect_type=mapping.aspect_type,
|
||||
aspect_instance=1,
|
||||
value=asset.covering_type,
|
||||
quantity=asset.quantity,
|
||||
install_date=asset.fitted_date,
|
||||
renewal_year=CalicoMapper._renewal_year(
|
||||
asset, survey_year
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
return PropertyConditionSurvey(
|
||||
uprn=client_property_data.uprn,
|
||||
elements=elements,
|
||||
date=date(survey_year, 1, 1) if survey_year else date(2000, 1, 1),
|
||||
source=SOURCE,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _renewal_year(
|
||||
asset: CalicoAssetCondition, survey_year: Optional[int]
|
||||
) -> Optional[int]:
|
||||
if asset.remaining_life is None or survey_year is None:
|
||||
return None
|
||||
return survey_year + asset.remaining_life
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue