Repository navigation
Expand file tree
/
Copy pathpart_year_profit_tax_credits_flow.rb
More file actions
124 lines (102 loc) · 2.88 KB
/
Copy pathpart_year_profit_tax_credits_flow.rb
File metadata and controls
124 lines (102 loc) · 2.88 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
class PartYearProfitTaxCreditsFlow < SmartAnswer::Flow
def define
name "part-year-profit-tax-credits"
status :published
content_id "de6723a5-7256-4bfd-aad3-82b04b06b73e"
date_question :when_did_your_tax_credits_award_end? do
on_response do |response|
self.calculator = SmartAnswer::Calculators::PartYearProfitTaxCreditsCalculator.new
calculator.tax_credits_award_ends_on = response
end
next_node do
question :what_date_do_your_accounts_go_up_to?
end
end
date_question :what_date_do_your_accounts_go_up_to? do
default_year { 0 }
on_response do |response|
calculator.accounts_end_month_and_day = response
end
next_node do
question :have_you_stopped_trading?
end
end
radio :have_you_stopped_trading? do
option "yes"
option "no"
on_response do |response|
case response
when "yes"
calculator.stopped_trading = true
when "no"
calculator.stopped_trading = false
end
end
next_node do
if calculator.stopped_trading
question :did_you_start_trading_before_the_relevant_accounting_year?
else
question :do_your_accounts_cover_a_12_month_period?
end
end
end
radio :did_you_start_trading_before_the_relevant_accounting_year? do
option "yes"
option "no"
next_node do |response|
case response
when "yes"
question :when_did_you_stop_trading?
when "no"
question :when_did_you_start_trading?
end
end
end
date_question :when_did_you_stop_trading? do
on_response do |response|
calculator.stopped_trading_on = response
end
validate(:error_not_in_tax_year) do
calculator.valid_stopped_trading_date?
end
next_node do
question :what_is_your_taxable_profit?
end
end
radio :do_your_accounts_cover_a_12_month_period? do
option "yes"
option "no"
next_node do |response|
if response == "yes"
question :what_is_your_taxable_profit?
else
question :when_did_you_start_trading?
end
end
end
date_question :when_did_you_start_trading? do
on_response do |response|
calculator.started_trading_on = response
end
validate(:error_invalid_start_trading_date) do
calculator.valid_start_trading_date?
end
next_node do
if calculator.stopped_trading
question :when_did_you_stop_trading?
else
question :what_is_your_taxable_profit?
end
end
end
money_question :what_is_your_taxable_profit? do
on_response do |response|
calculator.taxable_profit = response
end
next_node do
outcome :result
end
end
outcome :result
end
end