generated from BCDevOps/opendev-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstep_code_checklist.rb
More file actions
84 lines (77 loc) · 2.8 KB
/
step_code_checklist.rb
File metadata and controls
84 lines (77 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class StepCodeChecklist < ApplicationRecord
belongs_to :step_code, optional: Rails.env.test?
belongs_to :step_requirement,
class_name: "PermitTypeRequiredStep",
optional: true
has_one :building_characteristics_summary,
class_name: "StepCodeBuildingCharacteristicsSummary",
dependent: :destroy
accepts_nested_attributes_for :building_characteristics_summary
after_create :create_building_characteristics_summary
delegate :data_entries,
:building_permit_number,
:jurisdiction_name,
:full_address,
:pid,
to: :step_code
delegate :plan_author, :plan_version, :plan_date, to: :step_code
enum stage: %i[pre_construction mid_construction as_built]
enum status: %i[draft complete]
enum compliance_path: %i[step_code_ers step_code_necb passive_house step_code]
enum epc_calculation_airtightness: %i[two_point_five three_point_two]
enum epc_calculation_testing_target_type: %i[ach nlr nla]
enum building_type: %i[
laneway
single_detached
double_detached
row
multi_plex
single_detached_with_suite
low_rise_murb
stacked_duplex
triplex
retail
other
]
def self.select_options
{
compliance_paths: compliance_paths.keys,
airtightness_values: epc_calculation_airtightnesses.keys,
epc_testing_target_types: epc_calculation_testing_target_types.keys,
building_types: building_types.keys,
energy_steps:
(ENV["MIN_ENERGY_STEP"].to_i..ENV["MAX_ENERGY_STEP"].to_i).to_a,
zero_carbon_steps:
(
ENV["MIN_ZERO_CARBON_STEP"].to_i..ENV["MAX_ZERO_CARBON_STEP"].to_i
).to_a,
building_characteristics_summary: {
performance_types: {
windows_glazed_doors:
StepCode::BuildingCharacteristics::WindowsGlazedDoors::PERFORMANCE_TYPES.keys,
doors:
StepCode::BuildingCharacteristics::Line::Doors::PERFORMANCE_TYPES.keys,
space_heating_cooling:
StepCode::BuildingCharacteristics::Line::SpaceHeatingCooling::PERFORMANCE_TYPES.keys,
hot_water:
StepCode::BuildingCharacteristics::Line::HotWater::PERFORMANCE_TYPES.keys
},
fossil_fuels_presence:
StepCode::BuildingCharacteristics::FossilFuels::PRESENCE.keys
}
}
end
def compliance_reports
StepCode::Compliance::GenerateReports
.new(checklist: self, requirements: step_code.step_requirements)
.call
.reports
end
def passing_compliance_reports
compliance_reports.filter { |r| r[:energy].step && r[:zero_carbon].step }
end
def selected_report
return unless step_requirement.present?
compliance_reports.find { |r| r[:requirement_id] == step_requirement_id }
end
end