Repository navigation
Expand file tree
/
Copy pathcalculate_married_couples_allowance_flow.rb
More file actions
143 lines (117 loc) · 3.47 KB
/
Copy pathcalculate_married_couples_allowance_flow.rb
File metadata and controls
143 lines (117 loc) · 3.47 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
class CalculateMarriedCouplesAllowanceFlow < SmartAnswer::Flow
def define
content_id "e04dc5fe-9a31-4229-9de9-884dd0c0a8ce"
name "calculate-married-couples-allowance"
status :published
radio :were_you_or_your_partner_born_on_or_before_6_april_1935? do
option :yes
option :no
next_node do |response|
if response == "yes"
question :did_you_marry_or_civil_partner_before_5_december_2005?
else
outcome :sorry
end
end
end
radio :did_you_marry_or_civil_partner_before_5_december_2005? do
option :yes
option :no
on_response do |response|
self.calculator = SmartAnswer::Calculators::MarriedCouplesAllowanceCalculator.new
calculator.marriage_or_civil_partnership_before_5_december_2005 = response
end
next_node do
if calculator.husband_income_measured?
question :whats_the_husbands_date_of_birth?
else
question :whats_the_highest_earners_date_of_birth?
end
end
end
date_question :whats_the_husbands_date_of_birth? do
on_response do |response|
calculator.birth_date = response
end
next_node do
question :whats_the_husbands_income?
end
end
date_question :whats_the_highest_earners_date_of_birth? do
on_response do |response|
calculator.birth_date = response
end
next_node do
question :whats_the_highest_earners_income?
end
end
money_question :whats_the_husbands_income? do
on_response do |response|
calculator.income = response
end
validate { calculator.valid_income? }
next_node do
if calculator.income_within_limit_for_personal_allowance?
outcome :husband_done
else
question :paying_into_a_pension?
end
end
end
money_question :whats_the_highest_earners_income? do
on_response do |response|
calculator.income = response
end
validate { calculator.valid_income? }
next_node do
if calculator.income_within_limit_for_personal_allowance?
outcome :highest_earner_done
else
question :paying_into_a_pension?
end
end
end
radio :paying_into_a_pension? do
option :yes
option :no
next_node do |response|
if response == "yes"
question :how_much_expected_contributions_before_tax?
else
question :how_much_expected_gift_aided_donations?
end
end
end
money_question :how_much_expected_contributions_before_tax? do
on_response do |response|
calculator.gross_pension_contributions = response
end
next_node do
question :how_much_expected_contributions_with_tax_relief?
end
end
money_question :how_much_expected_contributions_with_tax_relief? do
on_response do |response|
calculator.net_pension_contributions = response
end
next_node do
question :how_much_expected_gift_aided_donations?
end
end
money_question :how_much_expected_gift_aided_donations? do
on_response do |response|
calculator.gift_aided_donations = response
end
next_node do
if calculator.husband_income_measured?
outcome :husband_done
else
outcome :highest_earner_done
end
end
end
outcome :husband_done
outcome :highest_earner_done
outcome :sorry
end
end