epb_view_models 2.5.0 → 2.6.1

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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EpbViewModels
4
- VERSION = "2.5.0"
4
+ VERSION = "2.6.1"
5
5
  end
@@ -81,6 +81,7 @@ module ViewModel
81
81
  SAP-Schema-NI-12.0
82
82
  SAP-Schema-NI-11.2
83
83
  SAP-Schema-S-19.0.0
84
+ SAP-Schema-S-17.0
84
85
  ].freeze
85
86
  def create(xml, schema_type, filter_results_for = nil, additional_data = {})
86
87
  # Hack to use symbols, we need to update all callers to use symbols instead
@@ -30,7 +30,7 @@ module ViewModel
30
30
  end
31
31
 
32
32
  def scheme_assessor_id
33
- xpath(%w[Certificate-Number])
33
+ xpath(%w[Identification-Number Membership-Number]) or xpath(%w[Identification-Number Certificate-Number])
34
34
  end
35
35
 
36
36
  def assessor_name
@@ -0,0 +1,503 @@
1
+ module ViewModel
2
+ module SapSchemaS170
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[Home-Inspector Name])
38
+ end
39
+
40
+ def assessor_email
41
+ xpath(%w[Home-Inspector/E-Mail])
42
+ end
43
+
44
+ def assessor_telephone
45
+ xpath(%w[Home-Inspector/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
+ xpath(%w[Related-Party-Disclosure-Number])&.to_i
89
+ end
90
+
91
+ def improvements
92
+ @xml_doc
93
+ .search("Suggested-Improvements Improvement")
94
+ .map do |node|
95
+ {
96
+ energy_performance_rating_improvement:
97
+ xpath(%w[Energy-Performance-Rating], node).to_i,
98
+ environmental_impact_rating_improvement:
99
+ xpath(%w[Environmental-Impact-Rating], node).to_i,
100
+ green_deal_category_code: xpath(%w[Green-Deal-Category], node),
101
+ improvement_category: xpath(%w[Improvement-Category], node),
102
+ improvement_code:
103
+ xpath(%w[Improvement-Details Improvement-Number], node),
104
+ improvement_description: xpath(%w[Improvement-Description], node),
105
+ improvement_title: improvement_title(node),
106
+ improvement_type: xpath(%w[Improvement-Type], node),
107
+ indicative_cost: xpath(%w[Indicative-Cost], node),
108
+ sequence: xpath(%w[Sequence], node).to_i,
109
+ typical_saving: xpath(%w[Typical-Saving], node),
110
+ }
111
+ end
112
+ end
113
+
114
+ def recommendations_for_report
115
+ @xml_doc
116
+ .search("Suggested-Improvements Improvement")
117
+ .map do |node|
118
+ {
119
+ sequence: xpath(%w[Sequence], node).to_i,
120
+ improvement_summary: xpath(%w[Improvement-Summary], node),
121
+ improvement_description: xpath(%w[Improvement-Description], node),
122
+ improvement_code:
123
+ xpath(%w[Improvement-Details Improvement-Number], node),
124
+ indicative_cost: xpath(%w[Indicative-Cost], node),
125
+ }
126
+ end
127
+ end
128
+
129
+ def hot_water_cost_potential
130
+ xpath(%w[Hot-Water-Cost-Potential])
131
+ end
132
+
133
+ def heating_cost_potential
134
+ xpath(%w[Heating-Cost-Potential])
135
+ end
136
+
137
+ def lighting_cost_potential
138
+ xpath(%w[Lighting-Cost-Potential])
139
+ end
140
+
141
+ def hot_water_cost_current
142
+ xpath(%w[Hot-Water-Cost-Current])
143
+ end
144
+
145
+ def heating_cost_current
146
+ xpath(%w[Heating-Cost-Current])
147
+ end
148
+
149
+ def lighting_cost_current
150
+ xpath(%w[Lighting-Cost-Current])
151
+ end
152
+
153
+ def potential_carbon_emission
154
+ xpath(%w[CO2-Emissions-Potential])
155
+ end
156
+
157
+ def current_carbon_emission
158
+ xpath(%w[CO2-Emissions-Current])
159
+ end
160
+
161
+ def potential_energy_rating
162
+ xpath(%w[Energy-Rating-Potential])&.to_i
163
+ end
164
+
165
+ def current_energy_rating
166
+ xpath(%w[Energy-Rating-Current])&.to_i
167
+ end
168
+
169
+ def primary_energy_use
170
+ xpath(%w[Energy-Consumption-Current])
171
+ end
172
+
173
+ def energy_consumption_potential
174
+ xpath(%w[Energy-Consumption-Potential])
175
+ end
176
+
177
+ def estimated_energy_cost; end
178
+
179
+ def total_floor_area
180
+ xpath(%w[Property-Summary Total-Floor-Area])
181
+ end
182
+
183
+ def total_roof_area
184
+ roofs = @xml_doc.xpath("//SAP-Roofs/SAP-Roof")
185
+ return nil if roofs.count.zero?
186
+
187
+ total_roof_area = 0
188
+ roofs.each do |roof|
189
+ roof_area = roof.at("Total-Roof-Area")&.content.to_i
190
+ total_roof_area += roof_area
191
+ end
192
+ total_roof_area
193
+ end
194
+
195
+ def dwelling_type
196
+ xpath(%w[Dwelling-Type])
197
+ end
198
+
199
+ def potential_energy_saving; end
200
+
201
+ def property_age_band
202
+ xpath(%w[Construction-Year])
203
+ end
204
+
205
+ def main_dwelling_construction_age_band_or_year
206
+ sap_building_parts =
207
+ @xml_doc.xpath("//SAP-Building-Parts/SAP-Building-Part")
208
+ sap_building_parts.each do |sap_building_part|
209
+ building_part_number = sap_building_part.at("Building-Part-Number")
210
+
211
+ # Identifies the Main Dwelling
212
+ if building_part_number&.content == "1"
213
+ return (
214
+ sap_building_part.at_xpath(
215
+ "Construction-Age-Band | Construction-Year",
216
+ )&.content
217
+ )
218
+ end
219
+ end
220
+ nil
221
+ end
222
+
223
+ def tenure
224
+ xpath(%w[Tenure])
225
+ end
226
+
227
+ def transaction_type
228
+ xpath(%w[Transaction-Type])
229
+ end
230
+
231
+ def current_space_heating_demand
232
+ xpath(%w[Space-Heating]) or xpath(%w[Space-Heating-Existing-Dwelling])
233
+ end
234
+
235
+ def current_water_heating_demand
236
+ xpath(%w[Water-Heating])
237
+ end
238
+
239
+ def impact_of_cavity_insulation
240
+ if xpath(%w[Impact-Of-Cavity-Insulation])
241
+ xpath(%w[Impact-Of-Cavity-Insulation])&.to_i
242
+ end
243
+ end
244
+
245
+ def impact_of_loft_insulation
246
+ if xpath(%w[Impact-Of-Loft-Insulation])
247
+ xpath(%w[Impact-Of-Loft-Insulation])&.to_i
248
+ end
249
+ end
250
+
251
+ def impact_of_solid_wall_insulation
252
+ if xpath(%w[Impact-Of-Solid-Wall-Insulation])
253
+ xpath(%w[Impact-Of-Solid-Wall-Insulation])&.to_i
254
+ end
255
+ end
256
+
257
+ def type_of_assessment
258
+ "SAP"
259
+ end
260
+
261
+ def country_code
262
+ xpath(%w[Country-Code])
263
+ end
264
+
265
+ def main_fuel_type
266
+ xpath(%w[Main-Fuel-Type])
267
+ end
268
+
269
+ def secondary_fuel_type
270
+ xpath(%w[Secondary-Fuel-Type])
271
+ end
272
+
273
+ def water_heating_fuel
274
+ xpath(%w[Water-Fuel-Type])
275
+ end
276
+
277
+ def environmental_impact_current
278
+ xpath(%w[Environmental-Impact-Current])&.to_i
279
+ end
280
+
281
+ def environmental_impact_potential
282
+ xpath(%w[Environmental-Impact-Potential])&.to_i
283
+ end
284
+
285
+ def co2_emissions_current_per_floor_area
286
+ xpath(%w[CO2-Emissions-Current-Per-Floor-Area])
287
+ end
288
+
289
+ def level
290
+ xpath(%w[Level])
291
+ end
292
+
293
+ def top_storey
294
+ flat_level_code = xpath(%w[Level])
295
+ flat_level_code == "3" ? "Y" : "N"
296
+ end
297
+
298
+ def main_heating_controls
299
+ xpath(%w[Main-Heating-Controls Description])
300
+ end
301
+
302
+ def multiple_glazed_proportion
303
+ xpath(%w[Multiple-Glazed-Percentage])
304
+ end
305
+
306
+ def low_energy_lighting
307
+ xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Percentage])
308
+ end
309
+
310
+ def fixed_lighting_outlets_count
311
+ xpath(%w[Fixed-Lighting-Outlets-Count])&.to_i
312
+ end
313
+
314
+ def low_energy_fixed_lighting_outlets_count
315
+ xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Count])&.to_i
316
+ end
317
+
318
+ def open_fireplaces_count
319
+ xpath(%w[Open-Fireplaces-Count])&.to_i
320
+ end
321
+
322
+ def hot_water_description
323
+ xpath(%w[Hot-Water Description])
324
+ end
325
+
326
+ def hot_water_energy_efficiency_rating
327
+ xpath(%w[Hot-Water Energy-Efficiency-Rating])
328
+ end
329
+
330
+ def hot_water_environmental_efficiency_rating
331
+ xpath(%w[Hot-Water Environmental-Efficiency-Rating])
332
+ end
333
+
334
+ def window_description
335
+ xpath(%w[Windows Description])
336
+ end
337
+
338
+ def window_energy_efficiency_rating
339
+ xpath(%w[Windows Energy-Efficiency-Rating])
340
+ end
341
+
342
+ def window_environmental_efficiency_rating
343
+ xpath(%w[Windows Environmental-Efficiency-Rating])
344
+ end
345
+
346
+ def secondary_heating_description
347
+ xpath(%w[Secondary-Heating Description])
348
+ end
349
+
350
+ def secondary_heating_energy_efficiency_rating
351
+ xpath(%w[Secondary-Heating Energy-Efficiency-Rating])
352
+ end
353
+
354
+ def secondary_heating_environmental_efficiency_rating
355
+ xpath(%w[Secondary-Heating Environmental-Efficiency-Rating])
356
+ end
357
+
358
+ def lighting_description
359
+ xpath(%w[Lighting Description])
360
+ end
361
+
362
+ def lighting_energy_efficiency_rating
363
+ xpath(%w[Lighting Energy-Efficiency-Rating])
364
+ end
365
+
366
+ def lighting_environmental_efficiency_rating
367
+ xpath(%w[Lighting Environmental-Efficiency-Rating])
368
+ end
369
+
370
+ def built_form
371
+ xpath(%w[Built-Form])
372
+ end
373
+
374
+ def wind_turbine_count
375
+ xpath(%w[Wind-Turbines-Count])&.to_i
376
+ end
377
+
378
+ def all_main_heating_descriptions
379
+ @xml_doc.search("Main-Heating/Description").map(&:content)
380
+ end
381
+
382
+ def all_main_heating_controls_descriptions
383
+ @xml_doc.search("Main-Heating-Controls/Description").map(&:content)
384
+ end
385
+
386
+ def report_type
387
+ xpath(%w[Report-Type])
388
+ end
389
+
390
+ def all_roof_descriptions
391
+ @xml_doc.search("Roof/Description").map(&:content)
392
+ end
393
+
394
+ def all_roof_energy_efficiency_rating
395
+ @xml_doc.search("Roof/Energy-Efficiency-Rating").map(&:content)
396
+ end
397
+
398
+ def all_roof_env_energy_efficiency_rating
399
+ @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content)
400
+ end
401
+
402
+ def all_wall_descriptions
403
+ @xml_doc.search("Walls/Description").map(&:content)
404
+ end
405
+
406
+ def all_wall_energy_efficiency_rating
407
+ @xml_doc.search("Walls/Energy-Efficiency-Rating").map(&:content)
408
+ end
409
+
410
+ def all_wall_env_energy_efficiency_rating
411
+ @xml_doc.search("Walls/Environmental-Efficiency-Rating").map(&:content)
412
+ end
413
+
414
+ def energy_tariff
415
+ xpath(%w[Electricity-Tariff])
416
+ end
417
+
418
+ def floor_level
419
+ xpath(%w[SAP-Flat-Details Level])
420
+ end
421
+
422
+ def floor_height
423
+ @xml_doc.search("Storey-Height").map(&:content)
424
+ end
425
+
426
+ def all_floor_descriptions
427
+ @xml_doc.search("Property-Summary/Floor/Description").map(&:content)
428
+ end
429
+
430
+ def all_floor_energy_efficiency_rating
431
+ @xml_doc
432
+ .search("Property-Summary/Floor/Energy-Efficiency-Rating")
433
+ .map(&:content)
434
+ end
435
+
436
+ def all_floor_env_energy_efficiency_rating
437
+ @xml_doc
438
+ .search("Property-Summary/Floor/Environmental-Efficiency-Rating")
439
+ .map(&:content)
440
+ end
441
+
442
+ def all_main_heating_energy_efficiency
443
+ @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content)
444
+ end
445
+
446
+ def all_main_heating_controls_energy_efficiency
447
+ @xml_doc
448
+ .search("Main-Heating-Controls/Energy-Efficiency-Rating")
449
+ .map(&:content)
450
+ end
451
+
452
+ def all_main_heating_controls_environmental_efficiency
453
+ @xml_doc
454
+ .search("Main-Heating-Controls/Environmental-Efficiency-Rating")
455
+ .map(&:content)
456
+ end
457
+
458
+ def all_main_heating_environmental_efficiency
459
+ @xml_doc
460
+ .search("Main-Heating/Environmental-Efficiency-Rating")
461
+ .map(&:content)
462
+ end
463
+
464
+ def cylinder_insul_thickness
465
+ xpath(%w[Hot-Water-Store-Insulation-Thickness])
466
+ end
467
+
468
+ def cylinder_insulation_type
469
+ xpath(%w[Hot-Water-Store-Insulation-Type])
470
+ end
471
+
472
+ def cylinder_size
473
+ xpath(%w[Hot-Water-Store-Size])
474
+ end
475
+
476
+ def has_cylinder_thermostat
477
+ xpath(%w[Has-Cylinder-Thermostat])
478
+ end
479
+
480
+ def mech_vent_sys_index_number
481
+ xpath(%w[Mechanical-Vent-System-Index-Number])&.to_i
482
+ end
483
+
484
+ def mechanical_vent_data_source
485
+ xpath(%w[Mechanical-Ventilation-Data-Source])
486
+ end
487
+
488
+ def thermal_store
489
+ xpath(%w[Thermal-Store])
490
+ end
491
+
492
+ def ventilation_type
493
+ xpath(%w[Ventilation-Type])
494
+ end
495
+
496
+ def addendum
497
+ return nil if xpath(%w[Addendum]).nil?
498
+
499
+ fetch_addendum_numbers.merge(fetch_addendum_boolean_nodes)
500
+ end
501
+ end
502
+ end
503
+ end
@@ -245,6 +245,8 @@ module ViewModel
245
245
  end
246
246
  when :"SAP-Schema-S-19.0.0"
247
247
  return ViewModel::SapSchemaS1900::CommonSchema.new xml_doc
248
+ when :"SAP-Schema-S-17.0"
249
+ return ViewModel::SapSchemaS170::CommonSchema.new xml_doc
248
250
  end
249
251
 
250
252
  raise ArgumentError, "Unsupported schema type"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epb_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MHCLG Energy Performance of Buildings
@@ -1683,6 +1683,17 @@ files:
1683
1683
  - api/schemas/xml/SAP-Schema-NI-18.0.0/SAP/UDT/EPC-Domains.xsd
1684
1684
  - api/schemas/xml/SAP-Schema-NI-18.0.0/SAP/UDT/SAP09-Domains.xsd
1685
1685
  - api/schemas/xml/SAP-Schema-NI-18.0.0/SAP/UDT/SharedDomains.xsd
1686
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/ExternalDefinitions.xml
1687
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/ExternalDefinitions.xsd
1688
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/AssessorManagement.xsd
1689
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/EPC-Certificate.xsd
1690
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/ExceptionList.xsd
1691
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/Property.xsd
1692
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/ReportList.xsd
1693
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/SAP-CollectedData.xsd
1694
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/SAP-Report.xsd
1695
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/UDT/EPC-Domains.xsd
1696
+ - api/schemas/xml/SAP-Schema-S-17.0/SAP/UDT/SAP-Domains.xsd
1686
1697
  - api/schemas/xml/SAP-Schema-S-19.0.0/SAP/ExternalDefinitions.xml
1687
1698
  - api/schemas/xml/SAP-Schema-S-19.0.0/SAP/ExternalDefinitions.xsd
1688
1699
  - api/schemas/xml/SAP-Schema-S-19.0.0/SAP/Templates/AssessorManagement.xsd
@@ -1949,6 +1960,7 @@ files:
1949
1960
  - lib/view_model/sap_schema_ni_173/common_schema.rb
1950
1961
  - lib/view_model/sap_schema_ni_174/common_schema.rb
1951
1962
  - lib/view_model/sap_schema_ni_1800/common_schema.rb
1963
+ - lib/view_model/sap_schema_s_170/common_schema.rb
1952
1964
  - lib/view_model/sap_schema_s_1900/common_schema.rb
1953
1965
  - lib/view_model/sap_wrapper.rb
1954
1966
  - lib/view_model_boundary/node_not_found.rb