epb_view_models 2.2.2 → 2.2.3

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 (30) hide show
  1. checksums.yaml +4 -4
  2. data/api/schemas/data/orchestrate.json +3 -0
  3. data/api/schemas/xml/DECAR-S-7.0/CommonFiles/CommonStructures.xsd +24 -0
  4. data/api/schemas/xml/DECAR-S-7.0/CommonFiles/Exceptions.xsd +69 -0
  5. data/api/schemas/xml/DECAR-S-7.0/Messages/LodgeReportRequest.xsd +14 -0
  6. data/api/schemas/xml/DECAR-S-7.0/Reports/BaseDataTypes.xsd +181 -0
  7. data/api/schemas/xml/DECAR-S-7.0/Reports/CEPC-Reports.xsd +66 -0
  8. data/api/schemas/xml/DECAR-S-7.0/Reports/Input-Data.xsd +307 -0
  9. data/api/schemas/xml/DECAR-S-7.0/Reports/Performance-Summary.xsd +105 -0
  10. data/api/schemas/xml/DECAR-S-7.0/Reports/Report-Header.xsd +449 -0
  11. data/api/schemas/xml/DECAR-S-7.0/Reports/Reported-Data.xsd +403 -0
  12. data/lib/epb_view_models.rb +1 -1
  13. data/lib/presenter/dec_rr/summary.rb +1 -3
  14. data/lib/view_model/cepc31/dec_rr.rb +4 -0
  15. data/lib/view_model/cepc40/dec_rr.rb +4 -0
  16. data/lib/view_model/cepc50/dec_rr.rb +4 -0
  17. data/lib/view_model/cepc51/dec_rr.rb +4 -0
  18. data/lib/view_model/cepc60/dec_rr.rb +4 -0
  19. data/lib/view_model/cepc70/dec_rr.rb +4 -0
  20. data/lib/view_model/cepc71/dec_rr.rb +4 -0
  21. data/lib/view_model/cepc800/dec_rr.rb +4 -0
  22. data/lib/view_model/cepc_ni800/dec_rr.rb +4 -0
  23. data/lib/view_model/dec_rr_wrapper.rb +2 -0
  24. data/lib/view_model/dec_summary_wrapper.rb +2 -0
  25. data/lib/view_model/dec_wrapper.rb +2 -0
  26. data/lib/view_model/decar_s_70/common_schema.rb +109 -0
  27. data/lib/view_model/decar_s_70/dec.rb +235 -0
  28. data/lib/view_model/decar_s_70/dec_rr.rb +102 -0
  29. data/lib/view_model/factory.rb +4 -1
  30. metadata +13 -1
@@ -0,0 +1,235 @@
1
+ require "date"
2
+
3
+ module ViewModel
4
+ module DecarS70
5
+ class Dec < ViewModel::DecarS70::CommonSchema
6
+ def date_of_expiry
7
+ floor_area =
8
+ xpath(%w[Display-Certificate Technical-Information Floor-Area])
9
+
10
+ expiry_date = Date.parse(current_assessment_date)
11
+
12
+ expiry_date =
13
+ if floor_area.to_i <= 1000 && !postcode.start_with?("BT")
14
+ (expiry_date - 1).next_year 10
15
+ else
16
+ (expiry_date - 1).next_year 1
17
+ end
18
+
19
+ expiry_date.strftime("%F")
20
+ end
21
+
22
+ def energy_efficiency_rating
23
+ xpath(%w[This-Assessment Energy-Rating])&.to_i
24
+ end
25
+
26
+ def current_assessment_date
27
+ xpath(%w[This-Assessment Nominated-Date])
28
+ end
29
+
30
+ def current_heating_co2
31
+ xpath(%w[This-Assessment Heating-CO2])&.to_i
32
+ end
33
+
34
+ def current_electricity_co2
35
+ xpath(%w[This-Assessment Electricity-CO2])&.to_i
36
+ end
37
+
38
+ def current_renewables_co2
39
+ xpath(%w[This-Assessment Renewables-CO2])&.to_i
40
+ end
41
+
42
+ def year1_assessment_date
43
+ xpath(%w[Year1-Assessment Nominated-Date])
44
+ end
45
+
46
+ def year1_heating_co2
47
+ xpath(%w[Year1-Assessment Heating-CO2])&.to_i
48
+ end
49
+
50
+ def year1_electricity_co2
51
+ xpath(%w[Year1-Assessment Electricity-CO2])&.to_i
52
+ end
53
+
54
+ def year1_renewables_co2
55
+ xpath(%w[Year1-Assessment Renewables-CO2])&.to_i
56
+ end
57
+
58
+ def year1_energy_efficiency_rating
59
+ xpath(%w[Year1-Assessment Energy-Rating])&.to_i
60
+ end
61
+
62
+ def year2_assessment_date
63
+ xpath(%w[Year2-Assessment Nominated-Date])
64
+ end
65
+
66
+ def year2_heating_co2
67
+ xpath(%w[Year2-Assessment Heating-CO2])&.to_i
68
+ end
69
+
70
+ def year2_electricity_co2
71
+ xpath(%w[Year2-Assessment Electricity-CO2])&.to_i
72
+ end
73
+
74
+ def year2_renewables_co2
75
+ xpath(%w[Year2-Assessment Renewables-CO2])&.to_i
76
+ end
77
+
78
+ def year2_energy_efficiency_rating
79
+ xpath(%w[Year2-Assessment Energy-Rating])&.to_i
80
+ end
81
+
82
+ def main_heating_fuel
83
+ xpath(%w[Technical-Information Main-Heating-Fuel])
84
+ end
85
+
86
+ def building_environment
87
+ xpath(%w[Technical-Information Building-Environment])
88
+ end
89
+
90
+ def floor_area
91
+ xpath(%w[Technical-Information Floor-Area])
92
+ end
93
+
94
+ def asset_rating
95
+ xpath(%w[OR-Previous-Data Asset-Rating])&.to_i
96
+ end
97
+
98
+ def annual_energy_use_fuel_thermal
99
+ xpath(%w[Annual-Energy-Use-Fuel-Thermal])
100
+ end
101
+
102
+ def annual_energy_use_electrical
103
+ xpath(%w[DEC-Annual-Energy-Summary Annual-Energy-Use-Electrical])
104
+ end
105
+
106
+ def typical_thermal_use
107
+ xpath(%w[DEC-Annual-Energy-Summary Typical-Thermal-Use])
108
+ end
109
+
110
+ def typical_electrical_use
111
+ xpath(%w[DEC-Annual-Energy-Summary Typical-Electrical-Use])
112
+ end
113
+
114
+ def renewables_fuel_thermal
115
+ xpath(%w[DEC-Annual-Energy-Summary Renewables-Fuel-Thermal])
116
+ end
117
+
118
+ def renewables_electrical
119
+ xpath(%w[DEC-Annual-Energy-Summary Renewables-Electrical])
120
+ end
121
+
122
+ def dec_status
123
+ xpath(%w[DEC-Status])
124
+ end
125
+
126
+ def dec_related_party_disclosure
127
+ xpath(%w[DEC-Related-Party-Disclosure])
128
+ end
129
+
130
+ def calculation_tool
131
+ xpath(%w[Calculation-Details Calculation-Tool])
132
+ end
133
+
134
+ def related_rrn
135
+ xpath(%w[Related-RRN])
136
+ end
137
+
138
+ def output_engine
139
+ xpath(%w[Output-Engine])
140
+ end
141
+
142
+ def or_assessment_start_date
143
+ xpath(%w[OR-Operational-Rating OR-Assessment-Start-Date])
144
+ end
145
+
146
+ def occupier
147
+ xpath(%w[Occupier])
148
+ end
149
+
150
+ def benchmarks
151
+ @xml_doc
152
+ .search("Benchmarks/Benchmark")
153
+ .map do |node|
154
+ {
155
+ name: xpath(%w[Name], node),
156
+ id: xpath(%w[Benchmark-ID], node)&.to_i,
157
+ tufa: xpath(%w[TUFA], node),
158
+ }
159
+ end
160
+ end
161
+
162
+ def or_energy_consumption
163
+ @xml_doc
164
+ .search("OR-Energy-Consumption")
165
+ .children
166
+ .select(&:element?)
167
+ .map do |node|
168
+ {
169
+ consumption: xpath(%w[Consumption], node),
170
+ start_date: xpath(%w[Start-Date], node),
171
+ end_date: xpath(%w[End-Date], node),
172
+ estimate: xpath(%w[Estimate], node)&.to_i,
173
+ name: node.name,
174
+ }
175
+ end
176
+ end
177
+
178
+ def annual_energy_summary
179
+ summary = @xml_doc.search("DEC-Annual-Energy-Summary")
180
+ {
181
+ electrical: xpath(%w[Annual-Energy-Use-Electrical], summary),
182
+ fuel_thermal: xpath(%w[Annual-Energy-Use-Fuel-Thermal], summary),
183
+ renewables_fuel_thermal: xpath(%w[Renewables-Fuel-Thermal], summary),
184
+ renewables_electrical: xpath(%w[Renewables-Electrical], summary),
185
+ typical_thermal_use: xpath(%w[Typical-Thermal-Use], summary),
186
+ typical_electrical_use: xpath(%w[Typical-Electrical-Use], summary),
187
+ }
188
+ end
189
+
190
+ def property_type
191
+ xpath(%w[Property-Type])
192
+ end
193
+
194
+ def main_benchmark
195
+ xpath(%w[OR-Benchmark-Data Main-Benchmark])
196
+ end
197
+
198
+ def other_fuel
199
+ xpath(%w[Technical-Information Other-Fuel-Description])
200
+ end
201
+
202
+ def special_energy_uses
203
+ xpath(%w[Technical-Information Special-Energy-Uses])
204
+ end
205
+
206
+ def occupancy_level
207
+ xpath(%w[Benchmarks Benchmark Occupancy-Level])
208
+ end
209
+
210
+ def ac_inspection_commissioned
211
+ xpath(%w[AC-Inspection-Commissioned])
212
+ end
213
+
214
+ def ac_present
215
+ xpath(%w[AC-Present])
216
+ end
217
+
218
+ def ac_kw_rating
219
+ xpath(%w[AC-kW-Rating])&.to_i
220
+ end
221
+
222
+ def estimated_ac_kw_rating
223
+ xpath(%w[AC-Estimated-Output])&.to_i
224
+ end
225
+
226
+ def building_category
227
+ xpath(%w[Building-Category])
228
+ end
229
+
230
+ def renewable_sources
231
+ xpath(%w[Renewable-Sources])
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,102 @@
1
+ require "date"
2
+
3
+ module ViewModel
4
+ module DecarS70
5
+ class DecRr < ViewModel::DecarS70::CommonSchema
6
+ def type_of_assessment
7
+ "DEC-AR"
8
+ end
9
+
10
+ def date_of_expiry
11
+ floor_area = xpath(%w[Advisory-Report Technical-Information Floor-Area])
12
+
13
+ expiry_date = Date.parse(date_of_issue)
14
+
15
+ expiry_date =
16
+ if floor_area.to_f <= 1000 && !postcode.start_with?("BT")
17
+ (expiry_date - 1).next_year 10
18
+ else
19
+ (expiry_date - 1).next_year 7
20
+ end
21
+
22
+ expiry_date.strftime("%F")
23
+ end
24
+
25
+ def recommendations(payback)
26
+ @xml_doc
27
+ .search("AR-Recommendations/#{payback}")
28
+ .map do |node|
29
+ {
30
+ code: node.at("Recommendation-Code").content,
31
+ text: node.at("Recommendation").content,
32
+ cO2Impact: node.at("CO2-Impact").content,
33
+ }
34
+ end
35
+ end
36
+
37
+ def site_services(service)
38
+ {
39
+ description:
40
+ @xml_doc.at("Site-Services/#{service}/Description").content,
41
+ quantity: @xml_doc.at("Site-Services/#{service}/Quantity").content,
42
+ }
43
+ end
44
+
45
+ def site_service_one
46
+ site_services("Service-1")
47
+ end
48
+
49
+ def site_service_two
50
+ site_services("Service-2")
51
+ end
52
+
53
+ def site_service_three
54
+ site_services("Service-3")
55
+ end
56
+
57
+ def short_payback_recommendations
58
+ recommendations("Short-Payback")
59
+ end
60
+
61
+ def medium_payback_recommendations
62
+ recommendations("Medium-Payback")
63
+ end
64
+
65
+ def long_payback_recommendations
66
+ recommendations("Long-Payback")
67
+ end
68
+
69
+ def other_recommendations
70
+ recommendations("Other-Payback")
71
+ end
72
+
73
+ def floor_area
74
+ xpath(%w[Advisory-Report Technical-Information Floor-Area])
75
+ end
76
+
77
+ def building_environment
78
+ xpath(%w[Advisory-Report Technical-Information Building-Environment])
79
+ end
80
+
81
+ def related_rrn
82
+ xpath(%w[Related-RRN])
83
+ end
84
+
85
+ def occupier
86
+ xpath(%w[Occupier])
87
+ end
88
+
89
+ def property_type
90
+ xpath(%w[Property-Type])
91
+ end
92
+
93
+ def renewable_sources
94
+ xpath(%w[Renewable-Sources])
95
+ end
96
+
97
+ def discounted_energy
98
+ xpath(%w[Special-Energy-Uses])
99
+ end
100
+ end
101
+ end
102
+ end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module ViewModel
4
4
  class Factory
5
+ TYPES_OF_DECAR = %i[
6
+ DECAR-S-7.0
7
+ ].freeze
5
8
  TYPES_OF_CS63 = %i[
6
9
  CS63-S-7.0
7
10
  ].freeze
@@ -77,7 +80,7 @@ module ViewModel
77
80
 
78
81
  xml_doc = Nokogiri.XML(xml, nil, nil, Nokogiri::XML::ParseOptions.new.huge.strict).remove_namespaces!
79
82
 
80
- if TYPES_OF_CEPC.include?(schema_type)
83
+ if TYPES_OF_CEPC.include?(schema_type) || TYPES_OF_DECAR.include?(schema_type)
81
84
  filtered_results =
82
85
  if filter_results_for
83
86
  xml_doc.at("//*[RRN=\"#{filter_results_for}\"]/ancestor::Report")
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.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MHCLG Energy Performance of Buildings
@@ -171,6 +171,15 @@ files:
171
171
  - api/schemas/xml/CEPC-S-7.1/Reports/Reported-Data.xsd
172
172
  - api/schemas/xml/CEPC-S-7.1/Reports/UserManagement.xsd
173
173
  - api/schemas/xml/CS63-S-7.0/ActionPlan.xsd
174
+ - api/schemas/xml/DECAR-S-7.0/CommonFiles/CommonStructures.xsd
175
+ - api/schemas/xml/DECAR-S-7.0/CommonFiles/Exceptions.xsd
176
+ - api/schemas/xml/DECAR-S-7.0/Messages/LodgeReportRequest.xsd
177
+ - api/schemas/xml/DECAR-S-7.0/Reports/BaseDataTypes.xsd
178
+ - api/schemas/xml/DECAR-S-7.0/Reports/CEPC-Reports.xsd
179
+ - api/schemas/xml/DECAR-S-7.0/Reports/Input-Data.xsd
180
+ - api/schemas/xml/DECAR-S-7.0/Reports/Performance-Summary.xsd
181
+ - api/schemas/xml/DECAR-S-7.0/Reports/Report-Header.xsd
182
+ - api/schemas/xml/DECAR-S-7.0/Reports/Reported-Data.xsd
174
183
  - api/schemas/xml/RdSAP-Schema-17.0/RdSAP/ExternalDefinitions.xml
175
184
  - api/schemas/xml/RdSAP-Schema-17.0/RdSAP/ExternalDefinitions.xsd
176
185
  - api/schemas/xml/RdSAP-Schema-17.0/RdSAP/Templates/AssessorManagement.xsd
@@ -1676,6 +1685,9 @@ files:
1676
1685
  - lib/view_model/dec_rr_wrapper.rb
1677
1686
  - lib/view_model/dec_summary_wrapper.rb
1678
1687
  - lib/view_model/dec_wrapper.rb
1688
+ - lib/view_model/decar_s_70/common_schema.rb
1689
+ - lib/view_model/decar_s_70/dec.rb
1690
+ - lib/view_model/decar_s_70/dec_rr.rb
1679
1691
  - lib/view_model/domestic_epc_view_model.rb
1680
1692
  - lib/view_model/factory.rb
1681
1693
  - lib/view_model/rd_sap_schema_170/common_schema.rb