Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert part-year-profit-tax-credits to use ERB templates for questions #2143

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions lib/smart_answer_flows/locales/en/part-year-profit-tax-credits.yml

This file was deleted.

2 changes: 2 additions & 0 deletions lib/smart_answer_flows/part-year-profit-tax-credits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def define
satisfies_need "103438"
content_id "de6723a5-7256-4bfd-aad3-82b04b06b73e"

use_erb_templates_for_questions

date_question :when_did_your_tax_credits_award_end? do
from { Calculators::PartYearProfitTaxCreditsCalculator::TAX_CREDITS_AWARD_ENDS_EARLIEST_DATE }
to { Calculators::PartYearProfitTaxCreditsCalculator::TAX_CREDITS_AWARD_ENDS_LATEST_DATE }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% content_for :title do %>
Did you start trading before <%= format_date(accounting_year_begins_on) %>?
<% end %>

<% options(
"yes": "Yes",
"no": "No"
) %>

<% content_for :error_message do %>
You need to select yes or no to continue.
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% content_for :title do %>
Do your accounts cover the 12 month period up to <%= format_date(accounting_year_ends_on) %>?
<% end %>

<% options(
"yes": "Yes",
"no": "No"
) %>

<% content_for :error_message do %>
You need to select yes or no to continue.
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% content_for :title do %>
Have you stopped trading?
<% end %>

<% options(
"yes": "Yes",
"no": "No"
) %>

<% content_for :hint do %>
This means you’re no longer running your business.
<% end %>

<% content_for :error_message do %>
You need to select yes or no to continue.
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% content_for :title do %>
What date do your accounts go up to?
<% end %>

<% content_for :hint do %>
This is the last date of the accounting period for your business. For most people, this will be 5 April.
<% end %>

<% content_for :error_message do %>
You need to enter a date to continue.
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% content_for :title do %>
What is your actual or estimated taxable profit between <%= format_date(basis_period_begins_on) %> and <%= format_date(basis_period_ends_on) %>?
<% end %>

<% content_for :hint do %>
This is the amount left over after you take all your earnings from self-employment and deduct any allowable expenses and losses. If this is over 2 years of accounts you need to add them together.
<% end %>

<% content_for :error_message do %>
Enter your taxable profit.
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% content_for :title do %>
When did you start trading?
<% end %>

<% content_for :hint do %>
This date must be before <%= format_date(award_period_ends_on) %>.
<% end %>

<% content_for :error_message do %>
You need to enter a date to continue.
<% end %>
<% content_for :invalid_start_trading_date do %>
The start trading date must be before the date your Tax Credits award ends.
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% content_for :title do %>
When did you stop trading?
<% end %>

<% content_for :hint do %>
This date must be between <%= format_date(tax_year_begins_on) %> and <%= format_date(tax_year_ends_on) %>, which is the start and end dates of the tax year that your tax credit award ends in.
<% end %>

<% content_for :not_in_tax_year_error do %>
The date must be between <%= format_date(tax_year_begins_on) %> and <%= format_date(tax_year_ends_on) %>.
<% end %>
<% content_for :error_message do %>
You need to enter a date to continue.
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% content_for :title do %>
When did your Tax Credits award end?
<% end %>

<% content_for :hint do %>
You can find this on your award review.
<% end %>

<% content_for :error_message do %>
You need to enter a date to continue.
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,6 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
end
end

context 'when rendering did_you_start_trading_before_the_relevant_accounting_year? question' do
setup do
question = @flow.node(:did_you_start_trading_before_the_relevant_accounting_year?)
@state = SmartAnswer::State.new(question)
@presenter = QuestionPresenter.new(@i18n_prefix, question, @state)
end

should 'have options with labels' do
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
end

should 'have a default error message' do
@state.error = 'error-message'
assert_equal 'You need to select yes or no to continue.', @presenter.error
end
end

context 'when rendering do_your_accounts_cover_a_12_month_period? question' do
setup do
question = @flow.node(:do_your_accounts_cover_a_12_month_period?)
Expand Down Expand Up @@ -115,15 +98,23 @@ class PartYearProfitTaxCreditsViewTest < ActiveSupport::TestCase
context 'when rendering did_you_start_trading_before_the_relevant_accounting_year? question' do
setup do
question = @flow.node(:did_you_start_trading_before_the_relevant_accounting_year?)
state = SmartAnswer::State.new(question)
state.accounting_year_begins_on = Date.parse('2015-04-06')
presenter = QuestionPresenter.new(@i18n_prefix, question, state)
@title = presenter.title
@state = SmartAnswer::State.new(question)
@state.accounting_year_begins_on = Date.parse('2015-04-06')
@presenter = QuestionPresenter.new(@i18n_prefix, question, @state)
end

should 'have options with labels' do
assert_equal({ 'yes' => 'Yes', 'no' => 'No' }, values_vs_labels(@presenter.options))
end

should 'have a default error message' do
@state.error = 'error-message'
assert_equal 'You need to select yes or no to continue.', @presenter.error
end

should 'display title with interpolated accounting_year_begins_on' do
expected = "Did you start trading before 6 April 2015?"
assert_equal expected, @title
assert_equal expected, @presenter.title
end
end

Expand Down