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

Ap 4503 correction to ineligible result #5982

Merged
merged 6 commits into from
Nov 21, 2023
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
28 changes: 28 additions & 0 deletions app/helpers/ineligible_reasons_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module IneligibleReasonsHelper
def ineligible_reasons(cfe_result)
return "" unless cfe_result.assessment_result == "ineligible"

reasons = ineligible_reasons_array(cfe_result)
return ineligible_reason(reasons.first) if reasons.length == 1

ineligible_reasons = ":<ul class='govuk-list govuk-list--bullet'>"
reasons.each do |reason|
ineligible_reasons += "<li>#{ineligible_reason(reason)}</li>"
end
ineligible_reasons += "</ul>"
end

private

def ineligible_reason(reason)
t("shared.ineligible_reasons.#{reason}")
end

def ineligible_reasons_array(cfe_result)
ineligible_reasons_array = []
ineligible_reasons_array << "gross_income" if cfe_result.ineligible_gross_income?
ineligible_reasons_array << "disposable_income" if cfe_result.ineligible_disposable_income?
ineligible_reasons_array << "disposable_capital" if cfe_result.ineligible_disposable_capital?
ineligible_reasons_array
end
end
27 changes: 27 additions & 0 deletions app/models/cfe/v6/result.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
module CFE
module V6
class Result < CFE::V4::Result
def gross_income_results
gross_income_proceeding_types.pluck(:result)
end

def disposable_income_results
disposable_income_proceeding_types.pluck(:result)
end

def capital_proceeding_types
capital_summary[:proceeding_types]
end

def capital_results
capital_proceeding_types.pluck(:result)
end

def ineligible_gross_income?
gross_income_results.all?("ineligible")
end

def ineligible_disposable_income?
disposable_income_results.all?("ineligible")
end

def ineligible_disposable_capital?
capital_results.all?("ineligible")
end
end
end
end
2 changes: 1 addition & 1 deletion app/views/shared/assessment_results/_ineligible.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<p class="govuk-body"><%= t(".detail") %></p>
<p class="govuk-body"><%= sanitize(t(".detail", ineligible_reasons: ineligible_reasons(@cfe_result))) %></p>
</div>
</div>
6 changes: 5 additions & 1 deletion config/locales/en/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ en:
- You still need to provide details of the case before we can decide if they’re eligible.
ineligible:
heading: "%{name} is unlikely to get legal aid"
detail: This is because they have too much disposable capital.
detail: "This is because they have too much %{ineligible_reasons}"
capital_contribution_required:
heading: "%{name} may need to pay towards legal aid"
details:
Expand Down Expand Up @@ -922,3 +922,7 @@ en:
details: |
For example, Child Benefit or tax credits.
Do not include Housing Benefit, government Cost of Living Payments, or any other disregarded benefits.
ineligible_reasons:
gross_income: gross income
disposable_income: disposable income
disposable_capital: disposable capital
Loading