Repository navigation
Expand file tree
/
Copy pathcheck_building_safety_costs_flow.rb
More file actions
170 lines (140 loc) · 3.75 KB
/
Copy pathcheck_building_safety_costs_flow.rb
File metadata and controls
170 lines (140 loc) · 3.75 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
class CheckBuildingSafetyCostsFlow < SmartAnswer::Flow
def define
name "check-building-safety-costs"
content_id "29355604-e9a1-499a-9b0c-18abd833f02e"
status :published
radio :building_over_11_metres? do
option :yes
option :no
next_node do |response|
if response == "yes"
question :developer_agreed_to_pay?
else
outcome :unlikely_to_need_to_pay
end
end
end
radio :developer_agreed_to_pay? do
option :yes
option :no
option :dont_know
next_node do |response|
if response == "yes"
outcome :developers_pay
else
question :owned_by_leaseholders?
end
end
end
radio :owned_by_leaseholders? do
option :yes
option :no
next_node do |response|
if response == "no"
question :own_more_than_3_properties?
else
outcome :have_to_pay_owned_by_leaseholders
end
end
end
radio :own_more_than_3_properties? do
option :yes
option :no
next_node do |response|
if response == "yes"
question :main_home_february_2022?
else
question :purchased_pre_or_post_february_2022?
end
end
end
radio :main_home_february_2022? do
option :yes
option :no
next_node do |response|
if response == "yes"
question :purchased_pre_or_post_february_2022?
else
outcome :have_to_pay_not_main_home
end
end
end
radio :purchased_pre_or_post_february_2022? do
option :pre_feb_2022
option :post_feb_2022
on_response do |response|
self.calculator = SmartAnswer::Calculators::CheckBuildingSafetyCostsCalculator.new
calculator.purchased_pre_or_post_february_2022 = response
end
next_node do
question :year_of_purchase?
end
end
year_question :year_of_purchase? do
from { SmartAnswer::Calculators::CheckBuildingSafetyCostsCalculator::FIRST_VALID_YEAR }
to { SmartAnswer::Calculators::CheckBuildingSafetyCostsCalculator::LAST_VALID_YEAR }
on_response do |response|
calculator.year_of_purchase = response.to_i
end
next_node do
question :value_of_property?
end
end
money_question :value_of_property? do
on_response do |response|
calculator.value_of_property = response
end
next_node do
question :live_in_london?
end
end
radio :live_in_london? do
option :yes
option :no
on_response do |response|
calculator.live_in_london = response
end
next_node do
question :shared_ownership?
end
end
radio :shared_ownership? do
option :yes
option :no
on_response do |response|
calculator.shared_ownership = response
end
next_node do |response|
if response == "yes"
question :percentage_owned?
else
question :amount_already_paid?
end
end
end
value_question :percentage_owned?, parse: Float do
on_response do |response|
calculator.percentage_owned = response / 100
end
validate(:valid_percentage_owned?) do
calculator.valid_percentage_owned?
end
next_node do
question :amount_already_paid?
end
end
money_question :amount_already_paid? do
on_response do |response|
calculator.amount_already_paid = response
end
next_node do
outcome :payment_amount
end
end
outcome :developers_pay
outcome :unlikely_to_need_to_pay
outcome :have_to_pay_owned_by_leaseholders
outcome :have_to_pay_not_main_home
outcome :payment_amount
end
end