Skip to content

Commit

Permalink
AP-5335: Update CYA, Review and print and means report pages to handl…
Browse files Browse the repository at this point in the history
…e Housing benefits question

The check_income_answers, review_and_print_application, submitted_application
and means report need to reflect the addition of the new houseing benefit question
that is now part of truelayer.
  • Loading branch information
jsugarman committed Oct 16, 2024
1 parent 2697d02 commit 62781d7
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def housing_benefit_params

def individual
show_for_partner = legal_aid_application.housing_payments_for?("Partner")
show_for_client = legal_aid_application.housing_payments_for?("Applicant") && legal_aid_application.uploading_bank_statements?
show_for_client = legal_aid_application.housing_payments_for?("Applicant")
if show_for_partner && show_for_client
I18n.t("generic.client_or_partner")
else
Expand Down
8 changes: 2 additions & 6 deletions app/helpers/means_report_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module MeansReportHelper
TransactionTypeItem = Struct.new(:name, :value_method, :scope, :suppress_border, :addendum)

def outgoings_detail_items(legal_aid_application)
def outgoings_detail_items
[
TransactionTypeItem.new(:housing, :moe_housing, "outgoing", false, housing_payment_addendum(legal_aid_application)),
TransactionTypeItem.new(:housing, :moe_housing, "outgoing", false),
TransactionTypeItem.new(:childcare, :moe_childcare, "outgoing", false),
TransactionTypeItem.new(:maintenance_out, :moe_maintenance_out, "outgoing", false),
TransactionTypeItem.new(:legal_aid, :moe_legal_aid, "outgoing", true),
Expand Down Expand Up @@ -48,8 +48,4 @@ def non_employed_income_detail_items
TransactionTypeItem.new(:pension, :mei_pension, "income", true),
]
end

def housing_payment_addendum(legal_aid_application)
t("shared.means_report.item.outgoing.housing_addendum") if legal_aid_application.uploading_bank_statements?
end
end
25 changes: 12 additions & 13 deletions app/services/flow/steps/partner/cash_outgoings_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ module Partner
CashOutgoingsStep = Step.new(
path: ->(application) { Steps.urls.providers_legal_aid_application_partners_cash_outgoing_path(application) },
forward: lambda do |application|
# if the applicant did not use Truelayer and makes housing payments, or if the partner makes housing payments, then ask about housing benefit
if (application.housing_payments_for?("Applicant") && application.uploading_bank_statements?) || application.housing_payments_for?("Partner")
:housing_benefits
else
:has_dependants
end
end,
if application.housing_payments_for?("Applicant") || application.housing_payments_for?("Partner")
:housing_benefits
else
:has_dependants
end
end,
check_answers: lambda do |application|
if (application.housing_payments_for?("Applicant") && application.uploading_bank_statements?) || application.housing_payments_for?("Partner")
:housing_benefits
else
:has_dependants
end
end,
if application.housing_payments_for?("Applicant") || application.housing_payments_for?("Partner")
:housing_benefits
else
:has_dependants
end
end,
)
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/views/shared/check_answers/_outgoings_details.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<section>
<dl id="outgoings-details-questions" class="govuk-summary-list govuk-!-margin-bottom-9">
<% outgoings_detail_items(@legal_aid_application).each do |item| %>
<% outgoings_detail_items.each do |item| %>
<%= render "shared/means_report/item", item.to_h %>
<% end %>
<%= render "shared/means_report/total", name: "total_outgoings", value_method: :total_monthly_outgoings %>
</dl>

</section>
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@
<% end %>
</section>

<!-- HOUSING BENEFIT -->

<section class="print-no-break govuk-!-padding-top-8">
<% if @legal_aid_application.housing_payments? %>
<% individual = @legal_aid_application.applicant.has_partner_with_no_contrary_interest? ? t("generic.client_or_partner") : t("generic.client") %>
<%= render(
"shared/check_answers/housing_benefit",
read_only: true,
individual:,
) %>
<% end %>
</section>

<!-- PARTNER INCOME -->

<% if @legal_aid_application.applicant.has_partner_with_no_contrary_interest? && !@legal_aid_application.applicant_receives_benefit? %>
Expand All @@ -66,7 +79,7 @@

<!-- CAPITAL -->

<section class="print-no-break govuk-!-padding-top-8">
<section class="print-no-break">
<% individual = @legal_aid_application.applicant.has_partner_with_no_contrary_interest? ? "_with_partner" : nil %>
<%= render "shared/check_answers/assets", read_only: true, individual: %>
</section>
Expand Down
9 changes: 3 additions & 6 deletions config/locales/en/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,17 @@ en:
student_loan: Partner student loan or grant
pension: Partner pension
outgoing:
housing: "Housing payments%{addendum}"
housing_addendum: " (any declared housing benefits have been deducted from this total)"
housing: "Housing payments (any declared housing benefits have been deducted from this total)"
childcare: Childcare payments
maintenance_out: Maintenance payments to a former partner
legal_aid: Payments towards legal aid in a criminal case
client:
housing: "Client housing payments%{addendum}"
housing_addendum: " (any declared housing benefits have been deducted from this total)"
housing: "Client housing payments (any declared housing benefits have been deducted from this total)"
childcare: Client childcare payments
maintenance_out: Client maintenance payments to a former partner
legal_aid: Client payments towards legal aid in a criminal case
partner:
housing: "Partner housing payments%{addendum}"
housing_addendum: " (any declared housing benefits have been deducted from this total)"
housing: "Partner housing payments (any declared housing benefits have been deducted from this total"
childcare: Partner childcare payments
maintenance_out: Partner maintenance payments to a former partner
legal_aid: Partner payments towards legal aid in a criminal case
Expand Down
2 changes: 1 addition & 1 deletion features/providers/means_report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Feature: Means report

And the Outgoings questions and answers should match:
| question | answer |
| Client housing payments | £125 |
| Client housing payments (any declared housing benefits have been deducted from this total) | £125 |
| Client childcare payments | £0 |
| Client maintenance payments to a former partner | £0 |
| Client payments towards legal aid in a criminal case | £100 |
Expand Down
24 changes: 0 additions & 24 deletions spec/helpers/means_report_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,6 @@
it "has expected items" do
expect(items.map(&:name)).to eq(%i[housing childcare maintenance_out legal_aid])
end

context "with housing item" do
subject(:housing_item) { items.first }

context "when an application is uploading_bank_statements?" do
before do
allow(legal_aid_application).to receive(:uploading_bank_statements?).and_return(true)
end

it "addendum matches expected text" do
expect(housing_item.addendum).to eq(" (any declared housing benefits have been deducted from this total)")
end
end

context "when an application is not uploading_bank_statements?" do
before do
allow(legal_aid_application).to receive(:uploading_bank_statements?).and_return(false)
end

it "addendum is nil" do
expect(housing_item.addendum).to be_nil
end
end
end
end

describe "#income_detail_items" do
Expand Down
49 changes: 36 additions & 13 deletions spec/services/flow/steps/partner/cash_outgoings_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

RSpec.describe Flow::Steps::Partner::CashOutgoingsStep, type: :request do
let(:legal_aid_application) { create(:legal_aid_application) }
let(:applicant_housing_payments?) { true }
let(:partner_housing_payments?) { false }
let(:bank_statements?) { true }

before do
allow(legal_aid_application).to receive(:housing_payments_for?).with("Applicant").and_return(applicant_housing_payments?)
allow(legal_aid_application).to receive(:housing_payments_for?).with("Partner").and_return(partner_housing_payments?)
allow(legal_aid_application).to receive(:uploading_bank_statements?).and_return(bank_statements?)
end

describe "#path" do
subject { described_class.path.call(legal_aid_application) }
Expand All @@ -21,19 +12,35 @@
describe "#forward" do
subject { described_class.forward.call(legal_aid_application) }

context "when the applicant has housing payments and is uploading bank statements" do
before do
allow(legal_aid_application).to receive(:housing_payments_for?).with("Applicant").and_return(applicant_housing_payments?)
allow(legal_aid_application).to receive(:housing_payments_for?).with("Partner").and_return(partner_housing_payments?)
end

context "when only the applicant has housing payments" do
let(:applicant_housing_payments?) { true }
let(:partner_housing_payments?) { false }

it { is_expected.to be :housing_benefits }
end

context "when the partner has housing payments" do
context "when only the partner has housing payments" do
let(:applicant_housing_payments?) { false }
let(:partner_housing_payments?) { true }

it { is_expected.to be :housing_benefits }
end

context "when both the applicant and partner have housing payments" do
let(:applicant_housing_payments?) { true }
let(:partner_housing_payments?) { true }

it { is_expected.to be :housing_benefits }
end

context "when there are no housing payments" do
let(:applicant_housing_payments?) { false }
let(:partner_housing_payments?) { false }

it { is_expected.to be :has_dependants }
end
Expand All @@ -42,19 +49,35 @@
describe "#check_answers" do
subject { described_class.check_answers.call(legal_aid_application) }

context "when the applicant has housing payments and is uploading bank statements" do
before do
allow(legal_aid_application).to receive(:housing_payments_for?).with("Applicant").and_return(applicant_housing_payments?)
allow(legal_aid_application).to receive(:housing_payments_for?).with("Partner").and_return(partner_housing_payments?)
end

context "when only the applicant has housing payments" do
let(:applicant_housing_payments?) { true }
let(:partner_housing_payments?) { false }

it { is_expected.to be :housing_benefits }
end

context "when the partner has housing payments" do
context "when only the partner has housing payments" do
let(:applicant_housing_payments?) { false }
let(:partner_housing_payments?) { true }

it { is_expected.to be :housing_benefits }
end

context "when both the applicant and partner have housing payments" do
let(:applicant_housing_payments?) { true }
let(:partner_housing_payments?) { true }

it { is_expected.to be :housing_benefits }
end

context "when there are no housing payments" do
let(:applicant_housing_payments?) { false }
let(:partner_housing_payments?) { false }

it { is_expected.to be :has_dependants }
end
Expand Down

0 comments on commit 62781d7

Please sign in to comment.