Skip to content

Commit

Permalink
Merge pull request #7400 from ministryofjustice/ap-5435/add-explicit-…
Browse files Browse the repository at this point in the history
…remarks-for-capital-disregards

AP-5435: Add capital disregard reason to means report
  • Loading branch information
jsugarman authored Nov 6, 2024
2 parents ca17a7d + c1f2101 commit 238c3f0
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 92 deletions.
4 changes: 4 additions & 0 deletions app/models/legal_aid_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ def policy_disregards?
policy_disregards&.any? ? true : false
end

def capital_disregards?
capital_disregards&.any? ? true : false
end

def transactions_total_by_type(transaction_type, category_id)
__send__(:"#{transaction_type}_transactions").amounts.fetch(category_id, 0)
end
Expand Down
3 changes: 3 additions & 0 deletions app/services/ccms/manual_review_determiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ManualReviewDeterminer
:non_passported?,
:has_restrictions?,
:policy_disregards?,
:capital_disregards?,
:manually_entered_employment_information?,
:manual_client_employment_information?,
:manual_partner_employment_information?,
Expand All @@ -37,6 +38,7 @@ def manual_review_required?
capital_contribution_required? ||
has_restrictions? ||
policy_disregards? ||
capital_disregards? ||
manually_entered_employment_information? ||
uploading_bank_statements?
end
Expand Down Expand Up @@ -64,6 +66,7 @@ def application_review_reasons
application_review_reasons << :dwp_override if dwp_overridden?
application_review_reasons << :restrictions if has_restrictions?
application_review_reasons << :policy_disregards if policy_disregards?
application_review_reasons << :capital_disregards if capital_disregards?
application_review_reasons << :non_passported if non_passported?
application_review_reasons << :client_further_employment_details if manual_client_employment_information?
application_review_reasons << :partner_further_employment_details if manual_partner_employment_information?
Expand Down
14 changes: 11 additions & 3 deletions app/services/manual_review_detailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ def initialize(legal_aid_application)
@legal_aid_application = legal_aid_application
end

attr_reader :legal_aid_application

delegate :has_restrictions?,
:policy_disregards?,
:capital_disregards?,
:manually_entered_employment_information?,
to: :legal_aid_application

def call
details = []
details << I18n.t("shared.assessment_results.manual_check_required.restrictions") if @legal_aid_application.has_restrictions?
details << I18n.t("shared.assessment_results.manual_check_required.policy_disregards") if @legal_aid_application.policy_disregards?
details << I18n.t("shared.assessment_results.manual_check_required.extra_employment_information") if @legal_aid_application.manually_entered_employment_information?
details << I18n.t("shared.assessment_results.manual_check_required.restrictions") if has_restrictions?
details << I18n.t("shared.assessment_results.manual_check_required.policy_disregards") if policy_disregards? || capital_disregards?
details << I18n.t("shared.assessment_results.manual_check_required.extra_employment_information") if manually_entered_employment_information?
details
end
end
20 changes: 10 additions & 10 deletions app/services/results_panel_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ def initialize(legal_aid_application)
@legal_aid_application = legal_aid_application
end

attr_reader :legal_aid_application

delegate :has_restrictions?,
:policy_disregards?,
:capital_disregards?,
:manually_entered_employment_information?,
to: :legal_aid_application

def call
return eligible_or_non_eligible if %w[eligible ineligible].include?(assessment_result)
return "shared/assessment_results/manual_check_required" if restrictions? || disregards? || manually_entered_employment_information?
return "shared/assessment_results/manual_check_required" if has_restrictions? || disregards? || manually_entered_employment_information?

"shared/assessment_results/#{cfe_result}#{capital_contribution}#{income_contribution}"
end
Expand All @@ -36,16 +44,8 @@ def income_contribution
"_income" if @legal_aid_application.cfe_result.income_contribution_required?
end

def restrictions?
@legal_aid_application.has_restrictions?
end

def disregards?
@legal_aid_application.policy_disregards?
end

def manually_entered_employment_information?
@legal_aid_application.manually_entered_employment_information?
policy_disregards? || capital_disregards?
end

def eligible_or_non_eligible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<dt class="<%= "govuk-summary-list__key govuk-!-width-one-half" %>">
<%= t(".category-#{reason}") %>
</dt>
<dd class="<%= "govuk-summary-list__value ovuk-!-text-align-right" %>" id="<%= "review-reason-#{reason}" %>">
<dd class="<%= "govuk-summary-list__value govuk-!-text-align-right" %>" id="<%= "review-reason-#{reason}" %>">
<% categories.each do |category| %>
<%= t(".category.#{category}") %>
<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<%= render "shared/check_answers/assets", read_only: true, individual: "" %>

<% if @legal_aid_application.passported? && @manual_review_determiner.manual_review_required? %>
<div class="govuk-!-padding-bottom-8"></div>
<%= render "caseworker_review" %>
<% end %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
<%= render "shared/check_answers/assets", read_only: true, individual: %>

<% if @legal_aid_application.passported? && @manual_review_determiner.manual_review_required? %>
<div class="govuk-!-padding-bottom-8"></div>

<%= render "caseworker_review" %>
<% end %>

Expand Down
1 change: 1 addition & 0 deletions config/locales/en/providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,7 @@ en:
unknown_frequency: Frequency unknown
residual_balance: Capital Contribution - Residual Balance Check
policy_disregards: Discretionary disregards selected
capital_disregards: Capital disregards declared
multi_benefit: Multiple benefits in single bank transaction
dwp_override: Provider disagrees with DWP result
restrictions: Restrictions on client's assets
Expand Down
19 changes: 19 additions & 0 deletions spec/factories/capital_disregards.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FactoryBot.define do
factory :capital_disregard do
legal_aid_application
name { "backdated_benefits" }
amount { nil }
date_received { nil }
payment_reason { nil }
account_name { nil }
mandatory { true }

trait :discretionary do
mandatory { false }
end

trait :mandatory do
mandatory { true }
end
end
end
17 changes: 17 additions & 0 deletions spec/models/legal_aid_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@
end
end

describe "#capital_disregards?" do
context "with no capital disregard record" do
it "returns false" do
expect(legal_aid_application.capital_disregards).to be_empty
expect(legal_aid_application.capital_disregards?).to be false
end
end

context "with capital_disregards record" do
before { create(:capital_disregard, legal_aid_application:) }

it "returns true" do
expect(legal_aid_application.capital_disregards?).to be true
end
end
end

describe "#add_benefit_check_result" do
let(:benefit_check_response) do
{
Expand Down
72 changes: 67 additions & 5 deletions spec/services/ccms/manual_review_determiner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ module CCMS
context "with policy_disregards" do
before do
allow(legal_aid_application).to receive(:policy_disregards?).and_return(true)
create(:cfe_v4_result, submission: cfe_submission)
create(:cfe_v6_result, submission: cfe_submission)
end

it "returns true" do
Expand All @@ -211,7 +211,29 @@ module CCMS
context "without policy_disregards" do
before do
allow(legal_aid_application).to receive(:policy_disregards?).and_return(false)
create(:cfe_v4_result, submission: cfe_submission)
create(:cfe_v6_result, submission: cfe_submission)
end

it "returns false" do
expect(manual_review_required).to be false
end
end

context "with capital_disregards" do
before do
allow(legal_aid_application).to receive(:capital_disregards?).and_return(true)
create(:cfe_v6_result, submission: cfe_submission)
end

it "returns true" do
expect(manual_review_required).to be true
end
end

context "without capital_disregards" do
before do
allow(legal_aid_application).to receive(:capital_disregards?).and_return(false)
create(:cfe_v6_result, submission: cfe_submission)
end

it "returns false" do
Expand All @@ -222,7 +244,7 @@ module CCMS
context "with client further employment information" do
let(:legal_aid_application) { create(:legal_aid_application, :with_employed_applicant_and_extra_info) }

before { create(:cfe_v4_result, submission: cfe_submission) }
before { create(:cfe_v6_result, submission: cfe_submission) }

it "returns true" do
expect(manual_review_required).to be true
Expand All @@ -232,7 +254,7 @@ module CCMS
context "with partner further employment information" do
let(:legal_aid_application) { create(:legal_aid_application, :with_employed_partner_and_extra_info) }

before { create(:cfe_v4_result, submission: cfe_submission) }
before { create(:cfe_v6_result, submission: cfe_submission) }

it "returns true" do
expect(manual_review_required).to be true
Expand All @@ -242,7 +264,7 @@ module CCMS
context "without further employment information" do
let(:legal_aid_application) { create(:legal_aid_application, :with_employed_applicant) }

before { create(:cfe_v4_result, submission: cfe_submission) }
before { create(:cfe_v6_result, submission: cfe_submission) }

it "returns false" do
expect(manual_review_required).to be false
Expand Down Expand Up @@ -367,6 +389,46 @@ module CCMS
expect(review_reasons_result).to include(:ineligible)
end
end

context "with policy_disregards" do
before do
create(:policy_disregards, legal_aid_application:, vaccine_damage_payments: true)
end

it "adds capital_disregards to the review reasons" do
expect(review_reasons_result).to include(:policy_disregards)
end
end

context "without policy_disregards" do
before do
create(:policy_disregards, legal_aid_application:)
end

it "does not add policy_disregards to the review reasons" do
expect(review_reasons_result).not_to include(:policy_disregards)
end
end

context "with capital_disregards" do
before do
create(:capital_disregard, legal_aid_application:)
end

it "adds capital_disregards to the review reasons" do
expect(review_reasons_result).to include(:capital_disregards)
end
end

context "without capital_disregards" do
before do
legal_aid_application.capital_disregards.destroy_all
end

it "does not add capital_disregards to the review reasons" do
expect(review_reasons_result).not_to include(:capital_disregards)
end
end
end

context "with passported application" do
Expand Down
13 changes: 13 additions & 0 deletions spec/services/manual_review_detailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@
end
end

context "when there are restrictions, without policy disregards, with capital disregards and with extra employment information" do
before do
allow(legal_aid_application).to receive_messages(has_restrictions?: true, policy_disregards?: false, capital_disregards?: true)
allow(applicant).to receive(:extra_employment_information?).and_return(true)
end

it "returns an array with three entries" do
expect(described_class.call(legal_aid_application)).to eq [I18n.t("shared.assessment_results.manual_check_required.restrictions"),
I18n.t("shared.assessment_results.manual_check_required.policy_disregards"),
I18n.t("shared.assessment_results.manual_check_required.extra_employment_information")]
end
end

context "when there are restrictions, with policy disregards and with full employment details manually entered by the provider" do
before do
allow(legal_aid_application).to receive_messages(has_restrictions?: true, policy_disregards?: true, full_employment_details: "test details")
Expand Down
Loading

0 comments on commit 238c3f0

Please sign in to comment.