Skip to content

Commit

Permalink
ap-5338: add sca fields to application details report
Browse files Browse the repository at this point in the history
  • Loading branch information
kmahern committed Nov 7, 2024
1 parent 63edd44 commit 0d456b3
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/models/legal_aid_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
22 changes: 22 additions & 0 deletions app/services/reports/mis/application_detail_csv_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -209,6 +213,8 @@ def call
linked_applications
home_address
previous_ccms_ref
child_client_involvement_type
sca
sanitise
end

Expand Down Expand Up @@ -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
Expand Down
68 changes: 68 additions & 0 deletions spec/services/reports/mis/application_detail_csv_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0d456b3

Please sign in to comment.