Class: ViewModel::RdSapSchemaS210::CommonSchema

Inherits:
DomesticEpcViewModel show all
Defined in:
lib/view_model/rd_sap_schema_s_210/common_schema.rb

Instance Method Summary collapse

Methods inherited from DomesticEpcViewModel

#addendum, #assessor_contact_address, #company_name, #has_hot_water_cylinder, #improvement_title, #lzc_energy_sources, #main_heating_category, #multi_glazing_type, #property_type, #status, #water_heating_code

Methods inherited from BaseViewModel

#initialize, #xpath

Constructor Details

This class inherits a constructor from ViewModel::BaseViewModel

Instance Method Details

#address_idObject



60
61
62
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 60

def address_id
  "LPRN-#{xpath(%w[UPRN])}"
end

#address_line1Object



8
9
10
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 8

def address_line1
  xpath(%w[Property Address Address-Line-1])
end

#address_line2Object



12
13
14
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 12

def address_line2
  xpath(%w[Property Address Address-Line-2]).to_s
end

#address_line3Object



16
17
18
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 16

def address_line3
  xpath(%w[Property Address Address-Line-3]).to_s
end

#address_line4Object



20
21
22
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 20

def address_line4
  xpath(%w[Property Address Address-Line-4]).to_s
end

#all_floor_descriptionsObject



497
498
499
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 497

def all_floor_descriptions
  @xml_doc.search("Property-Summary/Floor/Description").map(&:content)
end

#all_floor_energy_efficiency_ratingObject



501
502
503
504
505
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 501

def all_floor_energy_efficiency_rating
  @xml_doc
    .search("Property-Summary/Floor/Energy-Efficiency-Rating")
    .map(&:content)
end

#all_floor_env_energy_efficiency_ratingObject



507
508
509
510
511
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 507

def all_floor_env_energy_efficiency_rating
  @xml_doc
    .search("Property-Summary/Floor/Environmental-Efficiency-Rating")
    .map(&:content)
end

#all_hot_water_descriptionsObject



286
287
288
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 286

def all_hot_water_descriptions
  @xml_doc.search("Hot-Water/Description").map(&:content)
end

#all_lighting_descriptionsObject



290
291
292
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 290

def all_lighting_descriptions
  @xml_doc.search("Lighting/Description").map(&:content)
end

#all_main_heating_controls_descriptionsObject



272
273
274
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 272

def all_main_heating_controls_descriptions
  @xml_doc.search("Main-Heating-Controls/Description").map(&:content)
end

#all_main_heating_controls_energy_efficiencyObject



513
514
515
516
517
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 513

def all_main_heating_controls_energy_efficiency
  @xml_doc
    .search("Main-Heating-Controls/Energy-Efficiency-Rating")
    .map(&:content)
end

#all_main_heating_controls_environmental_efficiencyObject



519
520
521
522
523
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 519

def all_main_heating_controls_environmental_efficiency
  @xml_doc
    .search("Main-Heating-Controls/Environmental-Efficiency-Rating")
    .map(&:content)
end

#all_main_heating_descriptionsObject



268
269
270
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 268

def all_main_heating_descriptions
  @xml_doc.search("Main-Heating/Description").map(&:content)
end

#all_main_heating_energy_efficiencyObject



276
277
278
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 276

def all_main_heating_energy_efficiency
  @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content)
end

#all_main_heating_environmental_efficiencyObject



280
281
282
283
284
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 280

def all_main_heating_environmental_efficiency
  @xml_doc
    .search("Main-Heating/Environmental-Efficiency-Rating")
    .map(&:content)
end

#all_roof_descriptionsObject



252
253
254
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 252

def all_roof_descriptions
  @xml_doc.search("Roof/Description").map(&:content)
end

#all_roof_energy_efficiency_ratingObject



256
257
258
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 256

def all_roof_energy_efficiency_rating
  @xml_doc.search("Roof/Energy-Efficiency-Rating").map(&:content)
end

#all_roof_env_energy_efficiency_ratingObject



260
261
262
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 260

def all_roof_env_energy_efficiency_rating
  @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content)
end

#all_secondary_heating_descriptionsObject



294
295
296
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 294

def all_secondary_heating_descriptions
  @xml_doc.search("Secondary-Heating/Description").map(&:content)
end

#all_wall_descriptionsObject



457
458
459
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 457

def all_wall_descriptions
  @xml_doc.search("Wall/Description").map(&:content)
end

#all_wall_energy_efficiency_ratingObject



461
462
463
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 461

def all_wall_energy_efficiency_rating
  @xml_doc.search("Wall/Energy-Efficiency-Rating").map(&:content)
end

#all_wall_env_energy_efficiency_ratingObject



465
466
467
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 465

def all_wall_env_energy_efficiency_rating
  @xml_doc.search("Wall/Environmental-Efficiency-Rating").map(&:content)
end

#all_window_descriptionsObject



264
265
266
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 264

def all_window_descriptions
  @xml_doc.search("Window/Description").map(&:content)
end

#assessment_idObject



4
5
6
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 4

def assessment_id
  xpath(%w[RRN])
end

#assessor_emailObject



40
41
42
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 40

def assessor_email
  xpath(%w[Energy-Assessor E-Mail])
end

#assessor_nameObject



36
37
38
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 36

def assessor_name
  xpath(%w[Energy-Assessor Name])
end

#assessor_telephoneObject



44
45
46
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 44

def assessor_telephone
  xpath(%w[Energy-Assessor Telephone])
end

#built_formObject



445
446
447
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 445

def built_form
  xpath(%w[Built-Form])
end

#co2_emissions_current_per_floor_areaObject



314
315
316
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 314

def co2_emissions_current_per_floor_area
  xpath(%w[CO2-Emissions-Current-Per-Floor-Area])&.to_f
end

#country_codeObject



298
299
300
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 298

def country_code
  xpath(%w[Country-Code])
end

#current_carbon_emissionObject



162
163
164
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 162

def current_carbon_emission
  xpath(%w[CO2-Emissions-Current])
end

#current_energy_ratingObject



170
171
172
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 170

def current_energy_rating
  xpath(%w[Energy-Rating-Current])&.to_i
end

#current_space_heating_demandObject



198
199
200
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 198

def current_space_heating_demand
  xpath(%w[Space-Heating-Existing-Dwelling])
end

#current_water_heating_demandObject



202
203
204
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 202

def current_water_heating_demand
  xpath(%w[Water-Heating])
end

#cylinder_insul_thicknessObject



543
544
545
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 543

def cylinder_insul_thickness
  xpath(%w[Cylinder-Insulation-Thickness])
end

#cylinder_insulation_typeObject



547
548
549
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 547

def cylinder_insulation_type
  xpath(%w[Cylinder-Insulation-Type])
end

#cylinder_sizeObject



551
552
553
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 551

def cylinder_size
  xpath(%w[Cylinder-Size])
end

#date_of_assessmentObject



48
49
50
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 48

def date_of_assessment
  xpath(%w[Inspection-Date])
end

#date_of_completionObject



56
57
58
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 56

def date_of_completion
  xpath(%w[Completion-Date])
end

#date_of_expiryObject



64
65
66
67
68
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 64

def date_of_expiry
  expires_at = (Date.parse(date_of_registration) - 1) >> 12 * 10

  expires_at.to_s
end

#date_of_registrationObject



52
53
54
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 52

def date_of_registration
  xpath(%w[Registration-Date])
end

#dwelling_typeObject



180
181
182
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 180

def dwelling_type
  xpath(%w[Dwelling-Type])
end

#electricity_smart_meter_presentObject



477
478
479
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 477

def electricity_smart_meter_present
  Helper::ToBool.execute(xpath(%w[Electricity-Smart-Meter-Present]))
end

#energy_consumption_potentialObject



248
249
250
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 248

def energy_consumption_potential
  xpath(%w[Energy-Consumption-Potential])&.to_f
end

#energy_rating_currentObject



228
229
230
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 228

def energy_rating_current
  xpath(%w[Energy-Rating-Current])&.to_i
end

#energy_rating_potentialObject



232
233
234
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 232

def energy_rating_potential
  xpath(%w[Energy-Rating-Potential])&.to_i
end

#environmental_impact_currentObject



236
237
238
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 236

def environmental_impact_current
  xpath(%w[Environmental-Impact-Current])&.to_i
end

#environmental_impact_potentialObject



240
241
242
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 240

def environmental_impact_potential
  xpath(%w[Environmental-Impact-Potential])&.to_i
end

#estimated_energy_costObject



174
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 174

def estimated_energy_cost; end

#extensions_countObject



449
450
451
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 449

def extensions_count
  xpath(%w[Extensions-Count])&.to_i
end

#fixed_lighting_outlets_countObject



355
356
357
358
359
360
361
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 355

def fixed_lighting_outlets_count
  fixed_lighting_outlets_count = low_energy_fixed_lighting_outlets_count
  if xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])
    fixed_lighting_outlets_count += xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])&.to_i
  end
  fixed_lighting_outlets_count
end

#floor_heightObject



493
494
495
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 493

def floor_height
  @xml_doc.search("Room-Height").map(&:content)
end

#floor_levelObject



481
482
483
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 481

def floor_level
  xpath(%w[Flat-Location])
end

#floors_insulationObject



605
606
607
608
609
610
611
612
613
614
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 605

def floors_insulation
  @xml_doc
    .search("SAP-Building-Part")
    .map do |node|
    {
      floor_u_value: node.at_xpath("Floor-U-Value")&.content,
      floor_insulation_thickness: node.at_xpath("Floor-Insulation-Thickness")&.content,
    }
  end
end

#gas_smart_meter_presentObject



473
474
475
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 473

def gas_smart_meter_present
  Helper::ToBool.execute(xpath(%w[Gas-Smart-Meter-Present]))
end

#glazed_areaObject



342
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 342

def glazed_area; end

#habitable_room_countObject



224
225
226
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 224

def habitable_room_count
  xpath(%w[Habitable-Room-Count])&.to_i
end

#has_cylinder_thermostatObject



555
556
557
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 555

def has_cylinder_thermostat
  xpath(%w[Cylinder-Thermostat])
end

#heat_loss_corridorObject



397
398
399
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 397

def heat_loss_corridor
  xpath(%w[Heat-Loss-Corridor])
end

#heated_room_countObject



344
345
346
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 344

def heated_room_count
  xpath(%w[Heated-Room-Count])&.to_i
end

#heating_cost_currentObject



150
151
152
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 150

def heating_cost_current
  xpath(%w[Heating-Cost-Current])
end

#heating_cost_potentialObject



138
139
140
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 138

def heating_cost_potential
  xpath(%w[Heating-Cost-Potential])
end

#hot_water_cost_currentObject



146
147
148
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 146

def hot_water_cost_current
  xpath(%w[Hot-Water-Cost-Current])
end

#hot_water_cost_potentialObject



134
135
136
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 134

def hot_water_cost_potential
  xpath(%w[Hot-Water-Cost-Potential])
end

#hot_water_descriptionObject



381
382
383
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 381

def hot_water_description
  xpath(%w[Hot-Water Description])
end

#hot_water_energy_efficiency_ratingObject



385
386
387
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 385

def hot_water_energy_efficiency_rating
  xpath(%w[Hot-Water Energy-Efficiency-Rating])
end

#hot_water_environmental_efficiency_ratingObject



389
390
391
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 389

def hot_water_environmental_efficiency_rating
  xpath(%w[Hot-Water Environmental-Efficiency-Rating])
end

#impact_of_cavity_insulationObject



206
207
208
209
210
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 206

def impact_of_cavity_insulation
  if xpath(%w[Impact-Of-Cavity-Insulation])
    xpath(%w[Impact-Of-Cavity-Insulation])&.to_i
  end
end

#impact_of_loft_insulationObject



212
213
214
215
216
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 212

def impact_of_loft_insulation
  if xpath(%w[Impact-Of-Loft-Insulation])
    xpath(%w[Impact-Of-Loft-Insulation])&.to_i
  end
end

#impact_of_solid_wall_insulationObject



218
219
220
221
222
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 218

def impact_of_solid_wall_insulation
  if xpath(%w[Impact-Of-Solid-Wall-Insulation])
    xpath(%w[Impact-Of-Solid-Wall-Insulation])&.to_i
  end
end

#improvementsObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 96

def improvements
  @xml_doc
    .search("Suggested-Improvements Improvement")
    .map do |node|
      {
        energy_performance_rating_improvement:
          xpath(%w[Energy-Performance-Rating], node).to_i,
        environmental_impact_rating_improvement:
          xpath(%w[Environmental-Impact-Rating], node).to_i,
        green_deal_category_code: xpath(%w[Green-Deal-Category], node),
        improvement_category: xpath(%w[Improvement-Category], node),
        improvement_code:
          xpath(%w[Improvement-Details Improvement-Number], node),
        improvement_description: xpath(%w[Improvement-Description], node),
        improvement_title: improvement_title(node),
        improvement_type: xpath(%w[Improvement-Type], node),
        indicative_cost: xpath(%w[Indicative-Cost], node),
        sequence: xpath(%w[Sequence], node).to_i,
        typical_saving: xpath(%w[Typical-Saving], node),
      }
    end
end

#levelObject



322
323
324
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 322

def level
  xpath(%w[Level])
end

#lighting_cost_currentObject



154
155
156
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 154

def lighting_cost_current
  xpath(%w[Lighting-Cost-Current])
end

#lighting_cost_potentialObject



142
143
144
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 142

def lighting_cost_potential
  xpath(%w[Lighting-Cost-Potential])
end

#lighting_descriptionObject



429
430
431
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 429

def lighting_description
  xpath(%w[Lighting Description])
end

#lighting_energy_efficiency_ratingObject



433
434
435
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 433

def lighting_energy_efficiency_rating
  xpath(%w[Lighting Energy-Efficiency-Rating])
end

#lighting_environmental_efficiency_ratingObject



437
438
439
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 437

def lighting_environmental_efficiency_rating
  xpath(%w[Lighting Environmental-Efficiency-Rating])
end

#low_energy_fixed_lighting_outlets_countObject



363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 363

def low_energy_fixed_lighting_outlets_count
  low_energy_fixed_lighting_outlets_count = 0
  if xpath(%w[CFL-Fixed-Lighting-Bulbs-Count])
    low_energy_fixed_lighting_outlets_count += xpath(%w[CFL-Fixed-Lighting-Bulbs-Count])&.to_i
  end
  if xpath(%w[LED-Fixed-Lighting-Bulbs-Count])
    low_energy_fixed_lighting_outlets_count += xpath(%w[LED-Fixed-Lighting-Bulbs-Count])&.to_i
  end
  if xpath(%w[Low-Energy-Fixed-Lighting-Bulbs-Count])
    low_energy_fixed_lighting_outlets_count += xpath(%w[Low-Energy-Fixed-Lighting-Bulbs-Count])&.to_i
  end
  low_energy_fixed_lighting_outlets_count
end

#low_energy_lightingObject



348
349
350
351
352
353
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 348

def low_energy_lighting
  if fixed_lighting_outlets_count.zero?
    return 0
  end
  ((low_energy_fixed_lighting_outlets_count.to_f / fixed_lighting_outlets_count) * 100).round
end

#main_dwelling_construction_age_band_or_yearObject



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 525

def main_dwelling_construction_age_band_or_year
  sap_building_parts =
    @xml_doc.xpath("//SAP-Building-Parts/SAP-Building-Part")
  sap_building_parts.each do |sap_building_part|
    building_part_number = sap_building_part.at("Building-Part-Number")

    # Identifies the Main Dwelling
    if building_part_number&.content == "1"
      return (
        sap_building_part.at_xpath(
          "Construction-Age-Band | Construction-Year",
        )&.content
      )
    end
  end
  nil
end

#main_fuel_typeObject



302
303
304
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 302

def main_fuel_type
  xpath(%w[Main-Fuel-Type])
end

#main_heating_controlsObject



334
335
336
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 334

def main_heating_controls
  xpath(%w[Main-Heating-Controls Description])
end

#main_heating_detailsObject



649
650
651
652
653
654
655
656
657
658
659
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 649

def main_heating_details
  @xml_doc
    .search("Main-Heating")
    .map do |node|
    {
      main_heating_index_number: xpath(%w[Main-Heating-Index-Number]),
      sap_main_heating_code: xpath(%w[SAP-Main-Heating-Code]),
      main_fuel_type: xpath(%w[Main-Fuel-Type]),
    }
  end
end

#mains_gasObject



318
319
320
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 318

def mains_gas
  xpath(%w[Mains-Gas])
end

#mechanical_ventilationObject



489
490
491
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 489

def mechanical_ventilation
  xpath(%w[Mechanical-Ventilation])
end

#meter_typeObject



469
470
471
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 469

def meter_type
  xpath(%w[Meter-Type])
end

#multiple_glazed_proportionObject



338
339
340
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 338

def multiple_glazed_proportion
  xpath(%w[Multiple-Glazed-Proportion])
end

#open_fireplaces_countObject



377
378
379
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 377

def open_fireplaces_count
  xpath(%w[Open-Chimneys-Count])&.to_i
end

#party_wall_constructionObject



559
560
561
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 559

def party_wall_construction
  xpath(%w[SAP-Building-Part Party-Wall-Construction])
end

#party_walls_constructionObject

For lodgement rules



565
566
567
568
569
570
571
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 565

def party_walls_construction
  @xml_doc
    .search("SAP-Building-Part")
    .map do |node|
    xpath(%w[Party-Wall-Construction], node)
  end
end

#photovoltaic_roof_area_percentObject



441
442
443
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 441

def photovoltaic_roof_area_percent
  xpath(%w[Photovoltaic-Supply Percent-Roof-Area])
end

#postcodeObject



28
29
30
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 28

def postcode
  xpath(%w[Property Address Postcode])
end

#potential_carbon_emissionObject



158
159
160
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 158

def potential_carbon_emission
  xpath(%w[CO2-Emissions-Potential])
end

#potential_energy_ratingObject



166
167
168
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 166

def potential_energy_rating
  xpath(%w[Energy-Rating-Potential])&.to_i
end

#potential_energy_savingObject



184
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 184

def potential_energy_saving; end

#primary_energy_useObject



244
245
246
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 244

def primary_energy_use
  xpath(%w[Energy-Consumption-Current])&.to_f
end

#property_age_bandObject



186
187
188
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 186

def property_age_band
  xpath(%w[Construction-Age-Band])
end

#property_summaryObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 70

def property_summary
  @xml_doc.search("Energy-Assessment Property-Summary").children.select(
    &:element?
  ).map { |node|
    next if xpath(%w[Energy-Efficiency-Rating], node).nil?

    {
      energy_efficiency_rating:
        xpath(%w[Energy-Efficiency-Rating], node).to_i,
      environmental_efficiency_rating:
        xpath(%w[Environmental-Efficiency-Rating], node).to_i,
      name: node.name.underscore,
      description: xpath(%w[Description], node),
    }
  }.compact
end

#recommendations_for_reportObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 119

def recommendations_for_report
  @xml_doc
    .search("Suggested-Improvements Improvement")
    .map do |node|
      {
        sequence: xpath(%w[Sequence], node).to_i,
        improvement_summary: xpath(%w[Improvement-Summary], node),
        improvement_description: xpath(%w[Improvement-Description], node),
        improvement_code:
          xpath(%w[Improvement-Details Improvement-Number], node),
        indicative_cost: xpath(%w[Indicative-Cost], node),
      }
    end
end


91
92
93
94
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 91

def related_party_disclosure_number
  disclosure_number = xpath(%w[Related-Party-Disclosure-Number])
  disclosure_number.nil? ? nil : disclosure_number.to_i
end


87
88
89
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 87

def related_party_disclosure_text
  xpath(%w[Related-Party-Disclosure-Text])
end

#report_typeObject



453
454
455
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 453

def report_type
  xpath(%w[Report-Type])
end

#rooms_in_roofObject



641
642
643
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 641

def rooms_in_roof
  nil
end

#rooms_in_roof_insulationObject



601
602
603
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 601

def rooms_in_roof_insulation
  nil
end

#rooms_in_roof_roof_insulationObject



645
646
647
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 645

def rooms_in_roof_roof_insulation
  nil
end

#rooves_construction_and_insulationObject



590
591
592
593
594
595
596
597
598
599
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 590

def rooves_construction_and_insulation
  @xml_doc
    .search("SAP-Building-Part")
    .map do |node|
    {
      roof_insulation_location: node.at_xpath("Roof-Insulation-Location")&.content,
      roof_construction: node.at_xpath("Roof-Construction")&.content,
    }
  end
end

#rooves_insulationObject



616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 616

def rooves_insulation
  @xml_doc
    .search("SAP-Building-Part")
    .map do |node|
    {
      roof_u_value: node.at_xpath("Roof-U-Value")&.content,
      roof_insulation_thickness: node.at_xpath("Roof-Insulation-Thickness")&.content,
      rafter_insulation_thickness: node.at_xpath("Rafter-Insulation-Thickness")&.content,
      flat_roof_insulation_thickness: node.at_xpath("Flat-Roof-Insulation-Thickness")&.content,
      sloping_ceiling_insulation_thickness: node.at_xpath("Sloping-Ceiling-Insulation-Thickness")&.content,
    }
  end
end

#scheme_assessor_idObject



32
33
34
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 32

def scheme_assessor_id
  xpath(%w[Membership-Number]) or xpath(%w[Certificate-Number])
end

#secondary_fuel_typeObject



306
307
308
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 306

def secondary_fuel_type
  xpath(%w[Secondary-Fuel-Type])
end

#secondary_heating_descriptionObject



417
418
419
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 417

def secondary_heating_description
  xpath(%w[Secondary-Heating Description])
end

#secondary_heating_energy_efficiency_ratingObject



421
422
423
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 421

def secondary_heating_energy_efficiency_rating
  xpath(%w[Secondary-Heating Energy-Efficiency-Rating])
end

#secondary_heating_environmental_efficiency_ratingObject



425
426
427
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 425

def secondary_heating_environmental_efficiency_rating
  xpath(%w[Secondary-Heating Environmental-Efficiency-Rating])
end

#solar_water_heating_flagObject



485
486
487
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 485

def solar_water_heating_flag
  xpath(%w[Solar-Water-Heating])
end

#storey_countObject



330
331
332
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 330

def storey_count
  xpath(%w[Storey-Count])&.to_i
end

#tenureObject



190
191
192
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 190

def tenure
  xpath(%w[Tenure])
end

#top_storeyObject



326
327
328
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 326

def top_storey
  xpath(%w[Top-Storey])
end

#total_floor_areaObject



176
177
178
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 176

def total_floor_area
  xpath(%w[Property-Summary Total-Floor-Area])
end

#townObject



24
25
26
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 24

def town
  xpath(%w[Property Address Post-Town])
end

#transaction_typeObject



194
195
196
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 194

def transaction_type
  xpath(%w[Transaction-Type])
end

#unheated_corridor_lengthObject



401
402
403
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 401

def unheated_corridor_length
  xpath(%w[Unheated-Corridor-Length])
end

#walls_insulationObject



630
631
632
633
634
635
636
637
638
639
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 630

def walls_insulation
  @xml_doc
    .search("SAP-Building-Part")
    .map do |node|
    {
      wall_u_value: node.at_xpath("Wall-U-Value")&.content,
      wall_insulation_thickness: node.at_xpath("Wall-Insulation-Thickness")&.content,
    }
  end
end

#walls_thicknessObject



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 573

def walls_thickness
  @xml_doc
    .search("SAP-Building-Part")
    .map do |node|
    {
      alternative_wall_thickness: node.at_xpath("SAP-Alternative-Wall/Wall-Thickness")&.content,
      alternative_wall_thickness_measured: node.at_xpath("SAP-Alternative-Wall/Wall-Thickness-Measured")&.content,
      alternative_wall_construction: node.at_xpath("SAP-Alternative-Wall/Wall-Construction")&.content,
      alternative_wall_u_value: node.at_xpath("SAP-Alternative-Wall/Wall-U-Value")&.content,
      alternative_wall_insulation_thickness: node.at_xpath("SAP-Alternative-Wall/Wall-Insulation-Thickness")&.content,
      wall_thickness: node.at_xpath("Wall-Thickness")&.content,
      wall_construction: node.at_xpath("Wall-Construction")&.content,
      wall_thickness_measured: node.at_xpath("Wall-Thickness-Measured")&.content,
    }
  end
end

#water_heatingObject



661
662
663
664
665
666
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 661

def water_heating
  {
    water_heating_fuel: xpath(%w[Water-Heating-Fuel]),
    water_heating_code: xpath(%w[Water-Heating-Code]),
  }
end

#water_heating_fuelObject



310
311
312
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 310

def water_heating_fuel
  xpath(%w[Water-Heating-Fuel])
end

#wind_turbine_countObject



393
394
395
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 393

def wind_turbine_count
  xpath(%w[Wind-Turbines-Count])&.to_i
end

#window_descriptionObject



405
406
407
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 405

def window_description
  xpath(%w[Window Description])
end

#window_energy_efficiency_ratingObject



409
410
411
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 409

def window_energy_efficiency_rating
  xpath(%w[Window Energy-Efficiency-Rating])
end

#window_environmental_efficiency_ratingObject



413
414
415
# File 'lib/view_model/rd_sap_schema_s_210/common_schema.rb', line 413

def window_environmental_efficiency_rating
  xpath(%w[Window Environmental-Efficiency-Rating])
end