epb_view_models 2.0.5 → 2.0.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 070de28c2ff5b0887b065ab4c1223f094be93db67b1a5524c6602071606484d8
|
4
|
+
data.tar.gz: 9eb22208a968d88510302ebda40511bf289bed66205d889753cceca4524f409f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1c78fb53e73d2ef0b1544df616d043107595683b80b0f4e378f931d9d7e06e8d03a7bdd1f4fb82e3ef7f923b0ae11f41c94e318a5b516705b7696114c0bee88
|
7
|
+
data.tar.gz: b12893871ed115e1d2d91338fd1560aa031b5eab62edf276accefc2f082d588ffbfbd1621e57c63349a95e17f9c9be8ae7c4e3f82f5d568f41a05a5402350da6
|
data/lib/epb_view_models.rb
CHANGED
@@ -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.
|
4
|
+
version: 2.0.6
|
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-
|
11
|
+
date: 2025-01-27 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
|