From d8709c88c0c4426fe975450046862c81ad7f453d Mon Sep 17 00:00:00 2001 From: Katharine Ahern Date: Wed, 6 Nov 2024 11:53:54 +0000 Subject: [PATCH 1/6] ap-5338: add sca fields to application details report --- app/models/legal_aid_application.rb | 12 ++++ .../mis/application_detail_csv_line.rb | 22 ++++++ .../mis/application_detail_csv_line_spec.rb | 68 +++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/app/models/legal_aid_application.rb b/app/models/legal_aid_application.rb index 58cbb160e3..1e96a53f7c 100644 --- a/app/models/legal_aid_application.rb +++ b/app/models/legal_aid_application.rb @@ -650,6 +650,18 @@ def related_proceedings proceedings.where(sca_type: "related") end + def biological_parent? + proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("biological") } + end + + def parental_responsibility_order? + proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("court_order") } + end + + def child_subject? + proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("child_subject") } + end + private def expired_by_2023_surname_at_birth_issue? diff --git a/app/services/reports/mis/application_detail_csv_line.rb b/app/services/reports/mis/application_detail_csv_line.rb index c629f323a5..95b20975d2 100644 --- a/app/services/reports/mis/application_detail_csv_line.rb +++ b/app/services/reports/mis/application_detail_csv_line.rb @@ -173,6 +173,10 @@ def self.header_row "Number of legal links", "No fixed address", "Previous CCMS ref?", + "Child subject client involvment type?", + "Biological parent relationship?", + "Parental responsibility order relationship?", + "Child subject relationship?", ] end @@ -209,6 +213,8 @@ def call linked_applications home_address previous_ccms_ref + child_client_involvement_type + sca sanitise end @@ -454,6 +460,22 @@ def previous_ccms_ref @line << yesno(laa.applicant.previous_reference.present?) end + def child_client_involvement_type + @line << yesno(proceedings.any? { |proceeding| proceeding.client_involvement_type_ccms_code.eql?("W") }) + end + + def sca + if laa.special_children_act_proceedings? + @line << yesno(laa.biological_parent?) + @line << yesno(laa.parental_responsibility_order?) + @line << yesno(laa.child_subject?) + else + @line << nil + @line << nil + @line << nil + end + end + def yesno(value) value == true ? "Yes" : "No" end diff --git a/spec/services/reports/mis/application_detail_csv_line_spec.rb b/spec/services/reports/mis/application_detail_csv_line_spec.rb index ebb268f064..134340c1fc 100644 --- a/spec/services/reports/mis/application_detail_csv_line_spec.rb +++ b/spec/services/reports/mis/application_detail_csv_line_spec.rb @@ -853,6 +853,74 @@ module MIS end end + describe "child client involvement type" do + context "when the provider has selected child subject for any of the application proceedings" do + before { legal_aid_application.proceedings << proceeding } + + let(:proceeding) { create(:proceeding, :pb059, client_involvement_type_ccms_code: "W") } + + it "sets child subject client involement type to Yes" do + expect(value_for("Child subject client involvment type?")).to eq "Yes" + end + end + + context "when the provider has not selected child subject for any of the application proceedings" do + it "sets child subject client involement type to No" do + expect(value_for("Child subject client involvment type?")).to eq "No" + end + end + end + + describe "SCA fields" do + context "when the application has no SCA proceedings" do + it "returns the expected data" do + expect(value_for("Biological parent relationship?")).to be_nil + expect(value_for("Parental responsibility order relationship?")).to be_nil + expect(value_for("Child subject relationship?")).to be_nil + end + end + + context "when the application has an sca proceeding" do + let(:sca_proceeding) { create(:proceeding, :pb059, relationship_to_child:) } + + before { legal_aid_application.proceedings << sca_proceeding } + + context "when the application has a proceeding with relationship_to_child biological" do + let(:relationship_to_child) { "biological" } + + it "returns the expected data" do + expect(value_for("Biological parent relationship?")).to eq "Yes" + expect(value_for("Parental responsibility order relationship?")).to eq "No" + expect(value_for("Child subject relationship?")).to eq "No" + end + end + + context "when the application has a proceeding with relationship_to_child court_order" do + let(:relationship_to_child) { "court_order" } + + before { legal_aid_application.proceedings << sca_proceeding } + + it "returns the expected data" do + expect(value_for("Biological parent relationship?")).to eq "No" + expect(value_for("Parental responsibility order relationship?")).to eq "Yes" + expect(value_for("Child subject relationship?")).to eq "No" + end + end + + context "when the application has a proceeding with relationship_to_child child_subject" do + let(:relationship_to_child) { "child_subject" } + + before { legal_aid_application.proceedings << sca_proceeding } + + it "returns the expected data" do + expect(value_for("Biological parent relationship?")).to eq "No" + expect(value_for("Parental responsibility order relationship?")).to eq "No" + expect(value_for("Child subject relationship?")).to eq "Yes" + end + end + end + end + context "when the applicant age cannot be generated" do let(:legal_aid_application) { create(:legal_aid_application, applicant:) } let(:applicant) do From a3c2ac62a8140da399adb6ad442bd856c8db2f97 Mon Sep 17 00:00:00 2001 From: Katharine Ahern Date: Thu, 7 Nov 2024 09:14:13 +0000 Subject: [PATCH 2/6] ap-5338: add placeholder for autogranted logic --- app/models/legal_aid_application.rb | 5 +++++ .../reports/mis/application_detail_csv_line.rb | 6 ++++++ .../mis/application_detail_csv_line_spec.rb | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/app/models/legal_aid_application.rb b/app/models/legal_aid_application.rb index 1e96a53f7c..bba9e6d1f5 100644 --- a/app/models/legal_aid_application.rb +++ b/app/models/legal_aid_application.rb @@ -662,6 +662,11 @@ def child_subject? proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("child_subject") } end + def auto_grant_special_children_act?(_options) + # TODO: extract autogrant logic into model + false + end + private def expired_by_2023_surname_at_birth_issue? diff --git a/app/services/reports/mis/application_detail_csv_line.rb b/app/services/reports/mis/application_detail_csv_line.rb index 95b20975d2..863321920b 100644 --- a/app/services/reports/mis/application_detail_csv_line.rb +++ b/app/services/reports/mis/application_detail_csv_line.rb @@ -177,6 +177,7 @@ def self.header_row "Biological parent relationship?", "Parental responsibility order relationship?", "Child subject relationship?", + "Autogranted?", ] end @@ -215,6 +216,7 @@ def call previous_ccms_ref child_client_involvement_type sca + autogranted sanitise end @@ -476,6 +478,10 @@ def sca end end + def autogranted + @line << yesno(laa.auto_grant_special_children_act?(nil)) + end + def yesno(value) value == true ? "Yes" : "No" end diff --git a/spec/services/reports/mis/application_detail_csv_line_spec.rb b/spec/services/reports/mis/application_detail_csv_line_spec.rb index 134340c1fc..92c65132a6 100644 --- a/spec/services/reports/mis/application_detail_csv_line_spec.rb +++ b/spec/services/reports/mis/application_detail_csv_line_spec.rb @@ -921,6 +921,24 @@ module MIS end end + describe "autogranted" do + context "when the application is autogranted" do + before { allow(legal_aid_application).to receive(:auto_grant_special_children_act?).and_return(true) } + + it "sets autogranted? to Yes" do + expect(value_for("Autogranted?")).to eq "Yes" + end + end + + context "when the application is not autogranted" do + before { allow(legal_aid_application).to receive(:auto_grant_special_children_act?).and_return(false) } + + it "sets autogranted? to Yes" do + expect(value_for("Autogranted?")).to eq "No" + end + end + end + context "when the applicant age cannot be generated" do let(:legal_aid_application) { create(:legal_aid_application, applicant:) } let(:applicant) do From 6e77d132c1702d86a007c148ea621c14f038c1ae Mon Sep 17 00:00:00 2001 From: Katharine Ahern Date: Thu, 7 Nov 2024 10:24:36 +0000 Subject: [PATCH 3/6] ap-5338: add sca fields to application digest --- app/models/application_digest.rb | 8 +++ app/models/legal_aid_application.rb | 6 +-- .../mis/application_detail_csv_line.rb | 10 ++-- spec/models/application_digest_spec.rb | 52 +++++++++++++++++++ spec/models/legal_aid_application_spec.rb | 48 +++++++++++++++++ .../mis/application_detail_csv_line_spec.rb | 4 +- 6 files changed, 118 insertions(+), 10 deletions(-) diff --git a/app/models/application_digest.rb b/app/models/application_digest.rb index f07dddf314..85d68455b0 100644 --- a/app/models/application_digest.rb +++ b/app/models/application_digest.rb @@ -14,6 +14,10 @@ class ApplicationDigest < ApplicationRecord family_linked legal_linked no_fixed_address + biological_parent + parental_responsibility_order + child_subject + autogranted ].freeze class << self @@ -64,6 +68,10 @@ def map_attrs(application_id) legal_linked_lead_or_associated: laa.legal_linked_lead_or_associated, number_of_legal_linked_applications: laa.legal_linked_applications_count, no_fixed_address: laa.applicant.no_fixed_residence?, + biological_parent: laa.biological_parent_relationship?, + parental_responsibility_order: laa.parental_responsibility_order_relationship?, + child_subject: laa.child_subject_relationship?, + autogranted: laa.auto_grant_special_children_act?(nil), } end diff --git a/app/models/legal_aid_application.rb b/app/models/legal_aid_application.rb index bba9e6d1f5..0d66760ba4 100644 --- a/app/models/legal_aid_application.rb +++ b/app/models/legal_aid_application.rb @@ -650,15 +650,15 @@ def related_proceedings proceedings.where(sca_type: "related") end - def biological_parent? + def biological_parent_relationship? proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("biological") } end - def parental_responsibility_order? + def parental_responsibility_order_relationship? proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("court_order") } end - def child_subject? + def child_subject_relationship? proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("child_subject") } end diff --git a/app/services/reports/mis/application_detail_csv_line.rb b/app/services/reports/mis/application_detail_csv_line.rb index 863321920b..15a0d8b16f 100644 --- a/app/services/reports/mis/application_detail_csv_line.rb +++ b/app/services/reports/mis/application_detail_csv_line.rb @@ -214,7 +214,7 @@ def call linked_applications home_address previous_ccms_ref - child_client_involvement_type + child_subject_client_involvement_type sca autogranted sanitise @@ -462,15 +462,15 @@ def previous_ccms_ref @line << yesno(laa.applicant.previous_reference.present?) end - def child_client_involvement_type + def child_subject_client_involvement_type @line << yesno(proceedings.any? { |proceeding| proceeding.client_involvement_type_ccms_code.eql?("W") }) end def sca if laa.special_children_act_proceedings? - @line << yesno(laa.biological_parent?) - @line << yesno(laa.parental_responsibility_order?) - @line << yesno(laa.child_subject?) + @line << yesno(laa.biological_parent_relationship?) + @line << yesno(laa.parental_responsibility_order_relationship?) + @line << yesno(laa.child_subject_relationship?) else @line << nil @line << nil diff --git a/spec/models/application_digest_spec.rb b/spec/models/application_digest_spec.rb index 02d1edc43c..ad4203bf4e 100644 --- a/spec/models/application_digest_spec.rb +++ b/spec/models/application_digest_spec.rb @@ -522,5 +522,57 @@ end end end + + describe "sca fields" do + let(:sca_proceeding) { create(:proceeding, :pb059, relationship_to_child:) } + + before { laa.proceedings << sca_proceeding } + + context "when the application has a proceeding with relationship_to_child biological" do + let(:relationship_to_child) { "biological" } + + it "returns the expected data" do + application_digest + expect(digest.biological_parent).to be true + expect(digest.parental_responsibility_order).to be false + expect(digest.child_subject).to be false + end + end + + context "when the application has a proceeding with relationship_to_child court_order" do + let(:relationship_to_child) { "court_order" } + + before { laa.proceedings << sca_proceeding } + + it "returns the expected data" do + application_digest + expect(digest.biological_parent).to be false + expect(digest.parental_responsibility_order).to be true + expect(digest.child_subject).to be false + end + end + + context "when the application has a proceeding with relationship_to_child child_subject" do + let(:relationship_to_child) { "child_subject" } + + before { laa.proceedings << sca_proceeding } + + it "returns the expected data" do + application_digest + expect(digest.biological_parent).to be false + expect(digest.parental_responsibility_order).to be false + expect(digest.child_subject).to be true + end + end + end + + describe "autogranted" do + context "when the application is not autogranted" do + it "returns autogranted false" do + application_digest + expect(digest.autogranted).to be false + end + end + end end end diff --git a/spec/models/legal_aid_application_spec.rb b/spec/models/legal_aid_application_spec.rb index 3942609ff2..9cd127d1e8 100644 --- a/spec/models/legal_aid_application_spec.rb +++ b/spec/models/legal_aid_application_spec.rb @@ -2194,6 +2194,54 @@ end end + describe "#biological_parent_relationship?" do + subject { legal_aid_application.biological_parent_relationship? } + + context "with a proceeding with a biological_parent relationship" do + before { legal_aid_application.proceedings << sca_proceeding } + + let(:sca_proceeding) { create(:proceeding, :pb059, relationship_to_child: "biological") } + + it { is_expected.to be true } + end + + context "without a proceeding with a biological parent relationship" do + it { is_expected.to be false } + end + end + + describe "#parental_responsibility_order_relationship?" do + subject { legal_aid_application.parental_responsibility_order_relationship? } + + context "with a proceeding with a parental_responsibility_order relationship" do + before { legal_aid_application.proceedings << sca_proceeding } + + let(:sca_proceeding) { create(:proceeding, :pb059, relationship_to_child: "court_order") } + + it { is_expected.to be true } + end + + context "without a proceeding with a parental_responsibility_order relationship" do + it { is_expected.to be false } + end + end + + describe "#child_subject_relationship?" do + subject { legal_aid_application.child_subject_relationship? } + + context "with a proceeding with a child_subject relationship" do + before { legal_aid_application.proceedings << sca_proceeding } + + let(:sca_proceeding) { create(:proceeding, :pb059, relationship_to_child: "child_subject") } + + it { is_expected.to be true } + end + + context "without a proceeding with a child_subject relationship" do + it { is_expected.to be false } + end + end + private def uploaded_evidence_output diff --git a/spec/services/reports/mis/application_detail_csv_line_spec.rb b/spec/services/reports/mis/application_detail_csv_line_spec.rb index 92c65132a6..d7d9ac4fa0 100644 --- a/spec/services/reports/mis/application_detail_csv_line_spec.rb +++ b/spec/services/reports/mis/application_detail_csv_line_spec.rb @@ -853,7 +853,7 @@ module MIS end end - describe "child client involvement type" do + describe "child subject client involvement type" do context "when the provider has selected child subject for any of the application proceedings" do before { legal_aid_application.proceedings << proceeding } @@ -933,7 +933,7 @@ module MIS context "when the application is not autogranted" do before { allow(legal_aid_application).to receive(:auto_grant_special_children_act?).and_return(false) } - it "sets autogranted? to Yes" do + it "sets autogranted? to No" do expect(value_for("Autogranted?")).to eq "No" end end From 90104a55ae14e4e4f02d8c8ea0caa3b78fb3a7e5 Mon Sep 17 00:00:00 2001 From: Katharine Ahern Date: Mon, 11 Nov 2024 10:06:35 +0000 Subject: [PATCH 4/6] ap-5338: add parental_responsibility_agreement parental_responsibility type --- app/models/application_digest.rb | 6 +++-- app/models/legal_aid_application.rb | 10 ++++++- .../mis/application_detail_csv_line.rb | 7 +++-- spec/models/application_digest_spec.rb | 23 +++++++++++++--- spec/models/legal_aid_application_spec.rb | 24 ++++++++++++++--- .../mis/application_detail_csv_line_spec.rb | 27 +++++++++++++------ 6 files changed, 77 insertions(+), 20 deletions(-) diff --git a/app/models/application_digest.rb b/app/models/application_digest.rb index 85d68455b0..83002fddd9 100644 --- a/app/models/application_digest.rb +++ b/app/models/application_digest.rb @@ -15,7 +15,8 @@ class ApplicationDigest < ApplicationRecord legal_linked no_fixed_address biological_parent - parental_responsibility_order + parental_responsibility_agreement + parental_responsibility_court_order child_subject autogranted ].freeze @@ -69,7 +70,8 @@ def map_attrs(application_id) number_of_legal_linked_applications: laa.legal_linked_applications_count, no_fixed_address: laa.applicant.no_fixed_residence?, biological_parent: laa.biological_parent_relationship?, - parental_responsibility_order: laa.parental_responsibility_order_relationship?, + parental_responsibility_agreement: laa.parental_responsibility_agreement_relationship?, + parental_responsibility_court_order: laa.parental_responsibility_court_order_relationship?, child_subject: laa.child_subject_relationship?, autogranted: laa.auto_grant_special_children_act?(nil), } diff --git a/app/models/legal_aid_application.rb b/app/models/legal_aid_application.rb index 0d66760ba4..0c7447b774 100644 --- a/app/models/legal_aid_application.rb +++ b/app/models/legal_aid_application.rb @@ -654,14 +654,22 @@ def biological_parent_relationship? proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("biological") } end - def parental_responsibility_order_relationship? + def parental_responsibility_court_order_relationship? proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("court_order") } end + def parental_responsibility_agreement_relationship? + proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("parental_responsibility_agreement") } + end + def child_subject_relationship? proceedings.any? { |proceeding| proceeding.relationship_to_child.eql?("child_subject") } end + def parental_responsibility_evidence? + attachments&.parental_responsibility&.exists? + end + def auto_grant_special_children_act?(_options) # TODO: extract autogrant logic into model false diff --git a/app/services/reports/mis/application_detail_csv_line.rb b/app/services/reports/mis/application_detail_csv_line.rb index 15a0d8b16f..3e8795e583 100644 --- a/app/services/reports/mis/application_detail_csv_line.rb +++ b/app/services/reports/mis/application_detail_csv_line.rb @@ -175,7 +175,8 @@ def self.header_row "Previous CCMS ref?", "Child subject client involvment type?", "Biological parent relationship?", - "Parental responsibility order relationship?", + "Parental responsibility agreement relationship?", + "Parental responsibility court order relationship?", "Child subject relationship?", "Autogranted?", ] @@ -469,12 +470,14 @@ def child_subject_client_involvement_type def sca if laa.special_children_act_proceedings? @line << yesno(laa.biological_parent_relationship?) - @line << yesno(laa.parental_responsibility_order_relationship?) + @line << yesno(laa.parental_responsibility_agreement_relationship?) + @line << yesno(laa.parental_responsibility_court_order_relationship?) @line << yesno(laa.child_subject_relationship?) else @line << nil @line << nil @line << nil + @line << nil end end diff --git a/spec/models/application_digest_spec.rb b/spec/models/application_digest_spec.rb index ad4203bf4e..6fc82db312 100644 --- a/spec/models/application_digest_spec.rb +++ b/spec/models/application_digest_spec.rb @@ -534,7 +534,22 @@ it "returns the expected data" do application_digest expect(digest.biological_parent).to be true - expect(digest.parental_responsibility_order).to be false + expect(digest.parental_responsibility_agreement).to be false + expect(digest.parental_responsibility_court_order).to be false + expect(digest.child_subject).to be false + end + end + + context "when the application has a proceeding with relationship_to_child parental_responsibility_agreement" do + let(:relationship_to_child) { "parental_responsibility_agreement" } + + before { laa.proceedings << sca_proceeding } + + it "returns the expected data" do + application_digest + expect(digest.biological_parent).to be false + expect(digest.parental_responsibility_agreement).to be true + expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be false end end @@ -547,7 +562,8 @@ it "returns the expected data" do application_digest expect(digest.biological_parent).to be false - expect(digest.parental_responsibility_order).to be true + expect(digest.parental_responsibility_agreement).to be false + expect(digest.parental_responsibility_court_order).to be true expect(digest.child_subject).to be false end end @@ -560,7 +576,8 @@ it "returns the expected data" do application_digest expect(digest.biological_parent).to be false - expect(digest.parental_responsibility_order).to be false + expect(digest.parental_responsibility_agreement).to be false + expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be true end end diff --git a/spec/models/legal_aid_application_spec.rb b/spec/models/legal_aid_application_spec.rb index 9cd127d1e8..28d5275324 100644 --- a/spec/models/legal_aid_application_spec.rb +++ b/spec/models/legal_aid_application_spec.rb @@ -2210,10 +2210,10 @@ end end - describe "#parental_responsibility_order_relationship?" do - subject { legal_aid_application.parental_responsibility_order_relationship? } + describe "#parental_responsibility_court_order_relationship?" do + subject { legal_aid_application.parental_responsibility_court_order_relationship? } - context "with a proceeding with a parental_responsibility_order relationship" do + context "with a proceeding with a parental_responsibility_court_order relationship" do before { legal_aid_application.proceedings << sca_proceeding } let(:sca_proceeding) { create(:proceeding, :pb059, relationship_to_child: "court_order") } @@ -2221,7 +2221,23 @@ it { is_expected.to be true } end - context "without a proceeding with a parental_responsibility_order relationship" do + context "without a proceeding with a parental_responsibility_court_order relationship" do + it { is_expected.to be false } + end + end + + describe "#parental_responsibility_agreement_relationship?" do + subject { legal_aid_application.parental_responsibility_agreement_relationship? } + + context "with a proceeding with a parental_responsibility_agreement relationship" do + before { legal_aid_application.proceedings << sca_proceeding } + + let(:sca_proceeding) { create(:proceeding, :pb059, relationship_to_child: "parental_responsibility_agreement") } + + it { is_expected.to be true } + end + + context "without a proceeding with a parental_responsibility_agreement relationship" do it { is_expected.to be false } end end diff --git a/spec/services/reports/mis/application_detail_csv_line_spec.rb b/spec/services/reports/mis/application_detail_csv_line_spec.rb index d7d9ac4fa0..48e0280c8a 100644 --- a/spec/services/reports/mis/application_detail_csv_line_spec.rb +++ b/spec/services/reports/mis/application_detail_csv_line_spec.rb @@ -875,7 +875,8 @@ module MIS context "when the application has no SCA proceedings" do it "returns the expected data" do expect(value_for("Biological parent relationship?")).to be_nil - expect(value_for("Parental responsibility order relationship?")).to be_nil + expect(value_for("Parental responsibility agreement relationship?")).to be_nil + expect(value_for("Parental responsibility court order relationship?")).to be_nil expect(value_for("Child subject relationship?")).to be_nil end end @@ -890,7 +891,19 @@ module MIS it "returns the expected data" do expect(value_for("Biological parent relationship?")).to eq "Yes" - expect(value_for("Parental responsibility order relationship?")).to eq "No" + expect(value_for("Parental responsibility agreement relationship?")).to eq "No" + expect(value_for("Parental responsibility court order relationship?")).to eq "No" + expect(value_for("Child subject relationship?")).to eq "No" + end + end + + context "when the application has a proceeding with relatitionship_to_child parental_responsibl;ity_agreement" do + let(:relationship_to_child) { "parental_responsibility_agreement" } + + it "returns the expected data" do + expect(value_for("Biological parent relationship?")).to eq "No" + expect(value_for("Parental responsibility agreement relationship?")).to eq "Yes" + expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "No" end end @@ -898,11 +911,10 @@ module MIS context "when the application has a proceeding with relationship_to_child court_order" do let(:relationship_to_child) { "court_order" } - before { legal_aid_application.proceedings << sca_proceeding } - it "returns the expected data" do expect(value_for("Biological parent relationship?")).to eq "No" - expect(value_for("Parental responsibility order relationship?")).to eq "Yes" + expect(value_for("Parental responsibility agreement relationship?")).to eq "No" + expect(value_for("Parental responsibility court order relationship?")).to eq "Yes" expect(value_for("Child subject relationship?")).to eq "No" end end @@ -910,11 +922,10 @@ module MIS context "when the application has a proceeding with relationship_to_child child_subject" do let(:relationship_to_child) { "child_subject" } - before { legal_aid_application.proceedings << sca_proceeding } - it "returns the expected data" do expect(value_for("Biological parent relationship?")).to eq "No" - expect(value_for("Parental responsibility order relationship?")).to eq "No" + expect(value_for("Parental responsibility agreement relationship?")).to eq "No" + expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "Yes" end end From 54927b4f97eb6066610deab699adbdd00ccb86c5 Mon Sep 17 00:00:00 2001 From: Katharine Ahern Date: Mon, 11 Nov 2024 11:07:43 +0000 Subject: [PATCH 5/6] ap-5338: add parental_responsibility_evidence --- app/models/application_digest.rb | 2 ++ .../reports/mis/application_detail_csv_line.rb | 5 +++++ spec/factories/attachments.rb | 6 ++++++ spec/models/application_digest_spec.rb | 10 +++++++++- spec/models/legal_aid_application_spec.rb | 15 +++++++++++++++ .../mis/application_detail_csv_line_spec.rb | 8 ++++++++ 6 files changed, 45 insertions(+), 1 deletion(-) diff --git a/app/models/application_digest.rb b/app/models/application_digest.rb index 83002fddd9..e3e9d125fd 100644 --- a/app/models/application_digest.rb +++ b/app/models/application_digest.rb @@ -18,6 +18,7 @@ class ApplicationDigest < ApplicationRecord parental_responsibility_agreement parental_responsibility_court_order child_subject + parental_responsibility_evidence autogranted ].freeze @@ -73,6 +74,7 @@ def map_attrs(application_id) parental_responsibility_agreement: laa.parental_responsibility_agreement_relationship?, parental_responsibility_court_order: laa.parental_responsibility_court_order_relationship?, child_subject: laa.child_subject_relationship?, + parental_responsibility_evidence: laa.parental_responsibility_evidence?, autogranted: laa.auto_grant_special_children_act?(nil), } end diff --git a/app/services/reports/mis/application_detail_csv_line.rb b/app/services/reports/mis/application_detail_csv_line.rb index 3e8795e583..7ffd6721b0 100644 --- a/app/services/reports/mis/application_detail_csv_line.rb +++ b/app/services/reports/mis/application_detail_csv_line.rb @@ -178,6 +178,7 @@ def self.header_row "Parental responsibility agreement relationship?", "Parental responsibility court order relationship?", "Child subject relationship?", + "Parental responsibility evidence?", "Autogranted?", ] end @@ -473,11 +474,15 @@ def sca @line << yesno(laa.parental_responsibility_agreement_relationship?) @line << yesno(laa.parental_responsibility_court_order_relationship?) @line << yesno(laa.child_subject_relationship?) + @line << if laa.parental_responsibility_agreement_relationship? || laa.parental_responsibility_court_order_relationship? + yesno(laa.parental_responsibility_evidence?) + end else @line << nil @line << nil @line << nil @line << nil + @line << nil end end diff --git a/spec/factories/attachments.rb b/spec/factories/attachments.rb index ba591aeb88..6e5b3d8e14 100644 --- a/spec/factories/attachments.rb +++ b/spec/factories/attachments.rb @@ -32,6 +32,12 @@ attachment_name { "bank_transaction_report.csv" } end + trait :parental_responsibility do + attachment_type { "parental_responsibility" } + sequence(:attachment_name) { |n| "parental_responsibility_#{n}" } + sequence(:original_filename) { "original_filename.pdf" } + end + trait :uploaded_evidence_collection do attachment_type { "uncategorised" } attachment_name { "uploaded_evidence_collection" } diff --git a/spec/models/application_digest_spec.rb b/spec/models/application_digest_spec.rb index 6fc82db312..6826a82447 100644 --- a/spec/models/application_digest_spec.rb +++ b/spec/models/application_digest_spec.rb @@ -537,13 +537,18 @@ expect(digest.parental_responsibility_agreement).to be false expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be false + expect(digest.parental_responsibility_evidence).to be false end end context "when the application has a proceeding with relationship_to_child parental_responsibility_agreement" do let(:relationship_to_child) { "parental_responsibility_agreement" } + let(:parental_responsibility_evidence) { create(:attachment, :parental_responsibility, attachment_name: "parental_responsibility") } - before { laa.proceedings << sca_proceeding } + before do + laa.proceedings << sca_proceeding + laa.attachments << parental_responsibility_evidence + end it "returns the expected data" do application_digest @@ -551,6 +556,7 @@ expect(digest.parental_responsibility_agreement).to be true expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be false + expect(digest.parental_responsibility_evidence).to be true end end @@ -565,6 +571,7 @@ expect(digest.parental_responsibility_agreement).to be false expect(digest.parental_responsibility_court_order).to be true expect(digest.child_subject).to be false + expect(digest.parental_responsibility_evidence).to be false end end @@ -579,6 +586,7 @@ expect(digest.parental_responsibility_agreement).to be false expect(digest.parental_responsibility_court_order).to be false expect(digest.child_subject).to be true + expect(digest.parental_responsibility_evidence).to be false end end end diff --git a/spec/models/legal_aid_application_spec.rb b/spec/models/legal_aid_application_spec.rb index 28d5275324..daa54d6ba2 100644 --- a/spec/models/legal_aid_application_spec.rb +++ b/spec/models/legal_aid_application_spec.rb @@ -2258,6 +2258,21 @@ end end + describe "#parental_responsibility_evidence?" do + subject { legal_aid_application.parental_responsibility_evidence? } + + context "with aan application that has parental responsibility evidence" do + let(:legal_aid_application) { create(:legal_aid_application, attachments: [parental_responsibility_evidence]) } + let(:parental_responsibility_evidence) { create(:attachment, :parental_responsibility, attachment_name: "parental_responsibility") } + + it { is_expected.to be true } + end + + context "without a proceeding with a child_subject relationship" do + it { is_expected.to be false } + end + end + private def uploaded_evidence_output diff --git a/spec/services/reports/mis/application_detail_csv_line_spec.rb b/spec/services/reports/mis/application_detail_csv_line_spec.rb index 48e0280c8a..5c4223f9ec 100644 --- a/spec/services/reports/mis/application_detail_csv_line_spec.rb +++ b/spec/services/reports/mis/application_detail_csv_line_spec.rb @@ -878,6 +878,7 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to be_nil expect(value_for("Parental responsibility court order relationship?")).to be_nil expect(value_for("Child subject relationship?")).to be_nil + expect(value_for("Parental responsibility evidence?")).to be_nil end end @@ -894,6 +895,7 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to eq "No" expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "No" + expect(value_for("Parental responsibility evidence?")).to be_nil end end @@ -905,17 +907,22 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to eq "Yes" expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "No" + expect(value_for("Parental responsibility evidence?")).to eq "No" end end context "when the application has a proceeding with relationship_to_child court_order" do let(:relationship_to_child) { "court_order" } + let(:parental_responsibility_evidence) { create(:attachment, :parental_responsibility, attachment_name: "parental_responsibility") } + + before { legal_aid_application.attachments << parental_responsibility_evidence } it "returns the expected data" do expect(value_for("Biological parent relationship?")).to eq "No" expect(value_for("Parental responsibility agreement relationship?")).to eq "No" expect(value_for("Parental responsibility court order relationship?")).to eq "Yes" expect(value_for("Child subject relationship?")).to eq "No" + expect(value_for("Parental responsibility evidence?")).to eq "Yes" end end @@ -927,6 +934,7 @@ module MIS expect(value_for("Parental responsibility agreement relationship?")).to eq "No" expect(value_for("Parental responsibility court order relationship?")).to eq "No" expect(value_for("Child subject relationship?")).to eq "Yes" + expect(value_for("Parental responsibility evidence?")).to be_nil end end end From 6890b6b3723248b18f2aa8cf513231d5183791b9 Mon Sep 17 00:00:00 2001 From: Katharine Ahern Date: Mon, 11 Nov 2024 11:13:37 +0000 Subject: [PATCH 6/6] ap-5338: add sca fields to application_digest table --- ...41107092712_add_sca_fields_to_application_digest.rb | 10 ++++++++++ db/schema.rb | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20241107092712_add_sca_fields_to_application_digest.rb diff --git a/db/migrate/20241107092712_add_sca_fields_to_application_digest.rb b/db/migrate/20241107092712_add_sca_fields_to_application_digest.rb new file mode 100644 index 0000000000..d8b1d15799 --- /dev/null +++ b/db/migrate/20241107092712_add_sca_fields_to_application_digest.rb @@ -0,0 +1,10 @@ +class AddSCAFieldsToApplicationDigest < ActiveRecord::Migration[7.2] + def change + add_column :application_digests, :biological_parent, :boolean + add_column :application_digests, :parental_responsibility_agreement, :boolean + add_column :application_digests, :parental_responsibility_court_order, :boolean + add_column :application_digests, :child_subject, :boolean + add_column :application_digests, :parental_responsibility_evidence, :boolean + add_column :application_digests, :autogranted, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index b744609869..c4449972d7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_10_30_094958) do +ActiveRecord::Schema[7.2].define(version: 2024_11_07_092712) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -183,6 +183,12 @@ t.string "legal_linked_lead_or_associated" t.integer "number_of_legal_linked_applications" t.boolean "no_fixed_address" + t.boolean "biological_parent" + t.boolean "parental_responsibility_agreement" + t.boolean "parental_responsibility_court_order" + t.boolean "child_subject" + t.boolean "parental_responsibility_evidence" + t.boolean "autogranted" t.index ["legal_aid_application_id"], name: "index_application_digests_on_legal_aid_application_id", unique: true end