epb_view_models 2.0.15 → 2.0.16

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.
@@ -5,7 +5,7 @@ loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "2.0.15"
8
+ VERSION = "2.0.16"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -26,6 +26,7 @@ module ViewModel
26
26
  RdSAP-Schema-NI-18.0
27
27
  RdSAP-Schema-NI-17.4
28
28
  RdSAP-Schema-NI-17.3
29
+ RdSAP-Schema-S-19.0
29
30
  ].freeze
30
31
  TYPES_OF_SAP = %i[
31
32
  SAP-Schema-19.1.0
@@ -0,0 +1,533 @@
1
+ module ViewModel
2
+ module RdSapSchemaS190
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[Membership-Number]) or 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 address_id
57
+ "LPRN-#{xpath(%w[UPRN])}"
58
+ end
59
+
60
+ def date_of_expiry
61
+ expires_at = (Date.parse(date_of_registration) - 1) >> 12 * 10
62
+
63
+ expires_at.to_s
64
+ end
65
+
66
+ def property_summary
67
+ @xml_doc.search("Energy-Assessment Property-Summary").children.select(
68
+ &:element?
69
+ ).map { |node|
70
+ next if xpath(%w[Energy-Efficiency-Rating], node).nil?
71
+
72
+ {
73
+ energy_efficiency_rating:
74
+ xpath(%w[Energy-Efficiency-Rating], node).to_i,
75
+ environmental_efficiency_rating:
76
+ xpath(%w[Environmental-Efficiency-Rating], node).to_i,
77
+ name: node.name.underscore,
78
+ description: xpath(%w[Description], node),
79
+ }
80
+ }.compact
81
+ end
82
+
83
+ def related_party_disclosure_text
84
+ xpath(%w[Related-Party-Disclosure-Text])
85
+ end
86
+
87
+ def related_party_disclosure_number
88
+ disclosure_number = xpath(%w[Related-Party-Disclosure-Number])
89
+ disclosure_number.nil? ? nil : disclosure_number.to_i
90
+ end
91
+
92
+ def improvements
93
+ @xml_doc
94
+ .search("Suggested-Improvements Improvement")
95
+ .map do |node|
96
+ {
97
+ energy_performance_rating_improvement:
98
+ xpath(%w[Energy-Performance-Rating], node).to_i,
99
+ environmental_impact_rating_improvement:
100
+ xpath(%w[Environmental-Impact-Rating], node).to_i,
101
+ green_deal_category_code: xpath(%w[Green-Deal-Category], node),
102
+ improvement_category: xpath(%w[Improvement-Category], node),
103
+ improvement_code:
104
+ xpath(%w[Improvement-Details Improvement-Number], node),
105
+ improvement_description: xpath(%w[Improvement-Description], node),
106
+ improvement_title: improvement_title(node),
107
+ improvement_type: xpath(%w[Improvement-Type], node),
108
+ indicative_cost: xpath(%w[Indicative-Cost], node),
109
+ sequence: xpath(%w[Sequence], node).to_i,
110
+ typical_saving: xpath(%w[Typical-Saving], node),
111
+ }
112
+ end
113
+ end
114
+
115
+ def recommendations_for_report
116
+ @xml_doc
117
+ .search("Suggested-Improvements Improvement")
118
+ .map do |node|
119
+ {
120
+ sequence: xpath(%w[Sequence], node).to_i,
121
+ improvement_summary: xpath(%w[Improvement-Summary], node),
122
+ improvement_description: xpath(%w[Improvement-Description], node),
123
+ improvement_code:
124
+ xpath(%w[Improvement-Details Improvement-Number], node),
125
+ indicative_cost: xpath(%w[Indicative-Cost], node),
126
+ }
127
+ end
128
+ end
129
+
130
+ def hot_water_cost_potential
131
+ xpath(%w[Hot-Water-Cost-Potential])
132
+ end
133
+
134
+ def heating_cost_potential
135
+ xpath(%w[Heating-Cost-Potential])
136
+ end
137
+
138
+ def lighting_cost_potential
139
+ xpath(%w[Lighting-Cost-Potential])
140
+ end
141
+
142
+ def hot_water_cost_current
143
+ xpath(%w[Hot-Water-Cost-Current])
144
+ end
145
+
146
+ def heating_cost_current
147
+ xpath(%w[Heating-Cost-Current])
148
+ end
149
+
150
+ def lighting_cost_current
151
+ xpath(%w[Lighting-Cost-Current])
152
+ end
153
+
154
+ def potential_carbon_emission
155
+ xpath(%w[CO2-Emissions-Potential])
156
+ end
157
+
158
+ def current_carbon_emission
159
+ xpath(%w[CO2-Emissions-Current])
160
+ end
161
+
162
+ def potential_energy_rating
163
+ xpath(%w[Energy-Rating-Potential])&.to_i
164
+ end
165
+
166
+ def current_energy_rating
167
+ xpath(%w[Energy-Rating-Current])&.to_i
168
+ end
169
+
170
+ def estimated_energy_cost; end
171
+
172
+ def total_floor_area
173
+ xpath(%w[Property-Summary Total-Floor-Area])
174
+ end
175
+
176
+ def dwelling_type
177
+ xpath(%w[Dwelling-Type])
178
+ end
179
+
180
+ def potential_energy_saving; end
181
+
182
+ def property_age_band
183
+ xpath(%w[Construction-Age-Band])
184
+ end
185
+
186
+ def tenure
187
+ xpath(%w[Tenure])
188
+ end
189
+
190
+ def transaction_type
191
+ xpath(%w[Transaction-Type])
192
+ end
193
+
194
+ def current_space_heating_demand
195
+ xpath(%w[Space-Heating-Existing-Dwelling])
196
+ end
197
+
198
+ def current_water_heating_demand
199
+ xpath(%w[Water-Heating])
200
+ end
201
+
202
+ def impact_of_cavity_insulation
203
+ if xpath(%w[Impact-Of-Cavity-Insulation])
204
+ xpath(%w[Impact-Of-Cavity-Insulation])&.to_i
205
+ end
206
+ end
207
+
208
+ def impact_of_loft_insulation
209
+ if xpath(%w[Impact-Of-Loft-Insulation])
210
+ xpath(%w[Impact-Of-Loft-Insulation])&.to_i
211
+ end
212
+ end
213
+
214
+ def impact_of_solid_wall_insulation
215
+ if xpath(%w[Impact-Of-Solid-Wall-Insulation])
216
+ xpath(%w[Impact-Of-Solid-Wall-Insulation])&.to_i
217
+ end
218
+ end
219
+
220
+ def habitable_room_count
221
+ xpath(%w[Habitable-Room-Count])&.to_i
222
+ end
223
+
224
+ def energy_rating_current
225
+ xpath(%w[Energy-Rating-Current])&.to_i
226
+ end
227
+
228
+ def energy_rating_potential
229
+ xpath(%w[Energy-Rating-Potential])&.to_i
230
+ end
231
+
232
+ def environmental_impact_current
233
+ xpath(%w[Environmental-Impact-Current])&.to_i
234
+ end
235
+
236
+ def environmental_impact_potential
237
+ xpath(%w[Environmental-Impact-Potential])&.to_i
238
+ end
239
+
240
+ def primary_energy_use
241
+ xpath(%w[Energy-Consumption-Current])
242
+ end
243
+
244
+ def energy_consumption_potential
245
+ xpath(%w[Energy-Consumption-Potential])
246
+ end
247
+
248
+ def all_roof_descriptions
249
+ @xml_doc.search("Roof/Description").map(&:content)
250
+ end
251
+
252
+ def all_roof_energy_efficiency_rating
253
+ @xml_doc.search("Roof/Energy-Efficiency-Rating").map(&:content)
254
+ end
255
+
256
+ def all_roof_env_energy_efficiency_rating
257
+ @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content)
258
+ end
259
+
260
+ def all_window_descriptions
261
+ @xml_doc.search("Window/Description").map(&:content)
262
+ end
263
+
264
+ def all_main_heating_descriptions
265
+ @xml_doc.search("Main-Heating/Description").map(&:content)
266
+ end
267
+
268
+ def all_main_heating_controls_descriptions
269
+ @xml_doc.search("Main-Heating-Controls/Description").map(&:content)
270
+ end
271
+
272
+ def all_main_heating_energy_efficiency
273
+ @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content)
274
+ end
275
+
276
+ def all_main_heating_environmental_efficiency
277
+ @xml_doc
278
+ .search("Main-Heating/Environmental-Efficiency-Rating")
279
+ .map(&:content)
280
+ end
281
+
282
+ def all_hot_water_descriptions
283
+ @xml_doc.search("Hot-Water/Description").map(&:content)
284
+ end
285
+
286
+ def all_lighting_descriptions
287
+ @xml_doc.search("Lighting/Description").map(&:content)
288
+ end
289
+
290
+ def all_secondary_heating_descriptions
291
+ @xml_doc.search("Secondary-Heating/Description").map(&:content)
292
+ end
293
+
294
+ def country_code
295
+ xpath(%w[Country-Code])
296
+ end
297
+
298
+ def main_fuel_type
299
+ xpath(%w[Main-Fuel-Type])
300
+ end
301
+
302
+ def secondary_fuel_type
303
+ xpath(%w[Secondary-Fuel-Type])
304
+ end
305
+
306
+ def water_heating_fuel
307
+ xpath(%w[Water-Heating-Fuel])
308
+ end
309
+
310
+ def co2_emissions_current_per_floor_area
311
+ xpath(%w[CO2-Emissions-Current-Per-Floor-Area])
312
+ end
313
+
314
+ def mains_gas
315
+ xpath(%w[Mains-Gas])
316
+ end
317
+
318
+ def level
319
+ xpath(%w[Level])
320
+ end
321
+
322
+ def top_storey
323
+ xpath(%w[Top-Storey])
324
+ end
325
+
326
+ def storey_count
327
+ xpath(%w[Storey-Count])&.to_i
328
+ end
329
+
330
+ def main_heating_controls
331
+ xpath(%w[Main-Heating-Controls Description])
332
+ end
333
+
334
+ def multiple_glazed_proportion
335
+ xpath(%w[Multiple-Glazed-Proportion])
336
+ end
337
+
338
+ def glazed_area
339
+ xpath(%w[Glazed-Area])
340
+ end
341
+
342
+ def heated_room_count
343
+ xpath(%w[Heated-Room-Count])&.to_i
344
+ end
345
+
346
+ def low_energy_lighting
347
+ xpath(%w[Low-Energy-Lighting])
348
+ end
349
+
350
+ def fixed_lighting_outlets_count
351
+ xpath(%w[Fixed-Lighting-Outlets-Count])&.to_i
352
+ end
353
+
354
+ def low_energy_fixed_lighting_outlets_count
355
+ xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Count])&.to_i
356
+ end
357
+
358
+ def open_fireplaces_count
359
+ xpath(%w[Open-Fireplaces-Count])&.to_i
360
+ end
361
+
362
+ def hot_water_description
363
+ xpath(%w[Hot-Water Description])
364
+ end
365
+
366
+ def hot_water_energy_efficiency_rating
367
+ xpath(%w[Hot-Water Energy-Efficiency-Rating])
368
+ end
369
+
370
+ def hot_water_environmental_efficiency_rating
371
+ xpath(%w[Hot-Water Environmental-Efficiency-Rating])
372
+ end
373
+
374
+ def wind_turbine_count
375
+ xpath(%w[Wind-Turbines-Count])&.to_i
376
+ end
377
+
378
+ def heat_loss_corridor
379
+ xpath(%w[Heat-Loss-Corridor])
380
+ end
381
+
382
+ def unheated_corridor_length
383
+ xpath(%w[Unheated-Corridor-Length])
384
+ end
385
+
386
+ def window_description
387
+ xpath(%w[Window Description])
388
+ end
389
+
390
+ def window_energy_efficiency_rating
391
+ xpath(%w[Window Energy-Efficiency-Rating])
392
+ end
393
+
394
+ def window_environmental_efficiency_rating
395
+ xpath(%w[Window Environmental-Efficiency-Rating])
396
+ end
397
+
398
+ def secondary_heating_description
399
+ xpath(%w[Secondary-Heating Description])
400
+ end
401
+
402
+ def secondary_heating_energy_efficiency_rating
403
+ xpath(%w[Secondary-Heating Energy-Efficiency-Rating])
404
+ end
405
+
406
+ def secondary_heating_environmental_efficiency_rating
407
+ xpath(%w[Secondary-Heating Environmental-Efficiency-Rating])
408
+ end
409
+
410
+ def lighting_description
411
+ xpath(%w[Lighting Description])
412
+ end
413
+
414
+ def lighting_energy_efficiency_rating
415
+ xpath(%w[Lighting Energy-Efficiency-Rating])
416
+ end
417
+
418
+ def lighting_environmental_efficiency_rating
419
+ xpath(%w[Lighting Environmental-Efficiency-Rating])
420
+ end
421
+
422
+ def photovoltaic_roof_area_percent
423
+ xpath(%w[Photovoltaic-Supply Percent-Roof-Area])
424
+ end
425
+
426
+ def built_form
427
+ xpath(%w[Built-Form])
428
+ end
429
+
430
+ def extensions_count
431
+ xpath(%w[Extensions-Count])&.to_i
432
+ end
433
+
434
+ def report_type
435
+ xpath(%w[Report-Type])
436
+ end
437
+
438
+ def all_wall_descriptions
439
+ @xml_doc.search("Wall/Description").map(&:content)
440
+ end
441
+
442
+ def all_wall_energy_efficiency_rating
443
+ @xml_doc.search("Wall/Energy-Efficiency-Rating").map(&:content)
444
+ end
445
+
446
+ def all_wall_env_energy_efficiency_rating
447
+ @xml_doc.search("Wall/Environmental-Efficiency-Rating").map(&:content)
448
+ end
449
+
450
+ def meter_type
451
+ xpath(%w[Meter-Type])
452
+ end
453
+
454
+ def floor_level
455
+ xpath(%w[Flat-Location])
456
+ end
457
+
458
+ def solar_water_heating_flag
459
+ xpath(%w[Solar-Water-Heating])
460
+ end
461
+
462
+ def mechanical_ventilation
463
+ xpath(%w[Mechanical-Ventilation])
464
+ end
465
+
466
+ def floor_height
467
+ @xml_doc.search("Room-Height").map(&:content)
468
+ end
469
+
470
+ def all_floor_descriptions
471
+ @xml_doc.search("Property-Summary/Floor/Description").map(&:content)
472
+ end
473
+
474
+ def all_floor_energy_efficiency_rating
475
+ @xml_doc
476
+ .search("Property-Summary/Floor/Energy-Efficiency-Rating")
477
+ .map(&:content)
478
+ end
479
+
480
+ def all_floor_env_energy_efficiency_rating
481
+ @xml_doc
482
+ .search("Property-Summary/Floor/Environmental-Efficiency-Rating")
483
+ .map(&:content)
484
+ end
485
+
486
+ def all_main_heating_controls_energy_efficiency
487
+ @xml_doc
488
+ .search("Main-Heating-Controls/Energy-Efficiency-Rating")
489
+ .map(&:content)
490
+ end
491
+
492
+ def all_main_heating_controls_environmental_efficiency
493
+ @xml_doc
494
+ .search("Main-Heating-Controls/Environmental-Efficiency-Rating")
495
+ .map(&:content)
496
+ end
497
+
498
+ def main_dwelling_construction_age_band_or_year
499
+ sap_building_parts =
500
+ @xml_doc.xpath("//SAP-Building-Parts/SAP-Building-Part")
501
+ sap_building_parts.each do |sap_building_part|
502
+ building_part_number = sap_building_part.at("Building-Part-Number")
503
+
504
+ # Identifies the Main Dwelling
505
+ if building_part_number&.content == "1"
506
+ return(
507
+ sap_building_part.at_xpath(
508
+ "Construction-Age-Band | Construction-Year",
509
+ )&.content
510
+ )
511
+ end
512
+ end
513
+ nil
514
+ end
515
+
516
+ def cylinder_insul_thickness
517
+ xpath(%w[Cylinder-Insulation-Thickness])
518
+ end
519
+
520
+ def cylinder_insulation_type
521
+ xpath(%w[Cylinder-Insulation-Type])
522
+ end
523
+
524
+ def cylinder_size
525
+ xpath(%w[Cylinder-Size])
526
+ end
527
+
528
+ def has_cylinder_thermostat
529
+ xpath(%w[Cylinder-Thermostat])
530
+ end
531
+ end
532
+ end
533
+ end
@@ -79,6 +79,8 @@ module ViewModel
79
79
  ViewModel::RdSapSchemaNi174::CommonSchema.new xml_doc
80
80
  when :"RdSAP-Schema-NI-17.3"
81
81
  ViewModel::RdSapSchemaNi173::CommonSchema.new xml_doc
82
+ when :"RdSAP-Schema-S-19.0"
83
+ ViewModel::RdSapSchemaS190::CommonSchema.new xml_doc
82
84
  else
83
85
  raise ArgumentError, "Unsupported schema type"
84
86
  end
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.15
4
+ version: 2.0.16
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-05-12 00:00:00.000000000 Z
11
+ date: 2025-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -285,6 +285,17 @@ files:
285
285
  - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/Templates/RdSAP-Report.xsd
286
286
  - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/UDT/EPC-Domains.xsd
287
287
  - api/schemas/xml/RdSAP-Schema-NI-21.0.0/RdSAP/UDT/SAP-Domains.xsd
288
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/ExternalDefinitions.xml
289
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/ExternalDefinitions.xsd
290
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/AssessorManagement.xsd
291
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/EPC-Certificate.xsd
292
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/EPC-CollectedData.xsd
293
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/ExceptionList.xsd
294
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/Property.xsd
295
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/RdSAP-Report.xsd
296
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/ReportList.xsd
297
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/UDT/EPC-Domains.xsd
298
+ - api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/UDT/SAP-Domains.xsd
288
299
  - api/schemas/xml/SAP-Schema-10.2/CommonFiles/CommonStructures.xsd
289
300
  - api/schemas/xml/SAP-Schema-10.2/CommonFiles/Exceptions.xsd
290
301
  - api/schemas/xml/SAP-Schema-10.2/Messages/ConditionReportChangeAccessRequest_1.xsd
@@ -1814,6 +1825,7 @@ files:
1814
1825
  - lib/view_model/rd_sap_schema_ni_190/common_schema.rb
1815
1826
  - lib/view_model/rd_sap_schema_ni_200/common_schema.rb
1816
1827
  - lib/view_model/rd_sap_schema_ni_210/common_schema.rb
1828
+ - lib/view_model/rd_sap_schema_s_190/common_schema.rb
1817
1829
  - lib/view_model/rd_sap_wrapper.rb
1818
1830
  - lib/view_model/sap_schema_102/common_schema.rb
1819
1831
  - lib/view_model/sap_schema_102/rdsap.rb