diff --git a/app/models/legal_aid_application.rb b/app/models/legal_aid_application.rb index 82ec8b5309..bb3af43431 100644 --- a/app/models/legal_aid_application.rb +++ b/app/models/legal_aid_application.rb @@ -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 diff --git a/app/services/ccms/manual_review_determiner.rb b/app/services/ccms/manual_review_determiner.rb index 9818f89b82..4d163ae6a7 100644 --- a/app/services/ccms/manual_review_determiner.rb +++ b/app/services/ccms/manual_review_determiner.rb @@ -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?, @@ -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 @@ -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? diff --git a/app/services/manual_review_detailer.rb b/app/services/manual_review_detailer.rb index a257ec82eb..8a041b6846 100644 --- a/app/services/manual_review_detailer.rb +++ b/app/services/manual_review_detailer.rb @@ -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 diff --git a/app/services/results_panel_selector.rb b/app/services/results_panel_selector.rb index 5ba18a8cad..5438119b3a 100644 --- a/app/services/results_panel_selector.rb +++ b/app/services/results_panel_selector.rb @@ -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 @@ -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 diff --git a/app/views/providers/means_reports/_caseworker_review.html.erb b/app/views/providers/means_reports/_caseworker_review.html.erb index ec9e5e1ad0..7c13f18607 100644 --- a/app/views/providers/means_reports/_caseworker_review.html.erb +++ b/app/views/providers/means_reports/_caseworker_review.html.erb @@ -32,7 +32,7 @@
"> <%= t(".category-#{reason}") %>
-
" id="<%= "review-reason-#{reason}" %>"> +
" id="<%= "review-reason-#{reason}" %>"> <% categories.each do |category| %> <%= t(".category.#{category}") %>
diff --git a/app/views/providers/means_reports/_with_bank_statement_uploads.html.erb b/app/views/providers/means_reports/_with_bank_statement_uploads.html.erb index 9e4bdba0b6..2b482cb70f 100644 --- a/app/views/providers/means_reports/_with_bank_statement_uploads.html.erb +++ b/app/views/providers/means_reports/_with_bank_statement_uploads.html.erb @@ -57,6 +57,7 @@ <%= render "shared/check_answers/assets", read_only: true, individual: "" %> <% if @legal_aid_application.passported? && @manual_review_determiner.manual_review_required? %> +
<%= render "caseworker_review" %> <% end %> diff --git a/app/views/providers/means_reports/_with_cfe_result_details.html.erb b/app/views/providers/means_reports/_with_cfe_result_details.html.erb index b5faf13c34..689c2792d6 100644 --- a/app/views/providers/means_reports/_with_cfe_result_details.html.erb +++ b/app/views/providers/means_reports/_with_cfe_result_details.html.erb @@ -86,6 +86,8 @@ <%= render "shared/check_answers/assets", read_only: true, individual: %> <% if @legal_aid_application.passported? && @manual_review_determiner.manual_review_required? %> +
+ <%= render "caseworker_review" %> <% end %> diff --git a/config/locales/en/providers.yml b/config/locales/en/providers.yml index a1171b50b7..233f99c834 100644 --- a/config/locales/en/providers.yml +++ b/config/locales/en/providers.yml @@ -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 diff --git a/spec/factories/capital_disregards.rb b/spec/factories/capital_disregards.rb new file mode 100644 index 0000000000..8587c0caa3 --- /dev/null +++ b/spec/factories/capital_disregards.rb @@ -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 diff --git a/spec/models/legal_aid_application_spec.rb b/spec/models/legal_aid_application_spec.rb index b157c354ad..4c445616b8 100644 --- a/spec/models/legal_aid_application_spec.rb +++ b/spec/models/legal_aid_application_spec.rb @@ -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 { diff --git a/spec/services/ccms/manual_review_determiner_spec.rb b/spec/services/ccms/manual_review_determiner_spec.rb index fb105a9ce0..a806e3a11c 100644 --- a/spec/services/ccms/manual_review_determiner_spec.rb +++ b/spec/services/ccms/manual_review_determiner_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/spec/services/manual_review_detailer_spec.rb b/spec/services/manual_review_detailer_spec.rb index 3df29d9617..e3a9e9d8ce 100644 --- a/spec/services/manual_review_detailer_spec.rb +++ b/spec/services/manual_review_detailer_spec.rb @@ -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") diff --git a/spec/services/results_panel_selector_spec.rb b/spec/services/results_panel_selector_spec.rb index 055d1fe25a..faae60b35e 100644 --- a/spec/services/results_panel_selector_spec.rb +++ b/spec/services/results_panel_selector_spec.rb @@ -7,106 +7,106 @@ before { allow(legal_aid_application).to receive(:cfe_result).and_return(cfe_result) } describe ".call" do - describe "V3 results" do - context "when it is eligible, with no restrictions and no policy disregards" do - let(:cfe_result) { create(:cfe_v3_result, :eligible) } + context "when it is eligible, with no restrictions and no policy disregards" do + let(:cfe_result) { create(:cfe_v6_result, :eligible) } - it "returns the eligible partial name" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/eligible" - end + it "returns the eligible partial name" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/eligible" end + end - context "when it has income_contribution_with no restrictions but with disregards" do - let(:cfe_result) { create(:cfe_v3_result, :with_income_contribution_required) } + context "when it is partially_eligible with income_contribution no restrictions or disregards" do + let(:cfe_result) { create(:cfe_v6_result, :partially_eligible_with_income_contribution_required) } - before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: true) - end + before do + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false) + end - it "returns the income_contribution name" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" - end + it "returns the correct income specific partial" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/partially_eligible_income" end end - describe "V4 results" do - context "when it is eligible, with no restrictions and no policy disregards" do - let(:cfe_result) { create(:cfe_v4_result, :eligible) } + context "when it is partially_eligible with capital_contribution no restrictions or disregards" do + let(:cfe_result) { create(:cfe_v6_result, :partially_eligible_with_capital_contribution_required) } + + before do + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false) + end - it "returns the eligible partial name" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/eligible" - end + it "returns the correct capital specific partial" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/partially_eligible_capital" end + end - context "when it is partially_eligible with income_contribution no restrictions or disregards" do - let(:cfe_result) { create(:cfe_v4_result, :partially_eligible_with_income_contribution_required) } + context "when it is eligible with no restrictions or disregards, with extra employment information" do + let(:cfe_result) { create(:cfe_v6_result, :eligible) } - before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false) - end + before do + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false) + allow(applicant).to receive(:extra_employment_information?).and_return(true) + end - it "returns the correct income specific partial" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/partially_eligible_income" - end + it "returns the correct capital specific partial" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" end + end - context "when it is partially_eligible with capital_contribution no restrictions or disregards" do - let(:cfe_result) { create(:cfe_v4_result, :partially_eligible_with_capital_contribution_required) } + context "when it has income_contribution with no restrictions or disregards, with extra employment information" do + let(:cfe_result) { create(:cfe_v6_result, :with_income_contribution_required) } - before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false) - end + before do + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false) + allow(applicant).to receive(:extra_employment_information?).and_return(true) + end - it "returns the correct capital specific partial" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/partially_eligible_capital" - end + it "returns the income_contribution name" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" end + end - context "when it is eligible with no restrictions or disregards, with extra employment information" do - let(:cfe_result) { create(:cfe_v4_result, :eligible) } + context "when it is partially_eligible with capital_contribution no restrictions or disregards, with extra employment information" do + let(:cfe_result) { create(:cfe_v6_result, :partially_eligible_with_capital_contribution_required) } - before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false) - allow(applicant).to receive(:extra_employment_information?).and_return(true) - end + before do + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false) + allow(applicant).to receive(:extra_employment_information?).and_return(true) + end - it "returns the correct capital specific partial" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" - end + it "returns the correct capital specific partial" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" end + end - context "when it has income_contribution with no restrictions or disregards, with extra employment information" do - let(:cfe_result) { create(:cfe_v4_result, :with_income_contribution_required) } + context "when it is eligible with no restrictions or disregards, with full employment details manually entered by the provider" do + let(:cfe_result) { create(:cfe_v6_result, :eligible) } - before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: true) - allow(applicant).to receive(:extra_employment_information?).and_return(true) - end + before do + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false, full_employment_details: "test details") + end - it "returns the income_contribution name" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" - end + it "returns the correct capital specific partial" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" end + end - context "when it is partially_eligible with capital_contribution no restrictions or disregards, with extra employment information" do - let(:cfe_result) { create(:cfe_v4_result, :partially_eligible_with_capital_contribution_required) } + context "when it has income_contribution with no restrictions or disregards, with full employment details manually entered by the provider" do + let(:cfe_result) { create(:cfe_v6_result, :with_income_contribution_required) } - before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false) - allow(applicant).to receive(:extra_employment_information?).and_return(true) - end + before do + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false, full_employment_details: "test details") + end - it "returns the correct capital specific partial" do - expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" - end + it "returns the income_contribution name" do + expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" end end - context "when it is eligible with no restrictions or disregards, with full employment details manually entered by the provider" do - let(:cfe_result) { create(:cfe_v4_result, :eligible) } + context "when it is partially_eligible with capital_contribution no restrictions or disregards, with extra full employment details manually entered by the provider" do + let(:cfe_result) { create(:cfe_v6_result, :partially_eligible_with_capital_contribution_required) } before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, full_employment_details: "test details") + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: false, full_employment_details: "test details") end it "returns the correct capital specific partial" do @@ -114,23 +114,23 @@ end end - context "when it has income_contribution with no restrictions or disregards, with full employment details manually entered by the provider" do - let(:cfe_result) { create(:cfe_v4_result, :with_income_contribution_required) } + context "when it is partially_eligible with no restrictions or capital disregards BUT with policy disregards" do + let(:cfe_result) { create(:cfe_v6_result, :partially_eligible_with_income_contribution_required) } before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: true, full_employment_details: "test details") + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: true, capital_disregards?: false) end - it "returns the income_contribution name" do + it "returns the correct capital specific partial" do expect(described_class.call(legal_aid_application)).to eq "shared/assessment_results/manual_check_required" end end - context "when it is partially_eligible with capital_contribution no restrictions or disregards, with extra full employment details manually entered by the provider" do - let(:cfe_result) { create(:cfe_v4_result, :partially_eligible_with_capital_contribution_required) } + context "when it is partially_eligible with no restrictions or policy disregards BUT with capital disregards" do + let(:cfe_result) { create(:cfe_v6_result, :partially_eligible_with_income_contribution_required) } before do - allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, full_employment_details: "test details") + allow(legal_aid_application).to receive_messages(has_restrictions?: false, policy_disregards?: false, capital_disregards?: true) end it "returns the correct capital specific partial" do