epb_view_models 2.0.5 → 2.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e37a534e069f0cce99aa4c94a5e819e4c95cae08ab7bac23a3d9e275d70f4ae
4
- data.tar.gz: b0caa2877b0671963f6161c235a99011239d341de4819d27a78631cab6e7df40
3
+ metadata.gz: a81a3fdfa0d58d6c1999f068864f725d52f9284b34d13a81368b9dd5115923ae
4
+ data.tar.gz: 694ef9eb066de7b122a8c6882c3158b6c52d8f5ff50c7340444f8093476274a7
5
5
  SHA512:
6
- metadata.gz: aecff0311df24627d53c49edab0de44c2dbafec75f54282da82a1a21a73a0f630c06971a28fde0924b890bf4420a0dd0028aad1963734b5cd9fc4b2dd6969dcd
7
- data.tar.gz: 1756934eace6db26256901e75241744a1d106f3c5e3604fb9e65e64e13e5b9a83485bfa493b40ed633f1418fd7fbf598cd2a622e6d4739cd906b7393bf679443
6
+ metadata.gz: 5f384273ae4020a1a375180e4aea5fa687802f59e72cca8305f00526bd620337337f46554a20e42cd85a8faf46e7d615f3977b6e2a76399c2a64552671dc6f4f
7
+ data.tar.gz: 8c81bad8d0aee88f4e58d5abe35970ab5b7c46c98ac2c4f2e2b6dbe615c864d94165703467c9dbd4983327f45631d84ad72429f68a45fac18a0a23c6cd591c3b
@@ -5,7 +5,7 @@ loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "2.0.5"
8
+ VERSION = "2.0.7"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -0,0 +1,100 @@
1
+ module Presenter
2
+ module RdSap
3
+ class CertificateSummary
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_certificate_summary
12
+ estimated_energy_cost =
13
+ Helper::EstimatedCostPotentialSavingHelper.new.estimated_cost(
14
+ @view_model.heating_cost_current,
15
+ @view_model.hot_water_cost_current,
16
+ @view_model.lighting_cost_current,
17
+ )
18
+ {
19
+ type_of_assessment: TYPE_OF_ASSESSMENT,
20
+ assessment_id: @view_model.assessment_id,
21
+ date_of_expiry: @view_model.date_of_expiry,
22
+ date_of_assessment: @view_model.date_of_assessment,
23
+ date_of_registration: @view_model.date_of_registration,
24
+ address: {
25
+ address_line1: @view_model.address_line1,
26
+ address_line2: @view_model.address_line2,
27
+ address_line3: @view_model.address_line3,
28
+ address_line4: nil,
29
+ town: @view_model.town,
30
+ postcode: @view_model.postcode,
31
+ },
32
+ assessor: {
33
+ scheme_assessor_id: @view_model.scheme_assessor_id,
34
+ name: @view_model.assessor_name,
35
+ contact_details: {
36
+ email: @view_model.assessor_email,
37
+ telephone: @view_model.assessor_telephone,
38
+ },
39
+ },
40
+ current_carbon_emission:
41
+ convert_to_big_decimal(@view_model.current_carbon_emission),
42
+ current_energy_efficiency_band: Helper::EnergyBandCalculator.domestic(@view_model.current_energy_rating),
43
+ current_energy_efficiency_rating: @view_model.current_energy_rating,
44
+ dwelling_type: @view_model.dwelling_type,
45
+ estimated_energy_cost:,
46
+ heat_demand: {
47
+ current_space_heating_demand:
48
+ @view_model.current_space_heating_demand&.to_i,
49
+ current_water_heating_demand:
50
+ @view_model.current_water_heating_demand&.to_i
51
+ },
52
+ heating_cost_current: @view_model.heating_cost_current,
53
+ heating_cost_potential: @view_model.heating_cost_potential,
54
+ hot_water_cost_current: @view_model.hot_water_cost_current,
55
+ hot_water_cost_potential: @view_model.hot_water_cost_potential,
56
+ lighting_cost_current: @view_model.lighting_cost_current,
57
+ lighting_cost_potential: @view_model.lighting_cost_potential,
58
+ potential_carbon_emission:
59
+ convert_to_big_decimal(@view_model.potential_carbon_emission),
60
+ potential_energy_efficiency_band: Helper::EnergyBandCalculator.domestic(@view_model.potential_energy_rating),
61
+ potential_energy_efficiency_rating: @view_model.potential_energy_rating,
62
+ potential_energy_saving:
63
+ Helper::EstimatedCostPotentialSavingHelper.new.potential_saving(
64
+ @view_model.heating_cost_potential,
65
+ @view_model.hot_water_cost_potential,
66
+ @view_model.lighting_cost_potential,
67
+ estimated_energy_cost,
68
+ ),
69
+ property_summary: @view_model.property_summary,
70
+ recommended_improvements:
71
+ @view_model.improvements.map do |improvement|
72
+ improvement[:energy_performance_band_improvement] =
73
+ Helper::EnergyBandCalculator.domestic(improvement[:energy_performance_rating_improvement])
74
+ improvement
75
+ end,
76
+ lzc_energy_sources: @view_model.lzc_energy_sources,
77
+ related_party_disclosure_number: @view_model.respond_to?(:related_party_disclosure_number) ? @view_model.related_party_disclosure_number : nil,
78
+ related_party_disclosure_text:
79
+ @view_model.related_party_disclosure_text,
80
+ total_floor_area: convert_to_big_decimal(@view_model.total_floor_area),
81
+ status: @view_model.status,
82
+ co2_emissions_current_per_floor_area:
83
+ @view_model.co2_emissions_current_per_floor_area,
84
+ addendum: @view_model.addendum,
85
+ gas_smart_meter_present: @view_model.respond_to?(:gas_smart_meter_present) ? @view_model.gas_smart_meter_present : nil,
86
+ electricity_smart_meter_present: @view_model.respond_to?(:electricity_smart_meter_present) ? @view_model.electricity_smart_meter_present : nil,
87
+ country_code: @view_model.country_code,
88
+ }
89
+ end
90
+
91
+ private
92
+
93
+ def convert_to_big_decimal(node)
94
+ return "" unless node
95
+
96
+ BigDecimal(node, 0)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,97 @@
1
+ module Presenter
2
+ module Sap
3
+ class CertificateSummary
4
+ def initialize(view_model)
5
+ @view_model = view_model
6
+ end
7
+
8
+ def to_certificate_summary
9
+ estimated_energy_cost =
10
+ Helper::EstimatedCostPotentialSavingHelper.new.estimated_cost(
11
+ @view_model.heating_cost_current,
12
+ @view_model.hot_water_cost_current,
13
+ @view_model.lighting_cost_current,
14
+ )
15
+ {
16
+ type_of_assessment: @view_model.type_of_assessment,
17
+ assessment_id: @view_model.assessment_id,
18
+ date_of_expiry: @view_model.date_of_expiry,
19
+ date_of_assessment: @view_model.date_of_assessment,
20
+ date_of_registration: @view_model.date_of_registration,
21
+ address: {
22
+ address_line1: @view_model.address_line1,
23
+ address_line2: @view_model.address_line2,
24
+ address_line3: @view_model.address_line3,
25
+ address_line4: nil,
26
+ town: @view_model.town,
27
+ postcode: @view_model.postcode,
28
+ },
29
+ assessor: {
30
+ scheme_assessor_id: @view_model.scheme_assessor_id,
31
+ name: @view_model.assessor_name,
32
+ contact_details: {
33
+ email: @view_model.assessor_email,
34
+ telephone: @view_model.assessor_telephone,
35
+ },
36
+ },
37
+ current_carbon_emission:
38
+ convert_to_big_decimal(@view_model.current_carbon_emission),
39
+ current_energy_efficiency_band: Helper::EnergyBandCalculator.domestic(@view_model.current_energy_rating),
40
+ current_energy_efficiency_rating: @view_model.current_energy_rating,
41
+ dwelling_type: @view_model.dwelling_type,
42
+ estimated_energy_cost:,
43
+ heat_demand: {
44
+ current_space_heating_demand:
45
+ @view_model.current_space_heating_demand&.to_i,
46
+ current_water_heating_demand:
47
+ @view_model.current_water_heating_demand&.to_i
48
+ },
49
+ heating_cost_current: @view_model.heating_cost_current,
50
+ heating_cost_potential: @view_model.heating_cost_potential,
51
+ hot_water_cost_current: @view_model.hot_water_cost_current,
52
+ hot_water_cost_potential: @view_model.hot_water_cost_potential,
53
+ lighting_cost_current: @view_model.lighting_cost_current,
54
+ lighting_cost_potential: @view_model.lighting_cost_potential,
55
+ potential_carbon_emission:
56
+ convert_to_big_decimal(@view_model.potential_carbon_emission),
57
+ potential_energy_efficiency_band: Helper::EnergyBandCalculator.domestic(@view_model.potential_energy_rating),
58
+ potential_energy_efficiency_rating: @view_model.potential_energy_rating,
59
+ potential_energy_saving:
60
+ Helper::EstimatedCostPotentialSavingHelper.new.potential_saving(
61
+ @view_model.heating_cost_potential,
62
+ @view_model.hot_water_cost_potential,
63
+ @view_model.lighting_cost_potential,
64
+ estimated_energy_cost,
65
+ ),
66
+ property_summary: @view_model.property_summary,
67
+ recommended_improvements:
68
+ @view_model.improvements.map do |improvement|
69
+ improvement[:energy_performance_band_improvement] =
70
+ Helper::EnergyBandCalculator.domestic(improvement[:energy_performance_rating_improvement])
71
+ improvement
72
+ end,
73
+ lzc_energy_sources: @view_model.lzc_energy_sources,
74
+ related_party_disclosure_number: @view_model.respond_to?(:related_party_disclosure_number) ? @view_model.related_party_disclosure_number : nil,
75
+ related_party_disclosure_text:
76
+ @view_model.related_party_disclosure_text,
77
+ total_floor_area: convert_to_big_decimal(@view_model.total_floor_area),
78
+ status: @view_model.status,
79
+ co2_emissions_current_per_floor_area:
80
+ @view_model.co2_emissions_current_per_floor_area,
81
+ addendum: @view_model.addendum,
82
+ gas_smart_meter_present: @view_model.respond_to?(:gas_smart_meter_present) ? @view_model.gas_smart_meter_present : nil,
83
+ electricity_smart_meter_present: @view_model.respond_to?(:electricity_smart_meter_present) ? @view_model.electricity_smart_meter_present : nil,
84
+ country_code: @view_model.country_code,
85
+ }
86
+ end
87
+
88
+ private
89
+
90
+ def convert_to_big_decimal(node)
91
+ return "" unless node
92
+
93
+ BigDecimal(node, 0)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -6,6 +6,7 @@ module ViewModel
6
6
  @schema_type = schema_type
7
7
  @view_model = build_view_model(xml_doc, schema_type)
8
8
  @summary = Presenter::RdSap::Summary.new(view_model)
9
+ @certificate_summary = Presenter::RdSap::CertificateSummary.new(view_model)
9
10
  @report = Presenter::RdSap::Report.new(view_model, schema_type, additional_data)
10
11
  @recommendation_report = Presenter::RdSap::RecommendationReport.new(view_model)
11
12
  @domestic_digest = Presenter::RdSap::DomesticDigest.new(view_model, schema_type)
@@ -19,6 +20,10 @@ module ViewModel
19
20
  @summary.to_hash
20
21
  end
21
22
 
23
+ def to_certificate_summary
24
+ @certificate_summary.to_certificate_summary
25
+ end
26
+
22
27
  def to_hash_ni
23
28
  @report.to_hash_ni
24
29
  end
@@ -6,6 +6,7 @@ module ViewModel
6
6
  @schema_type = schema_type
7
7
  @view_model = build_view_model(xml_doc, schema_type, report_type)
8
8
  @summary = Presenter::Sap::Summary.new(view_model)
9
+ @certificate_summary = Presenter::Sap::CertificateSummary.new(view_model)
9
10
  @report = Presenter::Sap::Report.new(view_model, schema_type, additional_data)
10
11
  @recommendation_report = Presenter::Sap::RecommendationReport.new(view_model)
11
12
  @domestic_digest = Presenter::Sap::DomesticDigest.new(view_model, schema_type)
@@ -19,6 +20,10 @@ module ViewModel
19
20
  @summary.to_hash
20
21
  end
21
22
 
23
+ def to_certificate_summary
24
+ @certificate_summary.to_certificate_summary
25
+ end
26
+
22
27
  def to_hash_ni
23
28
  @report.to_hash_ni
24
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epb_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - DLUHC Energy Performance of Buildings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-13 00:00:00.000000000 Z
11
+ date: 2025-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -1697,12 +1697,14 @@ files:
1697
1697
  - lib/presenter/export/commercial.rb
1698
1698
  - lib/presenter/export/domestic.rb
1699
1699
  - lib/presenter/export/statistics.rb
1700
+ - lib/presenter/rd_sap/certificate_summary.rb
1700
1701
  - lib/presenter/rd_sap/domestic_digest.rb
1701
1702
  - lib/presenter/rd_sap/export_configuration.rb
1702
1703
  - lib/presenter/rd_sap/recommendation_report.rb
1703
1704
  - lib/presenter/rd_sap/report.rb
1704
1705
  - lib/presenter/rd_sap/summary.rb
1705
1706
  - lib/presenter/sap/certificate_details.rb
1707
+ - lib/presenter/sap/certificate_summary.rb
1706
1708
  - lib/presenter/sap/domestic_digest.rb
1707
1709
  - lib/presenter/sap/export_configuration.rb
1708
1710
  - lib/presenter/sap/recommendation_report.rb