epb_view_models 2.7.1 → 2.8.0

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.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/api/schemas/data/orchestrate.json +19 -2
  3. data/api/schemas/xml/CEPC-S-7.0/Reports/BaseDataTypes.xsd +296 -296
  4. data/api/schemas/xml/CEPC-S-7.0/Reports/CEPC-Reports.xsd +63 -63
  5. data/api/schemas/xml/CEPC-S-7.0/Reports/Input-Data.xsd +34 -34
  6. data/api/schemas/xml/CEPC-S-7.0/Reports/Performance-Summary.xsd +120 -120
  7. data/api/schemas/xml/CEPC-S-7.0/Reports/Property.xsd +67 -67
  8. data/api/schemas/xml/CEPC-S-7.0/Reports/Report-Header.xsd +178 -178
  9. data/api/schemas/xml/CEPC-S-7.0/Reports/Reported-Data.xsd +391 -391
  10. data/api/schemas/xml/CEPC-S-7.0/Reports/UserManagement.xsd +171 -171
  11. data/api/schemas/xml/CEPC-S-7.1/Reports/BaseDataTypes.xsd +300 -300
  12. data/api/schemas/xml/CEPC-S-7.1/Reports/CEPC-Reports.xsd +66 -66
  13. data/api/schemas/xml/CEPC-S-7.1/Reports/Input-Data.xsd +34 -34
  14. data/api/schemas/xml/CEPC-S-7.1/Reports/Performance-Summary.xsd +125 -125
  15. data/api/schemas/xml/CEPC-S-7.1/Reports/Performance-Summary.xsd.bak +123 -123
  16. data/api/schemas/xml/CEPC-S-7.1/Reports/Property.xsd +67 -67
  17. data/api/schemas/xml/CEPC-S-7.1/Reports/Report-Header.xsd +178 -178
  18. data/api/schemas/xml/CEPC-S-7.1/Reports/Reported-Data.xsd +406 -406
  19. data/api/schemas/xml/CEPC-S-7.1/Reports/UserManagement.xsd +174 -174
  20. data/api/schemas/xml/CEPC-S-8.0.0/Reports/BaseDataTypes.xsd +302 -0
  21. data/api/schemas/xml/CEPC-S-8.0.0/Reports/CEPC-Reports.xsd +69 -0
  22. data/api/schemas/xml/CEPC-S-8.0.0/Reports/Input-Data.xsd +39 -0
  23. data/api/schemas/xml/CEPC-S-8.0.0/Reports/Performance-Summary.xsd +130 -0
  24. data/api/schemas/xml/CEPC-S-8.0.0/Reports/Property.xsd +72 -0
  25. data/api/schemas/xml/CEPC-S-8.0.0/Reports/Report-Header.xsd +182 -0
  26. data/api/schemas/xml/CEPC-S-8.0.0/Reports/Reported-Data.xsd +411 -0
  27. data/api/schemas/xml/CEPC-S-8.0.0/Reports/UserManagement.xsd +175 -0
  28. data/api/schemas/xml/CS63-S-8.0.0/ActionPlan.xsd +822 -0
  29. data/api/schemas/xml/DECAR-S-8.0.0/DEC-Summary.xsd +399 -0
  30. data/api/schemas/xml/DECAR-S-8.0.0/Reports/BaseDataTypes.xsd +187 -0
  31. data/api/schemas/xml/DECAR-S-8.0.0/Reports/CEPC-Reports.xsd +78 -0
  32. data/api/schemas/xml/DECAR-S-8.0.0/Reports/Input-Data.xsd +313 -0
  33. data/api/schemas/xml/DECAR-S-8.0.0/Reports/Performance-Summary.xsd +111 -0
  34. data/api/schemas/xml/DECAR-S-8.0.0/Reports/Report-Header.xsd +455 -0
  35. data/api/schemas/xml/DECAR-S-8.0.0/Reports/Reported-Data.xsd +408 -0
  36. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/ExternalDefinitions.xml +1456 -1456
  37. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/ExternalDefinitions.xsd +236 -236
  38. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/AssessorManagement.xsd +16 -16
  39. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/EPC-Certificate.xsd +388 -388
  40. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/EPC-CollectedData.xsd +784 -784
  41. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/HCR-FeaturesExternal.xsd +283 -283
  42. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/HCR-FeaturesGrounds.xsd +222 -222
  43. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/HCR-FeaturesInternal.xsd +205 -205
  44. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/HCR-FeaturesServices.xsd +311 -311
  45. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/HCR-PropertyDetails.xsd +380 -380
  46. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/HCR-RiskAssessment.xsd +298 -298
  47. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/Property.xsd +67 -67
  48. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/SAP-Reports.xsd +201 -201
  49. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/Templates/UserManagement.xsd +259 -259
  50. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/UDT/BaseDataTypes.xsd +176 -176
  51. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/UDT/EPC-Domains.xsd +881 -881
  52. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/UDT/HCR-Domains.xsd +1779 -1779
  53. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/UDT/SAP-Domains.xsd +1650 -1650
  54. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/UDT/SharedDomains.xsd +768 -768
  55. data/api/schemas/xml/RdSAP-Schema-S-16.1/RdSAP/UDT/TypeDefinitions.xsd +19 -19
  56. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/ExternalDefinitions.xml +1456 -1456
  57. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/ExternalDefinitions.xsd +236 -236
  58. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/Templates/AssessorManagement.xsd +208 -208
  59. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/Templates/EPC-Certificate.xsd +400 -400
  60. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/Templates/EPC-CollectedData.xsd +957 -957
  61. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/Templates/ExceptionList.xsd +18 -18
  62. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/Templates/Property.xsd +66 -66
  63. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/Templates/RdSAP-Report.xsd +180 -180
  64. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/Templates/ReportList.xsd +26 -26
  65. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/UDT/EPC-Domains.xsd +843 -843
  66. data/api/schemas/xml/RdSAP-Schema-S-17.00/RdSAP/UDT/SAP-Domains.xsd +2541 -2541
  67. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/ExternalDefinitions.xml +1456 -1456
  68. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/ExternalDefinitions.xsd +236 -236
  69. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/Templates/AssessorManagement.xsd +213 -213
  70. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/Templates/EPC-Certificate.xsd +400 -400
  71. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/Templates/EPC-CollectedData.xsd +966 -966
  72. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/Templates/ExceptionList.xsd +18 -18
  73. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/Templates/Property.xsd +66 -66
  74. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/Templates/RdSAP-Report.xsd +175 -175
  75. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/Templates/ReportList.xsd +26 -26
  76. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/UDT/EPC-Domains.xsd +853 -853
  77. data/api/schemas/xml/RdSAP-Schema-S-18.0/RdSAP/UDT/SAP-Domains.xsd +2551 -2551
  78. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/ExternalDefinitions.xsd +261 -261
  79. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/AssessorManagement.xsd +213 -213
  80. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/EPC-Certificate.xsd +400 -400
  81. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/EPC-CollectedData.xsd +1051 -1051
  82. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/Property.xsd +66 -66
  83. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/RdSAP-Report.xsd +176 -176
  84. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/Templates/ReportList.xsd +26 -26
  85. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/UDT/EPC-Domains.xsd +858 -858
  86. data/api/schemas/xml/RdSAP-Schema-S-19.0/RdSAP/UDT/SAP-Domains.xsd +2684 -2684
  87. data/api/schemas/xml/RdSAP-Schema-S-21.0/RdSAP/Templates/RdSAP-Report.cs +11846 -11846
  88. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/ExternalDefinitions.xml +1832 -0
  89. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/ExternalDefinitions.xsd +267 -0
  90. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/Templates/AssessorManagement.xsd +212 -0
  91. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/Templates/EPC-Certificate.xsd +399 -0
  92. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/Templates/EPC-CollectedData.xsd +1453 -0
  93. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/Templates/Property.xsd +67 -0
  94. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/Templates/RdSAP-Report.xsd +179 -0
  95. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/UDT/EPC-Domains.xsd +943 -0
  96. data/api/schemas/xml/RdSAP-Schema-S-22.0.0/RdSAP/UDT/SAP-Domains.xsd +3557 -0
  97. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/ExternalDefinitions.txt +236 -236
  98. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/ExternalDefinitions.xml +1456 -1456
  99. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/Templates/EPC-Certificate.xsd +433 -433
  100. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/Templates/Property.xsd +69 -69
  101. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/Templates/SAP09-CollectedData.xsd +1326 -1326
  102. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/Templates/SAP09-Report.xsd +196 -196
  103. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/Templates/UserManagement.xsd +217 -217
  104. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/UDT/BaseDataTypes.xsd +175 -175
  105. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/UDT/EPC-Domains.xsd +813 -813
  106. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/UDT/SAP09-Domains.xsd +3457 -3457
  107. data/api/schemas/xml/SAP-Schema-S-16.1/SAP/UDT/SharedDomains.xsd +317 -317
  108. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/ExternalDefinitions.xml +1456 -1456
  109. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/ExternalDefinitions.xsd +236 -236
  110. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/AssessorManagement.xsd +216 -216
  111. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/EPC-Certificate.xsd +457 -457
  112. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/ExceptionList.xsd +18 -18
  113. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/Property.xsd +62 -62
  114. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/ReportList.xsd +26 -26
  115. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/SAP-CollectedData.xsd +1444 -1444
  116. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/Templates/SAP-Report.xsd +193 -193
  117. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/UDT/EPC-Domains.xsd +558 -558
  118. data/api/schemas/xml/SAP-Schema-S-17.0/SAP/UDT/SAP-Domains.xsd +2975 -2975
  119. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/ExternalDefinitions.xml +1352 -0
  120. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/ExternalDefinitions.xsd +242 -0
  121. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/AssessorManagement.xsd +210 -0
  122. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/EPC-Certificate.xsd +495 -0
  123. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/ExceptionList.xsd +23 -0
  124. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/Property.xsd +77 -0
  125. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/ReportList.xsd +30 -0
  126. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/SAP-CollectedData.xsd +1800 -0
  127. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/SAP-Compliance-Report.xsd +40 -0
  128. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/Templates/SAP-Report.xsd +206 -0
  129. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/UDT/EPC-Domains.xsd +564 -0
  130. data/api/schemas/xml/SAP-Schema-S-20.0.0/SAP/UDT/SAP-Domains.xsd +3140 -0
  131. data/lib/epb_view_models/version.rb +1 -1
  132. data/lib/view_model/cepc800/common_schema.rb +7 -7
  133. data/lib/view_model/cepc_s_800/cepc.rb +184 -0
  134. data/lib/view_model/cepc_wrapper.rb +2 -0
  135. data/lib/view_model/{cs63 → cs63_70}/common_schema.rb +1 -1
  136. data/lib/view_model/cs63_800/common_schema.rb +211 -0
  137. data/lib/view_model/cs63_wrapper.rb +15 -3
  138. data/lib/view_model/dec_rr_wrapper.rb +2 -0
  139. data/lib/view_model/dec_summary_wrapper.rb +2 -0
  140. data/lib/view_model/dec_wrapper.rb +2 -0
  141. data/lib/view_model/decar_s_800/common_schema.rb +109 -0
  142. data/lib/view_model/decar_s_800/dec.rb +235 -0
  143. data/lib/view_model/decar_s_800/dec_rr.rb +102 -0
  144. data/lib/view_model/factory.rb +6 -1
  145. data/lib/view_model/rd_sap_schema_s_2200/common_schema.rb +685 -0
  146. data/lib/view_model/rd_sap_wrapper.rb +4 -2
  147. data/lib/view_model/sap_schema_s_2000/common_schema.rb +619 -0
  148. data/lib/view_model/sap_wrapper.rb +2 -0
  149. metadata +46 -2
@@ -0,0 +1,619 @@
1
+ module ViewModel
2
+ module SapSchemaS2000
3
+ class CommonSchema < ViewModel::DomesticEpcViewModel
4
+ THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY = 65
5
+
6
+ def assessment_id
7
+ xpath(%w[Report-Header RRN])
8
+ end
9
+
10
+ def address_line1
11
+ xpath(%w[Report-Header Property Address Address-Line-1])
12
+ end
13
+
14
+ def address_line2
15
+ xpath(%w[Report-Header Property Address Address-Line-2])
16
+ end
17
+
18
+ def address_line3
19
+ xpath(%w[Report-Header Property Address Address-Line-3])
20
+ end
21
+
22
+ def town
23
+ xpath(%w[Report-Header Property Address Post-Town])
24
+ end
25
+
26
+ def postcode
27
+ xpath(%w[Report-Header Property Address Postcode])
28
+ end
29
+
30
+ def scheme_assessor_id
31
+ xpath(%w[Membership-Number]) or xpath(%w[Certificate-Number])
32
+ end
33
+
34
+ def assessor_name
35
+ xpath(%w[Home-Inspector Name])
36
+ end
37
+
38
+ def assessor_email
39
+ xpath(%w[Home-Inspector/E-Mail])
40
+ end
41
+
42
+ def assessor_telephone
43
+ xpath(%w[Home-Inspector/Telephone])
44
+ end
45
+
46
+ def date_of_assessment
47
+ xpath(%w[Inspection-Date])
48
+ end
49
+
50
+ def date_of_registration
51
+ xpath(%w[Registration-Date])
52
+ end
53
+
54
+ def address_id
55
+ xpath(%w[UPRN])
56
+ end
57
+
58
+ def date_of_expiry
59
+ expires_at = (Date.parse(date_of_registration) - 1) >> 12 * 10
60
+
61
+ expires_at.to_s
62
+ end
63
+
64
+ def property_summary
65
+ @xml_doc.search("Energy-Assessment Property-Summary").children.select(
66
+ &:element?
67
+ ).map { |node|
68
+ next if xpath(%w[Energy-Efficiency-Rating], node).nil?
69
+
70
+ {
71
+ energy_efficiency_rating:
72
+ xpath(%w[Energy-Efficiency-Rating], node).to_i,
73
+ environmental_efficiency_rating:
74
+ xpath(%w[Environmental-Efficiency-Rating], node).to_i,
75
+ name: node.name.underscore,
76
+ description: xpath(%w[Description], node),
77
+ }
78
+ }.compact
79
+ end
80
+
81
+ def related_party_disclosure_text
82
+ xpath(%w[Related-Party-Disclosure-Text])
83
+ end
84
+
85
+ def related_party_disclosure_number
86
+ xpath(%w[Related-Party-Disclosure-Number])&.to_i
87
+ end
88
+
89
+ def improvements
90
+ @xml_doc
91
+ .search("Suggested-Improvements Improvement")
92
+ .map do |node|
93
+ {
94
+ energy_performance_rating_improvement:
95
+ xpath(%w[Energy-Performance-Rating], node).to_i,
96
+ environmental_impact_rating_improvement:
97
+ xpath(%w[Environmental-Impact-Rating], node).to_i,
98
+ green_deal_category_code: xpath(%w[Green-Deal-Category], node),
99
+ improvement_category: xpath(%w[Improvement-Category], node),
100
+ improvement_code:
101
+ xpath(%w[Improvement-Details Improvement-Number], node),
102
+ improvement_description: xpath(%w[Improvement-Description], node),
103
+ improvement_title: improvement_title(node),
104
+ improvement_type: xpath(%w[Improvement-Type], node),
105
+ indicative_cost: xpath(%w[Indicative-Cost], node),
106
+ sequence: xpath(%w[Sequence], node).to_i,
107
+ typical_saving: xpath(%w[Typical-Saving], node),
108
+ }
109
+ end
110
+ end
111
+
112
+ def recommendations_for_report
113
+ accessor = Accessor::DomesticRecommendationsAccessor.instance
114
+ @xml_doc
115
+ .search("Suggested-Improvements Improvement")
116
+ .map do |node|
117
+ improvement_code = xpath(%w[Improvement-Details Improvement-Number], node)
118
+ {
119
+ sequence: xpath(%w[Sequence], node).to_i,
120
+ improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "SAP-Schema-19.0.0", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
121
+ improvement_description: improvement_code ? accessor.fetch_details(schema_version: "SAP-Schema-19.0.0", improvement_number: improvement_code).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])&.to_f
171
+ end
172
+
173
+ def energy_consumption_potential
174
+ xpath(%w[Energy-Consumption-Potential])&.to_f
175
+ end
176
+
177
+ def estimated_energy_cost; end
178
+
179
+ def total_floor_area
180
+ xpath(%w[Property-Summary Total-Floor-Area])&.to_f
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 all_sap_floor_dimensions
258
+ @xml_doc.search("SAP-Floor-Dimension").select(&:element?).map { |node|
259
+ { total_floor_area: xpath(%w[Total-Floor-Area], node).to_f }
260
+ }.compact
261
+ end
262
+
263
+ def type_of_assessment
264
+ "SAP"
265
+ end
266
+
267
+ def level
268
+ xpath(%w[Level])
269
+ end
270
+
271
+ def top_storey
272
+ flat_level_code = xpath(%w[SAP-FlatLevelCode])
273
+ flat_level_code == "3" ? "Y" : "N"
274
+ end
275
+
276
+ def storey_count
277
+ xpath(%w[Storeys])
278
+ end
279
+
280
+ def building_part_number
281
+ xpath(%w[Building-Part-Number])
282
+ end
283
+
284
+ def all_building_parts
285
+ @xml_doc
286
+ .search("SAP-Building-Parts/SAP-Building-Part")
287
+ .map do |part|
288
+ {
289
+ roof_insulation_thickness:
290
+ if part.xpath("Roof-Insulation-Thickness").empty?
291
+ nil
292
+ else
293
+ part.xpath("Roof-Insulation-Thickness").text
294
+ end,
295
+ rafter_insulation_thickness:
296
+ xpath(%w[Rafter-Insulation-Thickness], part),
297
+ flat_roof_insulation_thickness:
298
+ xpath(%w[Flat-Roof-Insulation-Thickness], part),
299
+ sloping_ceiling_insulation_thickness:
300
+ xpath(%w[Sloping-Ceiling-Insulation-Thickness], part),
301
+ roof_u_value: xpath(%w[Roof-U-Value], part),
302
+ }
303
+ end
304
+ end
305
+
306
+ def floor_heat_loss
307
+ xpath(%w[Floor-Heat-Loss])
308
+ end
309
+
310
+ def immersion_heating_type
311
+ xpath(%w[Immersion-Heating-Type])
312
+ end
313
+
314
+ def main_fuel_type
315
+ xpath(%w[Main-Fuel-Type])
316
+ end
317
+
318
+ def secondary_fuel_type
319
+ xpath(%w[Secondary-Fuel-Type])
320
+ end
321
+
322
+ def water_heating_fuel
323
+ xpath(%w[Water-Fuel-Type])
324
+ end
325
+
326
+ def boiler_flue_type
327
+ xpath(%w[Boiler-Flue-Type])
328
+ end
329
+
330
+ def meter_type
331
+ xpath(%w[Meter-Type])
332
+ end
333
+
334
+ def sap_main_heating_code
335
+ xpath(%w[SAP-Main-Heating-Code])
336
+ end
337
+
338
+ def country_code
339
+ xpath(%w[Country-Code])
340
+ end
341
+
342
+ def environmental_impact_current
343
+ xpath(%w[Environmental-Impact-Current])&.to_i
344
+ end
345
+
346
+ def environmental_impact_potential
347
+ xpath(%w[Environmental-Impact-Potential])&.to_i
348
+ end
349
+
350
+ def co2_emissions_current_per_floor_area
351
+ xpath(%w[CO2-Emissions-Current-Per-Floor-Area])&.to_f
352
+ end
353
+
354
+ def main_heating_controls
355
+ xpath(%w[Main-Heating-Controls Description])
356
+ end
357
+
358
+ def multiple_glazed_proportion
359
+ xpath(%w[Multiple-Glazed-Percentage])
360
+ end
361
+
362
+ def fixed_lighting_outlets_count
363
+ @xml_doc.search("Fixed-Lights/Fixed-Light/Lighting-Outlets").map(&:content).map(&:to_i).sum
364
+ end
365
+
366
+ def format_fixed_light_array
367
+ @xml_doc
368
+ .search("Fixed-Lights/Fixed-Light")
369
+ .map do |part|
370
+ {
371
+ lighting_efficacy:
372
+ xpath(%w[Lighting-Efficacy], part),
373
+ lighting_outlets:
374
+ xpath(%w[Lighting-Outlets], part),
375
+ }
376
+ end
377
+ end
378
+
379
+ def low_energy_lighting
380
+ total_energy_outlet_count = []
381
+ low_energy_outlet_count = []
382
+
383
+ format_fixed_light_array.each do |outlet|
384
+ if outlet[:lighting_efficacy].to_i > THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY
385
+ low_energy_outlet_count << outlet[:lighting_outlets].to_i
386
+ end
387
+ total_energy_outlet_count << outlet[:lighting_outlets].to_f
388
+ end
389
+
390
+ if total_energy_outlet_count.sum.zero?
391
+ return 0
392
+ end
393
+
394
+ (low_energy_outlet_count.sum / total_energy_outlet_count.sum * 100).round
395
+ end
396
+
397
+ def low_energy_fixed_lighting_outlets_count
398
+ low_energy_outlet_count = []
399
+
400
+ format_fixed_light_array.each do |outlet|
401
+ if outlet[:lighting_efficacy].to_i > THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY
402
+ low_energy_outlet_count << outlet[:lighting_outlets].to_i
403
+ end
404
+ end
405
+
406
+ low_energy_outlet_count.sum
407
+ end
408
+
409
+ def open_fireplaces_count
410
+ xpath(%w[Open-Chimneys-Count])&.to_i
411
+ end
412
+
413
+ def hot_water_description
414
+ xpath(%w[Hot-Water Description])
415
+ end
416
+
417
+ def hot_water_energy_efficiency_rating
418
+ xpath(%w[Hot-Water Energy-Efficiency-Rating])
419
+ end
420
+
421
+ def hot_water_environmental_efficiency_rating
422
+ xpath(%w[Hot-Water Environmental-Efficiency-Rating])
423
+ end
424
+
425
+ def window_description
426
+ xpath(%w[Windows Description])
427
+ end
428
+
429
+ def window_energy_efficiency_rating
430
+ xpath(%w[Windows Energy-Efficiency-Rating])
431
+ end
432
+
433
+ def window_environmental_efficiency_rating
434
+ xpath(%w[Windows Environmental-Efficiency-Rating])
435
+ end
436
+
437
+ def secondary_heating_description
438
+ xpath(%w[Secondary-Heating Description])
439
+ end
440
+
441
+ def secondary_heating_energy_efficiency_rating
442
+ xpath(%w[Secondary-Heating Energy-Efficiency-Rating])
443
+ end
444
+
445
+ def secondary_heating_environmental_efficiency_rating
446
+ xpath(%w[Secondary-Heating Environmental-Efficiency-Rating])
447
+ end
448
+
449
+ def lighting_description
450
+ xpath(%w[Lighting Description])
451
+ end
452
+
453
+ def lighting_energy_efficiency_rating
454
+ xpath(%w[Lighting Energy-Efficiency-Rating])
455
+ end
456
+
457
+ def lighting_environmental_efficiency_rating
458
+ xpath(%w[Lighting Environmental-Efficiency-Rating])
459
+ end
460
+
461
+ def built_form
462
+ xpath(%w[Built-Form])
463
+ end
464
+
465
+ def wind_turbine_count
466
+ @xml_doc.search("Wind-Turbines/Wind-Turbine").map(&:content).count
467
+ end
468
+
469
+ def all_main_heating_descriptions
470
+ @xml_doc.search("Main-Heating/Description").map(&:content)
471
+ end
472
+
473
+ def all_main_heating_controls_descriptions
474
+ @xml_doc.search("Main-Heating-Controls/Description").map(&:content)
475
+ end
476
+
477
+ def report_type
478
+ xpath(%w[Report-Type])
479
+ end
480
+
481
+ def all_roof_descriptions
482
+ @xml_doc.search("Roof/Description").map(&:content)
483
+ end
484
+
485
+ def all_roof_env_energy_efficiency_rating
486
+ @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content)
487
+ end
488
+
489
+ def all_roof_energy_efficiency_rating
490
+ @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content)
491
+ end
492
+
493
+ def all_wall_descriptions
494
+ @xml_doc.search("Walls/Description").map(&:content)
495
+ end
496
+
497
+ def all_wall_energy_efficiency_rating
498
+ @xml_doc.search("Walls/Energy-Efficiency-Rating").map(&:content)
499
+ end
500
+
501
+ def all_wall_env_energy_efficiency_rating
502
+ @xml_doc.search("Walls/Environmental-Efficiency-Rating").map(&:content)
503
+ end
504
+
505
+ def energy_tariff
506
+ xpath(%w[Electricity-Tariff])
507
+ end
508
+
509
+ def floor_level
510
+ xpath(%w[SAP-Flat-Details Level])
511
+ end
512
+
513
+ def all_main_heating_energy_efficiency
514
+ @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content)
515
+ end
516
+
517
+ def floor_height
518
+ @xml_doc.search("Storey-Height").map(&:content)
519
+ end
520
+
521
+ def all_floor_descriptions
522
+ @xml_doc.search("Property-Summary/Floor/Description").map(&:content)
523
+ end
524
+
525
+ def all_floor_energy_efficiency_rating
526
+ @xml_doc
527
+ .search("Property-Summary/Floor/Energy-Efficiency-Rating")
528
+ .map(&:content)
529
+ end
530
+
531
+ def all_floor_env_energy_efficiency_rating
532
+ @xml_doc
533
+ .search("Property-Summary/Floor/Environmental-Efficiency-Rating")
534
+ .map(&:content)
535
+ end
536
+
537
+ def all_main_heating_controls_energy_efficiency
538
+ @xml_doc
539
+ .search("Main-Heating-Controls/Energy-Efficiency-Rating")
540
+ .map(&:content)
541
+ end
542
+
543
+ def all_main_heating_controls_environmental_efficiency
544
+ @xml_doc
545
+ .search("Main-Heating-Controls/Environmental-Efficiency-Rating")
546
+ .map(&:content)
547
+ end
548
+
549
+ def all_main_heating_environmental_efficiency
550
+ @xml_doc
551
+ .search("Main-Heating/Environmental-Efficiency-Rating")
552
+ .map(&:content)
553
+ end
554
+
555
+ def cylinder_insul_thickness
556
+ xpath(%w[Hot-Water-Store-Insulation-Thickness])
557
+ end
558
+
559
+ def cylinder_insulation_type
560
+ xpath(%w[Hot-Water-Store-Insulation-Type])
561
+ end
562
+
563
+ def cylinder_size
564
+ xpath(%w[Hot-Water-Store-Size])
565
+ end
566
+
567
+ def has_cylinder_thermostat
568
+ xpath(%w[Has-Cylinder-Thermostat])
569
+ end
570
+
571
+ def mech_vent_sys_index_number
572
+ xpath(%w[Mechanical-Vent-System-Index-Number])&.to_i
573
+ end
574
+
575
+ def mechanical_vent_data_source
576
+ xpath(%w[Mechanical-Ventilation-Data-Source])
577
+ end
578
+
579
+ def thermal_store
580
+ xpath(%w[Thermal-Store])
581
+ end
582
+
583
+ def ventilation_type
584
+ xpath(%w[Ventilation-Type])
585
+ end
586
+
587
+ def gas_smart_meter_present
588
+ Helper::ToBool.execute(xpath(%w[Gas-Smart-Meter-Present]))
589
+ end
590
+
591
+ def electricity_smart_meter_present
592
+ Helper::ToBool.execute(xpath(%w[Electricity-Smart-Meter-Present]))
593
+ end
594
+
595
+ def date_of_completion
596
+ xpath(%w[Completion-Date])
597
+ end
598
+
599
+ def main_heating_types
600
+ @xml_doc
601
+ .search("SAP-Heating/Main-Heating-Details/Main-Heating")
602
+ .map do |_node|
603
+ {
604
+ main_heating_code: xpath(%w[Main-Heating-Code]),
605
+ main_heating_index_number: xpath(%w[Main-Heating-Index-Number]),
606
+ }
607
+ end
608
+ end
609
+
610
+ def construction_years
611
+ @xml_doc
612
+ .search("SAP-Building-Part")
613
+ .map do |node|
614
+ xpath(%w[Construction-Year], node)
615
+ end
616
+ end
617
+ end
618
+ end
619
+ end
@@ -243,6 +243,8 @@ module ViewModel
243
243
  when "3"
244
244
  return ViewModel::SapSchemaNi112::Sap.new(xml_doc)
245
245
  end
246
+ when :"SAP-Schema-S-20.0.0"
247
+ return ViewModel::SapSchemaS2000::CommonSchema.new xml_doc
246
248
  when :"SAP-Schema-S-19.0.0"
247
249
  return ViewModel::SapSchemaS1900::CommonSchema.new xml_doc
248
250
  when :"SAP-Schema-S-17.0"