mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Map to domain from 17.1 schema 🟩
This commit is contained in:
parent
1bd423a5ac
commit
eddeb2c516
1 changed files with 183 additions and 19 deletions
|
|
@ -154,8 +154,145 @@ class EpcPropertyDataMapper:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_rdsap_schema_17_1(_schema: RdSapSchema17_1) -> EpcPropertyData:
|
def from_rdsap_schema_17_1(schema: RdSapSchema17_1) -> EpcPropertyData:
|
||||||
raise NotImplementedError
|
es = schema.sap_energy_source
|
||||||
|
return EpcPropertyData(
|
||||||
|
uprn=schema.uprn,
|
||||||
|
assessment_type=schema.assessment_type,
|
||||||
|
sap_version=schema.sap_version,
|
||||||
|
dwelling_type=schema.dwelling_type.value,
|
||||||
|
property_type=str(schema.property_type),
|
||||||
|
built_form=str(schema.built_form),
|
||||||
|
address_line_1=schema.address_line_1,
|
||||||
|
address_line_2=schema.address_line_2,
|
||||||
|
postcode=schema.postcode,
|
||||||
|
post_town=schema.post_town,
|
||||||
|
status=schema.status,
|
||||||
|
tenure=str(schema.tenure),
|
||||||
|
transaction_type=str(schema.transaction_type),
|
||||||
|
inspection_date=date.fromisoformat(schema.inspection_date),
|
||||||
|
completion_date=date.fromisoformat(schema.completion_date),
|
||||||
|
registration_date=date.fromisoformat(schema.registration_date),
|
||||||
|
total_floor_area_m2=float(schema.total_floor_area),
|
||||||
|
solar_water_heating=schema.solar_water_heating == "Y",
|
||||||
|
has_hot_water_cylinder=schema.has_hot_water_cylinder == "true",
|
||||||
|
has_fixed_air_conditioning=schema.has_fixed_air_conditioning == "true",
|
||||||
|
conservatory_type=schema.conservatory_type,
|
||||||
|
has_conservatory=schema.conservatory_type != 1,
|
||||||
|
door_count=schema.door_count,
|
||||||
|
habitable_rooms_count=schema.habitable_room_count,
|
||||||
|
heated_rooms_count=schema.heated_room_count,
|
||||||
|
wet_rooms_count=0,
|
||||||
|
extensions_count=schema.extensions_count,
|
||||||
|
open_chimneys_count=0,
|
||||||
|
insulated_door_count=schema.insulated_door_count,
|
||||||
|
draughtproofed_door_count=None,
|
||||||
|
led_fixed_lighting_bulbs_count=0,
|
||||||
|
cfl_fixed_lighting_bulbs_count=0,
|
||||||
|
incandescent_fixed_lighting_bulbs_count=0,
|
||||||
|
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
||||||
|
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
||||||
|
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
||||||
|
main_heating=EpcPropertyDataMapper._map_energy_elements(
|
||||||
|
schema.main_heating
|
||||||
|
),
|
||||||
|
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
||||||
|
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
||||||
|
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
||||||
|
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
||||||
|
schema.secondary_heating
|
||||||
|
),
|
||||||
|
sap_heating=SapHeating(
|
||||||
|
instantaneous_wwhrs=InstantaneousWwhrs(),
|
||||||
|
main_heating_details=[
|
||||||
|
MainHeatingDetail(
|
||||||
|
has_fghrs=d.has_fghrs == "Y",
|
||||||
|
main_fuel_type=d.main_fuel_type,
|
||||||
|
boiler_flue_type=d.boiler_flue_type,
|
||||||
|
fan_flue_present=d.fan_flue_present == "Y",
|
||||||
|
heat_emitter_type=d.heat_emitter_type,
|
||||||
|
emitter_temperature=d.emitter_temperature,
|
||||||
|
main_heating_number=d.main_heating_number,
|
||||||
|
main_heating_control=d.main_heating_control,
|
||||||
|
main_heating_category=d.main_heating_category,
|
||||||
|
main_heating_fraction=d.main_heating_fraction,
|
||||||
|
sap_main_heating_code=d.sap_main_heating_code,
|
||||||
|
central_heating_pump_age=None,
|
||||||
|
main_heating_data_source=d.main_heating_data_source,
|
||||||
|
main_heating_index_number=d.main_heating_index_number,
|
||||||
|
)
|
||||||
|
for d in schema.sap_heating.main_heating_details
|
||||||
|
],
|
||||||
|
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning
|
||||||
|
== "true",
|
||||||
|
cylinder_size=schema.sap_heating.cylinder_size,
|
||||||
|
water_heating_code=schema.sap_heating.water_heating_code,
|
||||||
|
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
||||||
|
immersion_heating_type=schema.sap_heating.immersion_heating_type,
|
||||||
|
cylinder_insulation_type=schema.sap_heating.cylinder_insulation_type,
|
||||||
|
cylinder_thermostat=schema.sap_heating.cylinder_thermostat,
|
||||||
|
secondary_fuel_type=schema.sap_heating.secondary_fuel_type,
|
||||||
|
secondary_heating_type=schema.sap_heating.secondary_heating_type,
|
||||||
|
cylinder_insulation_thickness=schema.sap_heating.cylinder_insulation_thickness,
|
||||||
|
),
|
||||||
|
sap_windows=[],
|
||||||
|
sap_energy_source=SapEnergySource(
|
||||||
|
mains_gas=es.mains_gas == "Y",
|
||||||
|
meter_type=str(es.meter_type),
|
||||||
|
pv_battery_count=0,
|
||||||
|
wind_turbines_count=es.wind_turbines_count,
|
||||||
|
gas_smart_meter_present=False,
|
||||||
|
is_dwelling_export_capable=False,
|
||||||
|
wind_turbines_terrain_type=str(es.wind_turbines_terrain_type),
|
||||||
|
electricity_smart_meter_present=False,
|
||||||
|
photovoltaic_supply=(
|
||||||
|
PhotovoltaicSupply(
|
||||||
|
none_or_no_details=PhotovoltaicSupplyNoneOrNoDetails(
|
||||||
|
percent_roof_area=es.photovoltaic_supply.none_or_no_details.percent_roof_area,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if es.photovoltaic_supply
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
),
|
||||||
|
sap_building_parts=[
|
||||||
|
SapBuildingPart(
|
||||||
|
identifier=bp.identifier,
|
||||||
|
construction_age_band=bp.construction_age_band,
|
||||||
|
wall_construction=bp.wall_construction,
|
||||||
|
wall_insulation_type=bp.wall_insulation_type,
|
||||||
|
wall_thickness_measured=bp.wall_thickness_measured == "Y",
|
||||||
|
party_wall_construction=bp.party_wall_construction,
|
||||||
|
sap_floor_dimensions=[
|
||||||
|
SapFloorDimension(
|
||||||
|
room_height_m=fd.room_height.value,
|
||||||
|
total_floor_area_m2=fd.total_floor_area.value,
|
||||||
|
party_wall_length_m=(
|
||||||
|
float(fd.party_wall_length)
|
||||||
|
if isinstance(fd.party_wall_length, int)
|
||||||
|
else fd.party_wall_length.value
|
||||||
|
),
|
||||||
|
heat_loss_perimeter_m=fd.heat_loss_perimeter.value,
|
||||||
|
floor=fd.floor,
|
||||||
|
floor_insulation=fd.floor_insulation,
|
||||||
|
floor_construction=fd.floor_construction,
|
||||||
|
)
|
||||||
|
for fd in bp.sap_floor_dimensions
|
||||||
|
],
|
||||||
|
building_part_number=bp.building_part_number,
|
||||||
|
wall_dry_lined=bp.wall_dry_lined == "Y",
|
||||||
|
wall_thickness_mm=bp.wall_thickness,
|
||||||
|
wall_insulation_thickness=bp.wall_insulation_thickness,
|
||||||
|
floor_heat_loss=bp.floor_heat_loss,
|
||||||
|
floor_insulation_thickness=None,
|
||||||
|
roof_construction=bp.roof_construction,
|
||||||
|
roof_insulation_location=bp.roof_insulation_location,
|
||||||
|
roof_insulation_thickness=bp.roof_insulation_thickness,
|
||||||
|
sap_room_in_roof=None,
|
||||||
|
)
|
||||||
|
for bp in schema.sap_building_parts
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_rdsap_schema_18_0(schema: RdSapSchema18_0) -> EpcPropertyData:
|
def from_rdsap_schema_18_0(schema: RdSapSchema18_0) -> EpcPropertyData:
|
||||||
|
|
@ -197,11 +334,15 @@ class EpcPropertyDataMapper:
|
||||||
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
||||||
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
||||||
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
||||||
main_heating=EpcPropertyDataMapper._map_energy_elements(schema.main_heating),
|
main_heating=EpcPropertyDataMapper._map_energy_elements(
|
||||||
|
schema.main_heating
|
||||||
|
),
|
||||||
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
||||||
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
||||||
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
||||||
secondary_heating=EpcPropertyDataMapper._map_energy_element(schema.secondary_heating),
|
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
||||||
|
schema.secondary_heating
|
||||||
|
),
|
||||||
sap_heating=SapHeating(
|
sap_heating=SapHeating(
|
||||||
instantaneous_wwhrs=InstantaneousWwhrs(),
|
instantaneous_wwhrs=InstantaneousWwhrs(),
|
||||||
main_heating_details=[
|
main_heating_details=[
|
||||||
|
|
@ -223,7 +364,8 @@ class EpcPropertyDataMapper:
|
||||||
)
|
)
|
||||||
for d in schema.sap_heating.main_heating_details
|
for d in schema.sap_heating.main_heating_details
|
||||||
],
|
],
|
||||||
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning == "true",
|
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning
|
||||||
|
== "true",
|
||||||
cylinder_size=schema.sap_heating.cylinder_size,
|
cylinder_size=schema.sap_heating.cylinder_size,
|
||||||
water_heating_code=schema.sap_heating.water_heating_code,
|
water_heating_code=schema.sap_heating.water_heating_code,
|
||||||
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
||||||
|
|
@ -340,11 +482,15 @@ class EpcPropertyDataMapper:
|
||||||
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
||||||
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
||||||
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
||||||
main_heating=EpcPropertyDataMapper._map_energy_elements(schema.main_heating),
|
main_heating=EpcPropertyDataMapper._map_energy_elements(
|
||||||
|
schema.main_heating
|
||||||
|
),
|
||||||
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
||||||
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
||||||
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
||||||
secondary_heating=EpcPropertyDataMapper._map_energy_element(schema.secondary_heating),
|
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
||||||
|
schema.secondary_heating
|
||||||
|
),
|
||||||
sap_heating=SapHeating(
|
sap_heating=SapHeating(
|
||||||
instantaneous_wwhrs=InstantaneousWwhrs(),
|
instantaneous_wwhrs=InstantaneousWwhrs(),
|
||||||
main_heating_details=[
|
main_heating_details=[
|
||||||
|
|
@ -366,7 +512,8 @@ class EpcPropertyDataMapper:
|
||||||
)
|
)
|
||||||
for d in schema.sap_heating.main_heating_details
|
for d in schema.sap_heating.main_heating_details
|
||||||
],
|
],
|
||||||
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning == "true",
|
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning
|
||||||
|
== "true",
|
||||||
cylinder_size=schema.sap_heating.cylinder_size,
|
cylinder_size=schema.sap_heating.cylinder_size,
|
||||||
water_heating_code=schema.sap_heating.water_heating_code,
|
water_heating_code=schema.sap_heating.water_heating_code,
|
||||||
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
||||||
|
|
@ -485,11 +632,15 @@ class EpcPropertyDataMapper:
|
||||||
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
||||||
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
||||||
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
||||||
main_heating=EpcPropertyDataMapper._map_energy_elements(schema.main_heating),
|
main_heating=EpcPropertyDataMapper._map_energy_elements(
|
||||||
|
schema.main_heating
|
||||||
|
),
|
||||||
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
||||||
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
||||||
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
||||||
secondary_heating=EpcPropertyDataMapper._map_energy_element(schema.secondary_heating),
|
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
||||||
|
schema.secondary_heating
|
||||||
|
),
|
||||||
sap_heating=SapHeating(
|
sap_heating=SapHeating(
|
||||||
# 20.0.0 uses room counts not product index numbers; domain fields default to None
|
# 20.0.0 uses room counts not product index numbers; domain fields default to None
|
||||||
instantaneous_wwhrs=InstantaneousWwhrs(),
|
instantaneous_wwhrs=InstantaneousWwhrs(),
|
||||||
|
|
@ -512,7 +663,8 @@ class EpcPropertyDataMapper:
|
||||||
)
|
)
|
||||||
for d in schema.sap_heating.main_heating_details
|
for d in schema.sap_heating.main_heating_details
|
||||||
],
|
],
|
||||||
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning == "true",
|
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning
|
||||||
|
== "true",
|
||||||
cylinder_size=schema.sap_heating.cylinder_size,
|
cylinder_size=schema.sap_heating.cylinder_size,
|
||||||
water_heating_code=schema.sap_heating.water_heating_code,
|
water_heating_code=schema.sap_heating.water_heating_code,
|
||||||
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
||||||
|
|
@ -650,9 +802,7 @@ class EpcPropertyDataMapper:
|
||||||
),
|
),
|
||||||
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
||||||
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
||||||
hot_water=EpcPropertyDataMapper._map_energy_element(
|
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
||||||
schema.hot_water
|
|
||||||
),
|
|
||||||
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
||||||
schema.secondary_heating
|
schema.secondary_heating
|
||||||
),
|
),
|
||||||
|
|
@ -884,9 +1034,7 @@ class EpcPropertyDataMapper:
|
||||||
),
|
),
|
||||||
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
||||||
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
||||||
hot_water=EpcPropertyDataMapper._map_energy_element(
|
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
||||||
schema.hot_water
|
|
||||||
),
|
|
||||||
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
||||||
schema.secondary_heating
|
schema.secondary_heating
|
||||||
),
|
),
|
||||||
|
|
@ -1074,7 +1222,14 @@ class EpcPropertyDataMapper:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _map_energy_element(
|
def _map_energy_element(
|
||||||
element: Union[EnergyElement_18_0, EnergyElement_19_0, EnergyElement_20_0, EnergyElement_21_0, EnergyElement_21_0_1],
|
element: Union[
|
||||||
|
EnergyElement_17_1,
|
||||||
|
EnergyElement_18_0,
|
||||||
|
EnergyElement_19_0,
|
||||||
|
EnergyElement_20_0,
|
||||||
|
EnergyElement_21_0,
|
||||||
|
EnergyElement_21_0_1,
|
||||||
|
],
|
||||||
) -> EnergyElement:
|
) -> EnergyElement:
|
||||||
description = (
|
description = (
|
||||||
element.description
|
element.description
|
||||||
|
|
@ -1089,7 +1244,16 @@ class EpcPropertyDataMapper:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _map_energy_elements(
|
def _map_energy_elements(
|
||||||
elements: Sequence[Union[EnergyElement_18_0, EnergyElement_19_0, EnergyElement_20_0, EnergyElement_21_0, EnergyElement_21_0_1]],
|
elements: Sequence[
|
||||||
|
Union[
|
||||||
|
EnergyElement_17_1,
|
||||||
|
EnergyElement_18_0,
|
||||||
|
EnergyElement_19_0,
|
||||||
|
EnergyElement_20_0,
|
||||||
|
EnergyElement_21_0,
|
||||||
|
EnergyElement_21_0_1,
|
||||||
|
]
|
||||||
|
],
|
||||||
) -> List[EnergyElement]:
|
) -> List[EnergyElement]:
|
||||||
return [EpcPropertyDataMapper._map_energy_element(e) for e in elements]
|
return [EpcPropertyDataMapper._map_energy_element(e) for e in elements]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue