Skip to content

Commit

Permalink
Merge pull request #5982 from ministryofjustice/ap-4503-correction-to…
Browse files Browse the repository at this point in the history
…-ineligible-result

Ap 4503 correction to ineligible result
  • Loading branch information
kmahern authored Nov 21, 2023
2 parents 662a702 + 5ca265a commit 5059908
Show file tree
Hide file tree
Showing 10 changed files with 893 additions and 24 deletions.
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

0 comments on commit 5059908

Please sign in to comment.