epb_view_models 2.0.10 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,575 @@
1
+ module ViewModel
2
+ module RdSapSchemaNi210
3
+ class CommonSchema < ViewModel::DomesticEpcViewModel
4
+ def assessment_id
5
+ xpath(%w[RRN])
6
+ end
7
+
8
+ def address_line1
9
+ xpath(%w[Property Address Address-Line-1])
10
+ end
11
+
12
+ def address_line2
13
+ xpath(%w[Property Address Address-Line-2]).to_s
14
+ end
15
+
16
+ def address_line3
17
+ xpath(%w[Property Address Address-Line-3]).to_s
18
+ end
19
+
20
+ def address_line4
21
+ xpath(%w[Property Address Address-Line-4]).to_s
22
+ end
23
+
24
+ def town
25
+ xpath(%w[Property Address Post-Town])
26
+ end
27
+
28
+ def postcode
29
+ xpath(%w[Property Address Postcode])
30
+ end
31
+
32
+ def scheme_assessor_id
33
+ xpath(%w[Certificate-Number])
34
+ end
35
+
36
+ def assessor_name
37
+ xpath(%w[Energy-Assessor Name])
38
+ end
39
+
40
+ def assessor_email
41
+ xpath(%w[Energy-Assessor E-Mail])
42
+ end
43
+
44
+ def assessor_telephone
45
+ xpath(%w[Energy-Assessor Telephone])
46
+ end
47
+
48
+ def date_of_assessment
49
+ xpath(%w[Inspection-Date])
50
+ end
51
+
52
+ def date_of_registration
53
+ xpath(%w[Registration-Date])
54
+ end
55
+
56
+ def date_of_completion
57
+ xpath(%w[Completion-Date])
58
+ end
59
+
60
+ def address_id
61
+ xpath(%w[UPRN])
62
+ end
63
+
64
+ def date_of_expiry
65
+ expires_at = (Date.parse(date_of_registration) - 1) >> 12 * 10
66
+
67
+ expires_at.to_s
68
+ end
69
+
70
+ def property_summary
71
+ @xml_doc.search("Energy-Assessment Property-Summary").children.select(
72
+ &:element?
73
+ ).map { |node|
74
+ next if xpath(%w[Energy-Efficiency-Rating], node).nil?
75
+
76
+ {
77
+ energy_efficiency_rating:
78
+ xpath(%w[Energy-Efficiency-Rating], node).to_i,
79
+ environmental_efficiency_rating:
80
+ xpath(%w[Environmental-Efficiency-Rating], node).to_i,
81
+ name: node.name.underscore,
82
+ description: xpath(%w[Description], node),
83
+ }
84
+ }.compact
85
+ end
86
+
87
+ def related_party_disclosure_text
88
+ xpath(%w[Related-Party-Disclosure-Text])
89
+ end
90
+
91
+ def related_party_disclosure_number
92
+ disclosure_number = xpath(%w[Related-Party-Disclosure-Number])
93
+ disclosure_number.nil? ? nil : disclosure_number.to_i
94
+ end
95
+
96
+ def improvements
97
+ @xml_doc
98
+ .search("Suggested-Improvements Improvement")
99
+ .map do |node|
100
+ {
101
+ energy_performance_rating_improvement:
102
+ xpath(%w[Energy-Performance-Rating], node).to_i,
103
+ environmental_impact_rating_improvement:
104
+ xpath(%w[Environmental-Impact-Rating], node).to_i,
105
+ green_deal_category_code: xpath(%w[Green-Deal-Category], node),
106
+ improvement_category: xpath(%w[Improvement-Category], node),
107
+ improvement_code:
108
+ xpath(%w[Improvement-Details Improvement-Number], node),
109
+ improvement_description: xpath(%w[Improvement-Description], node),
110
+ improvement_title: improvement_title(node),
111
+ improvement_type: xpath(%w[Improvement-Type], node),
112
+ indicative_cost: xpath(%w[Indicative-Cost], node),
113
+ sequence: xpath(%w[Sequence], node).to_i,
114
+ typical_saving: xpath(%w[Typical-Saving], node),
115
+ }
116
+ end
117
+ end
118
+
119
+ def recommendations_for_report
120
+ accessor = Accessor::DomesticRecommendationsAccessor.instance
121
+ @xml_doc
122
+ .search("Suggested-Improvements Improvement")
123
+ .map do |node|
124
+ improvement_code = xpath(%w[Improvement-Details Improvement-Number], node)
125
+ {
126
+ sequence: xpath(%w[Sequence], node).to_i,
127
+ improvement_code: xpath(%w[Improvement-Details Improvement-Number], node),
128
+ improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-20.0.0", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
129
+ improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-20.0.0", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
130
+ indicative_cost: xpath(%w[Indicative-Cost], node),
131
+ }
132
+ end
133
+ end
134
+
135
+ def hot_water_cost_potential
136
+ xpath(%w[Hot-Water-Cost-Potential])
137
+ end
138
+
139
+ def heating_cost_potential
140
+ xpath(%w[Heating-Cost-Potential])
141
+ end
142
+
143
+ def lighting_cost_potential
144
+ xpath(%w[Lighting-Cost-Potential])
145
+ end
146
+
147
+ def hot_water_cost_current
148
+ xpath(%w[Hot-Water-Cost-Current])
149
+ end
150
+
151
+ def heating_cost_current
152
+ xpath(%w[Heating-Cost-Current])
153
+ end
154
+
155
+ def lighting_cost_current
156
+ xpath(%w[Lighting-Cost-Current])
157
+ end
158
+
159
+ def potential_carbon_emission
160
+ xpath(%w[CO2-Emissions-Potential])
161
+ end
162
+
163
+ def current_carbon_emission
164
+ xpath(%w[CO2-Emissions-Current])
165
+ end
166
+
167
+ def potential_energy_rating
168
+ xpath(%w[Energy-Rating-Potential])&.to_i
169
+ end
170
+
171
+ def current_energy_rating
172
+ xpath(%w[Energy-Rating-Current])&.to_i
173
+ end
174
+
175
+ def estimated_energy_cost; end
176
+
177
+ def total_floor_area
178
+ xpath(%w[Property-Summary Total-Floor-Area])
179
+ end
180
+
181
+ def dwelling_type
182
+ xpath(%w[Dwelling-Type])
183
+ end
184
+
185
+ def potential_energy_saving; end
186
+
187
+ def property_age_band
188
+ xpath(%w[Construction-Age-Band])
189
+ end
190
+
191
+ def tenure
192
+ xpath(%w[Tenure])
193
+ end
194
+
195
+ def transaction_type
196
+ xpath(%w[Transaction-Type])
197
+ end
198
+
199
+ def current_space_heating_demand
200
+ xpath(%w[Space-Heating-Existing-Dwelling])
201
+ end
202
+
203
+ def current_water_heating_demand
204
+ xpath(%w[Water-Heating])
205
+ end
206
+
207
+ def impact_of_cavity_insulation
208
+ if xpath(%w[Impact-Of-Cavity-Insulation])
209
+ xpath(%w[Impact-Of-Cavity-Insulation])&.to_i
210
+ end
211
+ end
212
+
213
+ def impact_of_loft_insulation
214
+ if xpath(%w[Impact-Of-Loft-Insulation])
215
+ xpath(%w[Impact-Of-Loft-Insulation])&.to_i
216
+ end
217
+ end
218
+
219
+ def impact_of_solid_wall_insulation
220
+ if xpath(%w[Impact-Of-Solid-Wall-Insulation])
221
+ xpath(%w[Impact-Of-Solid-Wall-Insulation])&.to_i
222
+ end
223
+ end
224
+
225
+ def habitable_room_count
226
+ xpath(%w[Habitable-Room-Count])&.to_i
227
+ end
228
+
229
+ def energy_rating_current
230
+ xpath(%w[Energy-Rating-Current])&.to_i
231
+ end
232
+
233
+ def energy_rating_potential
234
+ xpath(%w[Energy-Rating-Potential])&.to_i
235
+ end
236
+
237
+ def environmental_impact_current
238
+ xpath(%w[Environmental-Impact-Current])&.to_i
239
+ end
240
+
241
+ def environmental_impact_potential
242
+ xpath(%w[Environmental-Impact-Potential])&.to_i
243
+ end
244
+
245
+ def primary_energy_use
246
+ xpath(%w[Energy-Consumption-Current])
247
+ end
248
+
249
+ def energy_consumption_potential
250
+ xpath(%w[Energy-Consumption-Potential])
251
+ end
252
+
253
+ def all_roof_descriptions
254
+ @xml_doc.search("Roof/Description").map(&:content)
255
+ end
256
+
257
+ def all_roof_energy_efficiency_rating
258
+ @xml_doc.search("Roof/Energy-Efficiency-Rating").map(&:content)
259
+ end
260
+
261
+ def all_roof_env_energy_efficiency_rating
262
+ @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content)
263
+ end
264
+
265
+ def all_window_descriptions
266
+ @xml_doc.search("Window/Description").map(&:content)
267
+ end
268
+
269
+ def all_main_heating_descriptions
270
+ @xml_doc.search("Main-Heating/Description").map(&:content)
271
+ end
272
+
273
+ def all_main_heating_controls_descriptions
274
+ @xml_doc.search("Main-Heating-Controls/Description").map(&:content)
275
+ end
276
+
277
+ def all_main_heating_energy_efficiency
278
+ @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content)
279
+ end
280
+
281
+ def all_main_heating_environmental_efficiency
282
+ @xml_doc
283
+ .search("Main-Heating/Environmental-Efficiency-Rating")
284
+ .map(&:content)
285
+ end
286
+
287
+ def all_hot_water_descriptions
288
+ @xml_doc.search("Hot-Water/Description").map(&:content)
289
+ end
290
+
291
+ def all_lighting_descriptions
292
+ @xml_doc.search("Lighting/Description").map(&:content)
293
+ end
294
+
295
+ def all_secondary_heating_descriptions
296
+ @xml_doc.search("Secondary-Heating/Description").map(&:content)
297
+ end
298
+
299
+ def all_sap_floor_dimensions
300
+ @xml_doc.search("SAP-Floor-Dimension").select(&:element?).map { |node|
301
+ { total_floor_area: xpath(%w[Total-Floor-Area], node).to_f }
302
+ }.compact
303
+ end
304
+
305
+ def level
306
+ xpath(%w[Level])
307
+ end
308
+
309
+ def top_storey
310
+ xpath(%w[Top-Storey])
311
+ end
312
+
313
+ def storey_count
314
+ xpath(%w[Storey-Count])&.to_i
315
+ end
316
+
317
+ def building_part_number
318
+ xpath(%w[Building-Part-Number])
319
+ end
320
+
321
+ def all_building_parts
322
+ @xml_doc
323
+ .search("SAP-Building-Parts/SAP-Building-Part")
324
+ .map do |part|
325
+ {
326
+ roof_insulation_thickness:
327
+ if part.xpath("Roof-Insulation-Thickness").empty?
328
+ nil
329
+ else
330
+ part.xpath("Roof-Insulation-Thickness").text
331
+ end,
332
+ rafter_insulation_thickness:
333
+ xpath(%w[Rafter-Insulation-Thickness], part),
334
+ flat_roof_insulation_thickness:
335
+ xpath(%w[Flat-Roof-Insulation-Thickness], part),
336
+ sloping_ceiling_insulation_thickness:
337
+ xpath(%w[Sloping-Ceiling-Insulation-Thickness], part),
338
+ roof_u_value: xpath(%w[Roof-U-Value], part),
339
+ roof_room_connected: xpath(%w[Roof-Room-Connected], part),
340
+ }
341
+ end
342
+ end
343
+
344
+ def floor_heat_loss
345
+ xpath(%w[Floor-Heat-Loss])
346
+ end
347
+
348
+ def immersion_heating_type
349
+ xpath(%w[Immersion-Heating-Type])
350
+ end
351
+
352
+ def main_fuel_type
353
+ xpath(%w[Main-Fuel-Type])
354
+ end
355
+
356
+ def secondary_fuel_type
357
+ xpath(%w[Secondary-Fuel-Type])
358
+ end
359
+
360
+ def water_heating_fuel
361
+ xpath(%w[Water-Heating-Fuel])
362
+ end
363
+
364
+ def boiler_flue_type
365
+ xpath(%w[Boiler-Flue-Type])
366
+ end
367
+
368
+ def meter_type
369
+ xpath(%w[Meter-Type])
370
+ end
371
+
372
+ def sap_main_heating_code
373
+ xpath(%w[SAP-Main-Heating-Code])
374
+ end
375
+
376
+ def country_code
377
+ xpath(%w[Country-Code])
378
+ end
379
+
380
+ def co2_emissions_current_per_floor_area
381
+ xpath(%w[CO2-Emissions-Current-Per-Floor-Area])
382
+ end
383
+
384
+ def mains_gas
385
+ xpath(%w[Mains-Gas])
386
+ end
387
+
388
+ def main_heating_controls
389
+ xpath(%w[Main-Heating-Controls Description])
390
+ end
391
+
392
+ def multiple_glazed_proportion
393
+ xpath(%w[Multiple-Glazed-Proportion])
394
+ end
395
+
396
+ def heated_room_count
397
+ xpath(%w[Heated-Room-Count])&.to_i
398
+ end
399
+
400
+ def hot_water_description
401
+ xpath(%w[Hot-Water Description])
402
+ end
403
+
404
+ def hot_water_energy_efficiency_rating
405
+ xpath(%w[Hot-Water Energy-Efficiency-Rating])
406
+ end
407
+
408
+ def hot_water_environmental_efficiency_rating
409
+ xpath(%w[Hot-Water Environmental-Efficiency-Rating])
410
+ end
411
+
412
+ def wind_turbine_count
413
+ xpath(%w[Wind-Turbines-Count])&.to_i
414
+ end
415
+
416
+ def heat_loss_corridor
417
+ xpath(%w[Heat-Loss-Corridor])
418
+ end
419
+
420
+ def unheated_corridor_length
421
+ xpath(%w[Unheated-Corridor-Length])
422
+ end
423
+
424
+ def window_description
425
+ xpath(%w[Window Description])
426
+ end
427
+
428
+ def window_energy_efficiency_rating
429
+ xpath(%w[Window Energy-Efficiency-Rating])
430
+ end
431
+
432
+ def window_environmental_efficiency_rating
433
+ xpath(%w[Window Environmental-Efficiency-Rating])
434
+ end
435
+
436
+ def secondary_heating_description
437
+ xpath(%w[Secondary-Heating Description])
438
+ end
439
+
440
+ def secondary_heating_energy_efficiency_rating
441
+ xpath(%w[Secondary-Heating Energy-Efficiency-Rating])
442
+ end
443
+
444
+ def secondary_heating_environmental_efficiency_rating
445
+ xpath(%w[Secondary-Heating Environmental-Efficiency-Rating])
446
+ end
447
+
448
+ def lighting_description
449
+ xpath(%w[Lighting Description])
450
+ end
451
+
452
+ def lighting_energy_efficiency_rating
453
+ xpath(%w[Lighting Energy-Efficiency-Rating])
454
+ end
455
+
456
+ def lighting_environmental_efficiency_rating
457
+ xpath(%w[Lighting Environmental-Efficiency-Rating])
458
+ end
459
+
460
+ def photovoltaic_roof_area_percent
461
+ xpath(%w[Photovoltaic-Supply Percent-Roof-Area])
462
+ end
463
+
464
+ def built_form
465
+ xpath(%w[Built-Form])
466
+ end
467
+
468
+ def extensions_count
469
+ xpath(%w[Extensions-Count])&.to_i
470
+ end
471
+
472
+ def report_type
473
+ xpath(%w[Report-Type])
474
+ end
475
+
476
+ def all_wall_descriptions
477
+ @xml_doc.search("Wall/Description").map(&:content)
478
+ end
479
+
480
+ def all_wall_energy_efficiency_rating
481
+ @xml_doc.search("Wall/Energy-Efficiency-Rating").map(&:content)
482
+ end
483
+
484
+ def all_wall_env_energy_efficiency_rating
485
+ @xml_doc.search("Wall/Environmental-Efficiency-Rating").map(&:content)
486
+ end
487
+
488
+ def floor_level
489
+ xpath(%w[Flat-Location])
490
+ end
491
+
492
+ def solar_water_heating_flag
493
+ xpath(%w[Solar-Water-Heating])
494
+ end
495
+
496
+ def mechanical_ventilation
497
+ xpath(%w[Mechanical-Ventilation])
498
+ end
499
+
500
+ def floor_height
501
+ @xml_doc.search("Room-Height").map(&:content)
502
+ end
503
+
504
+ def all_floor_descriptions
505
+ @xml_doc.search("Property-Summary/Floor/Description").map(&:content)
506
+ end
507
+
508
+ def all_floor_energy_efficiency_rating
509
+ @xml_doc
510
+ .search("Property-Summary/Floor/Energy-Efficiency-Rating")
511
+ .map(&:content)
512
+ end
513
+
514
+ def all_floor_env_energy_efficiency_rating
515
+ @xml_doc
516
+ .search("Property-Summary/Floor/Environmental-Efficiency-Rating")
517
+ .map(&:content)
518
+ end
519
+
520
+ def all_main_heating_controls_energy_efficiency
521
+ @xml_doc
522
+ .search("Main-Heating-Controls/Energy-Efficiency-Rating")
523
+ .map(&:content)
524
+ end
525
+
526
+ def all_main_heating_controls_environmental_efficiency
527
+ @xml_doc
528
+ .search("Main-Heating-Controls/Environmental-Efficiency-Rating")
529
+ .map(&:content)
530
+ end
531
+
532
+ def main_dwelling_construction_age_band_or_year
533
+ sap_building_parts =
534
+ @xml_doc.xpath("//SAP-Building-Parts/SAP-Building-Part")
535
+ sap_building_parts.each do |sap_building_part|
536
+ building_part_number = sap_building_part.at("Building-Part-Number")
537
+
538
+ # Identifies the Main Dwelling
539
+ if building_part_number&.content == "1"
540
+ return(
541
+ sap_building_part.at_xpath(
542
+ "Construction-Age-Band | Construction-Year",
543
+ )&.content
544
+ )
545
+ end
546
+ end
547
+ nil
548
+ end
549
+
550
+ def cylinder_insul_thickness
551
+ xpath(%w[Cylinder-Insulation-Thickness])
552
+ end
553
+
554
+ def cylinder_insulation_type
555
+ xpath(%w[Cylinder-Insulation-Type])
556
+ end
557
+
558
+ def cylinder_size
559
+ xpath(%w[Cylinder-Size])
560
+ end
561
+
562
+ def has_cylinder_thermostat
563
+ xpath(%w[Cylinder-Thermostat])
564
+ end
565
+
566
+ def gas_smart_meter_present
567
+ Helper::ToBool.execute(xpath(%w[Gas-Smart-Meter-Present]))
568
+ end
569
+
570
+ def electricity_smart_meter_present
571
+ Helper::ToBool.execute(xpath(%w[Electricity-Smart-Meter-Present]))
572
+ end
573
+ end
574
+ end
575
+ end
@@ -67,6 +67,8 @@ module ViewModel
67
67
  ViewModel::RdSapSchema171::CommonSchema.new xml_doc
68
68
  when :"RdSAP-Schema-17.0"
69
69
  ViewModel::RdSapSchema170::CommonSchema.new xml_doc
70
+ when :"RdSAP-Schema-NI-21.0.0"
71
+ ViewModel::RdSapSchemaNi210::CommonSchema.new xml_doc
70
72
  when :"RdSAP-Schema-NI-20.0.0"
71
73
  ViewModel::RdSapSchemaNi200::CommonSchema.new xml_doc
72
74
  when :"RdSAP-Schema-NI-19.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epb_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.10
4
+ version: 2.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - DLUHC Energy Performance of Buildings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-05 00:00:00.000000000 Z
11
+ date: 2025-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -276,6 +276,15 @@ files:
276
276
  - api/schemas/xml/RdSAP-Schema-NI-20.0.0/RdSAP/Templates/RdSAP-Report.xsd
277
277
  - api/schemas/xml/RdSAP-Schema-NI-20.0.0/RdSAP/UDT/EPC-Domains.xsd
278
278
  - api/schemas/xml/RdSAP-Schema-NI-20.0.0/RdSAP/UDT/SAP-Domains.xsd
279
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/ExternalDefinitions.xml
280
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/ExternalDefinitions.xsd
281
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/Templates/AssessorManagement.xsd
282
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/Templates/EPC-Certificate.xsd
283
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/Templates/EPC-CollectedData.xsd
284
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/Templates/Property.xsd
285
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/Templates/RdSAP-Report.xsd
286
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/UDT/EPC-Domains.xsd
287
+ - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/UDT/SAP-Domains.xsd
279
288
  - api/schemas/xml/SAP-Schema-10.2/CommonFiles/CommonStructures.xsd
280
289
  - api/schemas/xml/SAP-Schema-10.2/CommonFiles/Exceptions.xsd
281
290
  - api/schemas/xml/SAP-Schema-10.2/Messages/ConditionReportChangeAccessRequest_1.xsd
@@ -1791,6 +1800,7 @@ files:
1791
1800
  - lib/view_model/rd_sap_schema_ni_180/common_schema.rb
1792
1801
  - lib/view_model/rd_sap_schema_ni_190/common_schema.rb
1793
1802
  - lib/view_model/rd_sap_schema_ni_200/common_schema.rb
1803
+ - lib/view_model/rd_sap_schema_ni_210/common_schema.rb
1794
1804
  - lib/view_model/rd_sap_wrapper.rb
1795
1805
  - lib/view_model/sap_schema_102/common_schema.rb
1796
1806
  - lib/view_model/sap_schema_102/rdsap.rb