epb_view_models 1.0.14 → 1.0.17

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +10 -10
  4. data/Gemfile.lock +32 -39
  5. data/api/schemas/data/orchestrate.json +4 -0
  6. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/ExternalDefinitions.xml +1352 -0
  7. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/ExternalDefinitions.xsd +236 -0
  8. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/AssessorManagement.xsd +207 -0
  9. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/EPC-Certificate.xsd +476 -0
  10. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/ExceptionList.xsd +18 -0
  11. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/Property.xsd +71 -0
  12. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/ReportList.xsd +25 -0
  13. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/SAP-CollectedData.xsd +1793 -0
  14. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/SAP-Compliance-Report.xsd +36 -0
  15. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/Templates/SAP-Report.xsd +204 -0
  16. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/UDT/EPC-Domains.xsd +558 -0
  17. data/api/schemas/xml/SAP-Schema-19.0.0/SAP/UDT/SAP-Domains.xsd +3127 -0
  18. data/lib/epb_view_models.rb +1 -1
  19. data/lib/presenter/ac_cert/export_configuration.rb +7 -0
  20. data/lib/presenter/ac_report/export_configuration.rb +7 -0
  21. data/lib/presenter/cepc/export_configuration.rb +7 -0
  22. data/lib/presenter/cepc_rr/export_configuration.rb +7 -0
  23. data/lib/presenter/dec/export_configuration.rb +7 -0
  24. data/lib/presenter/dec_rr/export_configuration.rb +7 -0
  25. data/lib/presenter/export/statistics.rb +3 -14
  26. data/lib/presenter/rd_sap/export_configuration.rb +57 -1
  27. data/lib/presenter/rd_sap/hera.rb +35 -0
  28. data/lib/presenter/sap/export_configuration.rb +7 -0
  29. data/lib/presenter/sap/hera.rb +32 -0
  30. data/lib/presenter/xml/parser.rb +6 -0
  31. data/lib/view_model/domestic_epc_view_model.rb +10 -0
  32. data/lib/view_model/factory.rb +1 -0
  33. data/lib/view_model/rd_sap_schema_200/common_schema.rb +0 -4
  34. data/lib/view_model/rd_sap_schema_ni_200/common_schema.rb +0 -4
  35. data/lib/view_model/rd_sap_wrapper.rb +5 -0
  36. data/lib/view_model/sap_schema_1800/common_schema.rb +0 -4
  37. data/lib/view_model/sap_schema_1900/common_schema.rb +583 -0
  38. data/lib/view_model/sap_schema_ni_1800/common_schema.rb +0 -4
  39. data/lib/view_model/sap_wrapper.rb +7 -0
  40. metadata +24 -2
@@ -5,7 +5,7 @@ loader = Zeitwerk::Loader.for_gem
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "1.0.14"
8
+ VERSION = "1.0.17"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ module AcCert
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ # configuration goes here
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ module AcReport
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ # configuration goes here
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ module Cepc
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ # configuration goes here
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ module CepcRr
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ # configuration goes here
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ module Dec
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ # configuration goes here
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ module DecRr
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ # configuration goes here
5
+ end
6
+ end
7
+ end
@@ -7,23 +7,12 @@ module Presenter::Export
7
7
 
8
8
  def build
9
9
  {
10
- current_energy_rating: current_energy_rating,
11
10
  transaction_type: @view_model.transaction_type,
12
11
  }
13
12
  rescue NoMethodError
14
- nil
15
- end
16
-
17
- private
18
-
19
- def current_energy_rating
20
- view_model_type = @view_model.class.to_s.split("::")[1].downcase
21
-
22
- if view_model_type.include?("sapschema")
23
- @view_model.current_energy_rating
24
- elsif view_model_type.include?("cepc")
25
- @view_model.energy_efficiency_rating
26
- end
13
+ {
14
+ transaction_type: 0,
15
+ }
27
16
  end
28
17
  end
29
18
  end
@@ -1 +1,57 @@
1
-
1
+ module Presenter
2
+ module RdSap
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ excludes %w[
5
+ ExternalDefinitions-Revision-Number
6
+ User-Interface-Name
7
+ User-Interface-Version
8
+ PCDF-Revision-Number
9
+ Related-Party-Disclosure
10
+ Insurance-Details
11
+ Previous-EPC-Check
12
+ Green-Deal-Package
13
+ Energy-Assessor
14
+ Green-Deal-Category
15
+ RRN
16
+ ]
17
+ includes %w[
18
+ Certificate-Number
19
+ ]
20
+ bases %w[
21
+ Report-Header
22
+ Energy-Assessment
23
+ Property-Summary
24
+ Energy-Use
25
+ SAP-Data
26
+ SAP-Property-Details
27
+ Identification-Number
28
+ Property
29
+ Address
30
+ ]
31
+ preferred_keys({
32
+ "Certificate-Number" => "scheme_assessor_id",
33
+ })
34
+ list_nodes %w[
35
+ SAP-Floor-Dimensions
36
+ LZC-Energy-Source
37
+ ImprovementTexts
38
+ SAP-Building-Parts
39
+ SAP-Windows
40
+ SAP-Deselected-Improvements
41
+ Main-Heating-Details
42
+ Storage-Heaters
43
+ SAP-Special-Features
44
+ Air-Change-Rates
45
+ PV-Arrays
46
+ ]
47
+ rootless_list_nodes({
48
+ "Wall" => "walls",
49
+ "Roof" => "roofs",
50
+ "Floor" => { parents: %w[Property-Summary], key: "floors" },
51
+ "Main-Heating" => { parents: %w[Property-Summary], key: "main-heating" },
52
+ "Main-Heating-Controls" => "main_heating_controls",
53
+ "Addendum-Number" => "addendum_numbers",
54
+ })
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,35 @@
1
+ module Presenter
2
+ module RdSap
3
+ class Hera
4
+ TYPE_OF_ASSESSMENT = "RdSAP".freeze
5
+ private_constant :TYPE_OF_ASSESSMENT
6
+
7
+ def initialize(view_model)
8
+ @view_model = view_model
9
+ end
10
+
11
+ def to_hera_hash
12
+ {
13
+ type_of_assessment: TYPE_OF_ASSESSMENT,
14
+ assessment_id: @view_model.assessment_id,
15
+ date_of_registration: @view_model.date_of_registration,
16
+ address: {
17
+ address_line1: @view_model.address_line1,
18
+ address_line2: @view_model.address_line2,
19
+ address_line3: @view_model.address_line3,
20
+ address_line4: @view_model.address_line4,
21
+ town: @view_model.town,
22
+ postcode: @view_model.postcode,
23
+ },
24
+ dwelling_type: @view_model.dwelling_type,
25
+ built_form: @view_model.built_form,
26
+ main_dwelling_construction_age_band_or_year: @view_model.main_dwelling_construction_age_band_or_year,
27
+ property_summary: @view_model.property_summary,
28
+ main_heating_category: @view_model.main_heating_category,
29
+ main_fuel_type: @view_model.main_fuel_type,
30
+ has_hot_water_cylinder: @view_model.has_hot_water_cylinder,
31
+ }
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ module Sap
3
+ class ExportConfiguration < Presenter::ToWarehouse::BaseConfiguration
4
+ # configuration goes here
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ module Presenter
2
+ module Sap
3
+ class Hera
4
+ def initialize(view_model)
5
+ @view_model = view_model
6
+ end
7
+
8
+ def to_hera_hash
9
+ {
10
+ type_of_assessment: @view_model.type_of_assessment,
11
+ assessment_id: @view_model.assessment_id,
12
+ date_of_registration: @view_model.date_of_registration,
13
+ address: {
14
+ address_line1: @view_model.address_line1,
15
+ address_line2: @view_model.address_line2,
16
+ address_line3: @view_model.address_line3,
17
+ address_line4: nil,
18
+ town: @view_model.town,
19
+ postcode: @view_model.postcode,
20
+ },
21
+ dwelling_type: @view_model.dwelling_type,
22
+ built_form: @view_model.built_form,
23
+ main_dwelling_construction_age_band_or_year: @view_model.main_dwelling_construction_age_band_or_year,
24
+ property_summary: @view_model.property_summary,
25
+ main_heating_category: @view_model.main_heating_category,
26
+ main_fuel_type: @view_model.main_fuel_type,
27
+ has_hot_water_cylinder: @view_model.has_hot_water_cylinder,
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -124,6 +124,7 @@ module Presenter
124
124
  def set_value_with_keys(value, keys)
125
125
  prepare_hash keys
126
126
  *key, last = keys
127
+
127
128
  key.inject(@output, :fetch)[last] = value
128
129
  end
129
130
 
@@ -151,7 +152,12 @@ module Presenter
151
152
  false
152
153
  end
153
154
 
155
+ def is_bool?(string)
156
+ string == true || string == false || string =~ (/(true|false)$/i) ? true : false
157
+ end
158
+
154
159
  def try_as_number(string)
160
+ return string if is_bool?(string)
155
161
  return string unless is_numeric?(string)
156
162
 
157
163
  if string.include?(".")
@@ -54,6 +54,16 @@ module ViewModel
54
54
  xpath(%w[Water-Heating-Code])
55
55
  end
56
56
 
57
+ def has_hot_water_cylinder
58
+ return "false" if xpath(%w[Has-Hot-Water-Cylinder]).nil?
59
+
60
+ xpath(%w[Has-Hot-Water-Cylinder])
61
+ end
62
+
63
+ def main_heating_category
64
+ xpath(%w[Main-Heating-Category])
65
+ end
66
+
57
67
  private
58
68
 
59
69
  def fetch_addendum_numbers
@@ -26,6 +26,7 @@ module ViewModel
26
26
  RdSAP-Schema-NI-17.3
27
27
  ].freeze
28
28
  TYPES_OF_SAP = %i[
29
+ SAP-Schema-19.0.0
29
30
  SAP-Schema-18.0.0
30
31
  SAP-Schema-17.1
31
32
  SAP-Schema-17.0
@@ -350,10 +350,6 @@ module ViewModel
350
350
  xpath(%w[Immersion-Heating-Type])
351
351
  end
352
352
 
353
- def main_heating_category
354
- xpath(%w[Main-Heating-Category])
355
- end
356
-
357
353
  def main_fuel_type
358
354
  xpath(%w[Main-Fuel-Type])
359
355
  end
@@ -337,10 +337,6 @@ module ViewModel
337
337
  xpath(%w[Immersion-Heating-Type])
338
338
  end
339
339
 
340
- def main_heating_category
341
- xpath(%w[Main-Heating-Category])
342
- end
343
-
344
340
  def main_fuel_type
345
341
  xpath(%w[Main-Fuel-Type])
346
342
  end
@@ -8,6 +8,7 @@ module ViewModel
8
8
  @summary = Presenter::RdSap::Summary.new(view_model)
9
9
  @report = Presenter::RdSap::Report.new(view_model, schema_type, additional_data)
10
10
  @recommendation_report = Presenter::RdSap::RecommendationReport.new(view_model)
11
+ @hera = Presenter::RdSap::Hera.new(view_model)
11
12
  end
12
13
 
13
14
  def type
@@ -30,6 +31,10 @@ module ViewModel
30
31
  @recommendation_report.to_hash
31
32
  end
32
33
 
34
+ def to_hera_hash
35
+ @hera.to_hera_hash
36
+ end
37
+
33
38
  def get_view_model
34
39
  view_model
35
40
  end
@@ -301,10 +301,6 @@ module ViewModel
301
301
  xpath(%w[Immersion-Heating-Type])
302
302
  end
303
303
 
304
- def main_heating_category
305
- xpath(%w[Main-Heating-Category])
306
- end
307
-
308
304
  def main_fuel_type
309
305
  xpath(%w[Main-Fuel-Type])
310
306
  end