generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1489 from ministryofjustice/EL-1631-remove-check-…
…anwers-yml EL-1631 Remove check_answers.yml file
- Loading branch information
Showing
42 changed files
with
1,758 additions
and
683 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class BenefitsSubsection | ||
class << self | ||
def tables(check:, status_field_name:, status_attribute_name:, benefits:, benefits_field_name:) | ||
benefit_table = | ||
Table.new(screen: status_field_name, skip_change_link: false, index: nil, disputed?: nil, | ||
fields: [ | ||
FieldPresenter.new(table_label: status_field_name, attribute: status_attribute_name, type: :boolean, model: check), | ||
]) | ||
|
||
benefits_add = (benefits || []).map.with_index do |model, index| | ||
Table.new(screen: benefits_field_name, skip_change_link: false, index:, disputed?: nil, | ||
fields: [ | ||
SubFieldPresenter.new(table_label: benefits_field_name, attribute: :benefit_type, type: :number_or_text, model:), | ||
MoneySubFieldPresenter.new(table_label: benefits_field_name, attribute: :benefit_amount, model:, index:, disputed: false), | ||
SubFieldPresenter.new(table_label: benefits_field_name, attribute: :benefit_frequency, type: :frequency, model:), | ||
]) | ||
end | ||
|
||
[benefit_table] + benefits_add | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class EmploymentSubsection | ||
class << self | ||
def tables(check:, status_field_name:, incomes:, income_field_name:) | ||
employment_status = Table.new(screen: status_field_name, index: nil, | ||
disputed?: false, skip_change_link: false, fields: [ | ||
FieldPresenter.new(table_label: status_field_name, attribute: status_field_name, type: :select, model: check), | ||
]) | ||
|
||
employments = (incomes || []).map.with_index do |model, index| | ||
Table.new(screen: income_field_name, index:, | ||
disputed?: false, skip_change_link: false, | ||
fields: [ | ||
SubFieldPresenter.new(table_label: income_field_name, attribute: :income_type, type: :select, model:), | ||
SubFieldPresenter.new(table_label: income_field_name, attribute: :income_frequency, type: :frequency, model:), | ||
MoneySubFieldPresenter.new(table_label: income_field_name, attribute: :gross_income, index:, model:, disputed: false), | ||
MoneySubFieldPresenter.new(table_label: income_field_name, attribute: :income_tax, index:, model:, disputed: false), | ||
MoneySubFieldPresenter.new(table_label: income_field_name, attribute: :national_insurance, index:, model:, disputed: false), | ||
]) | ||
end | ||
[employment_status] + employments | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class FieldPresenter | ||
attr_reader :type | ||
|
||
def initialize(table_label:, attribute:, type:, model:) | ||
@table_label = table_label | ||
@attribute = attribute | ||
@type = type | ||
@model = model | ||
end | ||
|
||
def screen | ||
nil | ||
end | ||
|
||
def value | ||
@model.public_send(@attribute) | ||
end | ||
|
||
def label | ||
"#{@table_label}_fields.#{@attribute}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class FieldWithScreenPresenter < FieldPresenter | ||
attr_reader :screen | ||
|
||
def initialize(table_label:, attribute:, type:, model:, screen:) | ||
super(table_label:, attribute:, type:, model:) | ||
@screen = screen | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class MoneyPresenter < FieldPresenter | ||
def initialize(table_label:, attribute:, model:, disputed: false) | ||
super(table_label:, attribute:, type: :money, model:) | ||
@disputed = disputed | ||
end | ||
|
||
# top level field so never has an index | ||
def index | ||
nil | ||
end | ||
|
||
def disputed? | ||
@disputed | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class MoneySubFieldPresenter < SubFieldPresenter | ||
attr_reader :index | ||
|
||
def initialize(table_label:, attribute:, model:, index:, disputed:) | ||
super(table_label:, attribute:, type: :money, model:) | ||
@disputed = disputed | ||
@index = index | ||
end | ||
|
||
def disputed? | ||
@disputed | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
app/services/check_answers/money_with_frequency_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class MoneyWithFrequencyPresenter < FieldPresenter | ||
attr_reader :frequency_value | ||
|
||
def initialize(table_label:, attribute:, model:, frequency_value:) | ||
super(table_label:, attribute:, type: :money_with_frequency, model:) | ||
@frequency_value = frequency_value | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class OptionalMoneyPresenter < FieldPresenter | ||
attr_reader :relevancy_value | ||
|
||
def initialize(table_label:, attribute:, model:, relevancy_value:) | ||
super(table_label:, attribute:, type: :optional_money, model:) | ||
@relevancy_value = relevancy_value | ||
end | ||
|
||
def disputed? | ||
false | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/services/check_answers/optional_money_with_frequency_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class OptionalMoneyWithFrequencyPresenter < FieldPresenter | ||
attr_reader :frequency_value, :relevancy_value | ||
|
||
def initialize(table_label:, attribute:, model:, frequency_value:, relevancy_value:) | ||
super(table_label:, attribute:, type: :optional_money_with_frequency, model:) | ||
@frequency_value = frequency_value | ||
@relevancy_value = relevancy_value | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class OtherIncomeSubsection | ||
class << self | ||
def tables(check:, other_income_field:, attribute_prefix:) | ||
other_income = | ||
Table.new(screen: other_income_field, skip_change_link: false, index: nil, disputed?: nil, | ||
fields: [ | ||
OptionalMoneyWithFrequencyPresenter.new(table_label: other_income_field, | ||
attribute: "#{attribute_prefix}friends_or_family_conditional_value".to_sym, | ||
model: check, | ||
frequency_value: check.public_send("#{attribute_prefix}friends_or_family_frequency".to_sym), | ||
relevancy_value: check.public_send("#{attribute_prefix}friends_or_family_relevant".to_sym)), | ||
OptionalMoneyWithFrequencyPresenter.new(table_label: other_income_field, | ||
attribute: "#{attribute_prefix}maintenance_conditional_value".to_sym, | ||
model: check, | ||
frequency_value: check.public_send("#{attribute_prefix}maintenance_frequency".to_sym), | ||
relevancy_value: check.public_send("#{attribute_prefix}maintenance_relevant".to_sym)), | ||
OptionalMoneyWithFrequencyPresenter.new(table_label: other_income_field, | ||
attribute: "#{attribute_prefix}property_or_lodger_conditional_value".to_sym, | ||
model: check, | ||
frequency_value: check.public_send("#{attribute_prefix}property_or_lodger_frequency".to_sym), | ||
relevancy_value: check.public_send("#{attribute_prefix}property_or_lodger_relevant".to_sym)), | ||
OptionalMoneyWithFrequencyPresenter.new(table_label: other_income_field, | ||
attribute: "#{attribute_prefix}pension_conditional_value".to_sym, | ||
model: check, | ||
frequency_value: check.public_send("#{attribute_prefix}pension_frequency".to_sym), | ||
relevancy_value: check.public_send("#{attribute_prefix}pension_relevant".to_sym)), | ||
OptionalMoneyPresenter.new(table_label: other_income_field, | ||
attribute: "#{attribute_prefix}student_finance_conditional_value".to_sym, | ||
model: check, | ||
relevancy_value: check.public_send("#{attribute_prefix}student_finance_relevant".to_sym)), | ||
OptionalMoneyPresenter.new(table_label: other_income_field, | ||
attribute: "#{attribute_prefix}other_conditional_value".to_sym, | ||
model: check, | ||
relevancy_value: check.public_send("#{attribute_prefix}other_relevant".to_sym)), | ||
]) | ||
[other_income] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class OutgoingsSubsection | ||
class << self | ||
def tables(check:, label:, attribute_prefix:) | ||
table = Table.new screen: label, | ||
skip_change_link: false, index: nil, disputed?: nil, | ||
fields: [ | ||
if check.eligible_for_childcare_costs? | ||
OptionalMoneyWithFrequencyPresenter.new(table_label: label, | ||
attribute: "#{attribute_prefix}childcare_payments_conditional_value".to_sym, | ||
model: check, | ||
frequency_value: check.public_send("#{attribute_prefix}childcare_payments_frequency".to_sym), | ||
relevancy_value: check.public_send("#{attribute_prefix}childcare_payments_relevant".to_sym)) | ||
end, | ||
OptionalMoneyWithFrequencyPresenter.new(table_label: label, | ||
attribute: "#{attribute_prefix}maintenance_payments_conditional_value".to_sym, | ||
model: check, | ||
frequency_value: check.public_send("#{attribute_prefix}maintenance_payments_frequency".to_sym), | ||
relevancy_value: check.public_send("#{attribute_prefix}maintenance_payments_relevant".to_sym)), | ||
OptionalMoneyWithFrequencyPresenter.new(table_label: label, | ||
attribute: "#{attribute_prefix}legal_aid_payments_conditional_value".to_sym, | ||
model: check, | ||
frequency_value: check.public_send("#{attribute_prefix}legal_aid_payments_frequency".to_sym), | ||
relevancy_value: check.public_send("#{attribute_prefix}legal_aid_payments_relevant".to_sym)), | ||
].compact | ||
[table] | ||
end | ||
end | ||
end | ||
end |
30 changes: 30 additions & 0 deletions
30
app/services/check_answers/partner_dependant_field_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckAnswers | ||
class PartnerDependantFieldPresenter | ||
attr_reader :type | ||
|
||
def initialize(table_label:, attribute:, type:, model:) | ||
@table_label = table_label | ||
@attribute = attribute | ||
@type = type | ||
@model = model | ||
end | ||
|
||
def screen | ||
nil | ||
end | ||
|
||
def value | ||
@model.public_send(@attribute) | ||
end | ||
|
||
def label | ||
if @model.partner | ||
"#{@table_label}_fields.#{@attribute}_partner" | ||
else | ||
"#{@table_label}_fields.#{@attribute}" | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.