Skip to content

Commit

Permalink
Merge pull request #6104 from ministryofjustice/jsugarman/add-preferr…
Browse files Browse the repository at this point in the history
…ed-address-to-ccms

Incident: Add correspondence address to CCMS payload
  • Loading branch information
jsugarman authored Dec 12, 2023
2 parents 0c12d34 + 3129f93 commit 336b0db
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 41 deletions.
4 changes: 0 additions & 4 deletions app/models/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ def pretty_postcode?
postcode[-4] == " "
end

def first_lines
[address_line_one, address_line_two].select(&:present?).join(" ")
end

def to_json(*_args)
{
address_line_one:,
Expand Down
5 changes: 4 additions & 1 deletion app/services/ccms/requestors/applicant_add_requestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def name(xml)
# this is all mandatory: we don't hold any of this data except date of birth
def personal_information(xml)
xml.__send__(:"clientbio:DateOfBirth", applicant.date_of_birth.to_fs(:ccms_date))
xml.__send__(:"clientbio:NINumber", applicant.national_insurance_number)
xml.__send__(:"clientbio:Gender", "UNSPECIFIED")
xml.__send__(:"clientbio:MaritalStatus", "U")
xml.__send__(:"clientbio:VulnerableClient", false)
Expand All @@ -62,8 +63,10 @@ def contacts(xml)
end

def applicant_address(xml)
xml.__send__(:"common:AddressLine1", address.first_lines)
xml.__send__(:"common:AddressLine1", address.address_line_one)
xml.__send__(:"common:AddressLine2", address.address_line_two)
xml.__send__(:"common:City", address.city)
xml.__send__(:"common:County", address.county)
xml.__send__(:"common:Country", "GBR")
xml.__send__(:"common:PostalCode", address.pretty_postcode)
end
Expand Down
12 changes: 11 additions & 1 deletion app/services/ccms/requestors/case_add_requestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def case_request(xml)

def generate_application_details(xml)
xml.__send__(:"casebio:Client") { generate_client(xml) }
xml.__send__(:"casebio:PreferredAddress", "CLIENT")
xml.__send__(:"casebio:PreferredAddress", "CASE")
xml.__send__(:"casebio:CorrespondenceAddress") { generate_correspondence_address(xml) }
xml.__send__(:"casebio:ProviderDetails") { generate_provider_details(xml) }
xml.__send__(:"casebio:CategoryOfLaw") { generate_category_of_law(xml) }
xml.__send__(:"casebio:OtherParties") { generate_other_parties(xml) }
Expand Down Expand Up @@ -156,6 +157,15 @@ def generate_provider_details(xml)
end
end

def generate_correspondence_address(xml)
xml.__send__(:"common:AddressLine1", applicant.address.address_line_one)
xml.__send__(:"common:AddressLine2", applicant.address.address_line_two)
xml.__send__(:"common:City", applicant.address.city)
xml.__send__(:"common:County", applicant.address.county)
xml.__send__(:"common:Country", "GBR")
xml.__send__(:"common:PostalCode", applicant.address.pretty_postcode)
end

def generate_category_of_law(xml)
xml.__send__(:"casebio:CategoryOfLawCode", @legal_aid_application.lead_proceeding.category_law_code)
xml.__send__(:"casebio:CategoryOfLawDescription", @legal_aid_application.lead_proceeding.category_of_law)
Expand Down
14 changes: 11 additions & 3 deletions spec/data/ccms/case_add_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
<casebio:FirstName>Shery</casebio:FirstName>
<casebio:Surname>Ledner</casebio:Surname>
</casebio:Client>
<casebio:PreferredAddress>CLIENT</casebio:PreferredAddress>
<casebio:PreferredAddress>CASE</casebio:PreferredAddress>
<casebio:CorrespondenceAddress>
<common:AddressLine1>10 Foobar Lane</common:AddressLine1>
<common:AddressLine2>Bluewater</common:AddressLine2>
<common:City>Ipswich</common:City>
<common:County>Essex</common:County>
<common:Country>GBR</common:Country>
<common:PostalCode>GH0 8NY</common:PostalCode>
</casebio:CorrespondenceAddress>
<casebio:ProviderDetails>
<casebio:ProviderFirmID>169</casebio:ProviderFirmID>
<casebio:ProviderOfficeID>4727432767</casebio:ProviderOfficeID>
Expand Down Expand Up @@ -664,7 +672,7 @@
<common:Attribute>
<common:Attribute>POST_CODE</common:Attribute>
<common:ResponseType>text</common:ResponseType>
<common:ResponseValue>GH08NY</common:ResponseValue>
<common:ResponseValue>GH0 8NY</common:ResponseValue>
<common:UserDefinedInd>true</common:UserDefinedInd>
</common:Attribute>
<common:Attribute>
Expand Down Expand Up @@ -1918,7 +1926,7 @@
<common:Attribute>
<common:Attribute>POST_CODE</common:Attribute>
<common:ResponseType>text</common:ResponseType>
<common:ResponseValue>GH08NY</common:ResponseValue>
<common:ResponseValue>GH0 8NY</common:ResponseValue>
<common:UserDefinedInd>true</common:UserDefinedInd>
</common:Attribute>
<common:Attribute>
Expand Down
14 changes: 11 additions & 3 deletions spec/data/ccms/df_case_add_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
<casebio:FirstName>Shery</casebio:FirstName>
<casebio:Surname>Ledner</casebio:Surname>
</casebio:Client>
<casebio:PreferredAddress>CLIENT</casebio:PreferredAddress>
<casebio:PreferredAddress>CASE</casebio:PreferredAddress>
<casebio:CorrespondenceAddress>
<common:AddressLine1>10 Foobar Lane</common:AddressLine1>
<common:AddressLine2>Bluewater</common:AddressLine2>
<common:City>Ipswich</common:City>
<common:County>Essex</common:County>
<common:Country>GBR</common:Country>
<common:PostalCode>GH0 8NY</common:PostalCode>
</casebio:CorrespondenceAddress>
<casebio:ProviderDetails>
<casebio:ProviderFirmID>169</casebio:ProviderFirmID>
<casebio:ProviderOfficeID>4727432767</casebio:ProviderOfficeID>
Expand Down Expand Up @@ -670,7 +678,7 @@
<common:Attribute>
<common:Attribute>POST_CODE</common:Attribute>
<common:ResponseType>text</common:ResponseType>
<common:ResponseValue>GH08NY</common:ResponseValue>
<common:ResponseValue>GH0 8NY</common:ResponseValue>
<common:UserDefinedInd>true</common:UserDefinedInd>
</common:Attribute>
<common:Attribute>
Expand Down Expand Up @@ -1936,7 +1944,7 @@
<common:Attribute>
<common:Attribute>POST_CODE</common:Attribute>
<common:ResponseType>text</common:ResponseType>
<common:ResponseValue>GH08NY</common:ResponseValue>
<common:ResponseValue>GH0 8NY</common:ResponseValue>
<common:UserDefinedInd>true</common:UserDefinedInd>
</common:Attribute>
<common:Attribute>
Expand Down
14 changes: 11 additions & 3 deletions spec/data/ccms/non_default_client_involvement_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
<casebio:FirstName>Shery</casebio:FirstName>
<casebio:Surname>Ledner</casebio:Surname>
</casebio:Client>
<casebio:PreferredAddress>CLIENT</casebio:PreferredAddress>
<casebio:PreferredAddress>CASE</casebio:PreferredAddress>
<casebio:CorrespondenceAddress>
<common:AddressLine1>10 Foobar Lane</common:AddressLine1>
<common:AddressLine2>Bluewater</common:AddressLine2>
<common:City>Ipswich</common:City>
<common:County>Essex</common:County>
<common:Country>GBR</common:Country>
<common:PostalCode>GH0 8NY</common:PostalCode>
</casebio:CorrespondenceAddress>
<casebio:ProviderDetails>
<casebio:ProviderFirmID>169</casebio:ProviderFirmID>
<casebio:ProviderOfficeID>4727432767</casebio:ProviderOfficeID>
Expand Down Expand Up @@ -664,7 +672,7 @@
<common:Attribute>
<common:Attribute>POST_CODE</common:Attribute>
<common:ResponseType>text</common:ResponseType>
<common:ResponseValue>GH08NY</common:ResponseValue>
<common:ResponseValue>GH0 8NY</common:ResponseValue>
<common:UserDefinedInd>true</common:UserDefinedInd>
</common:Attribute>
<common:Attribute>
Expand Down Expand Up @@ -1918,7 +1926,7 @@
<common:Attribute>
<common:Attribute>POST_CODE</common:Attribute>
<common:ResponseType>text</common:ResponseType>
<common:ResponseValue>GH08NY</common:ResponseValue>
<common:ResponseValue>GH0 8NY</common:ResponseValue>
<common:UserDefinedInd>true</common:UserDefinedInd>
</common:Attribute>
<common:Attribute>
Expand Down
16 changes: 0 additions & 16 deletions spec/models/address_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,4 @@
model.postcode = "SW1H9AJ"
expect(model.pretty_postcode).to eq("SW1H 9AJ")
end

context "when the address has lines one and two populated" do
it "first_lines displays the first two lines of the address concatenated" do
model.address_line_one = "102"
model.address_line_two = "Petty France"
expect(model.first_lines).to eq("102 Petty France")
end
end

context "when the address has only line one populated" do
it "first_lines displays only the first line of the address" do
model.address_line_one = "102"
model.address_line_two = nil
expect(model.first_lines).to eq("102")
end
end
end
12 changes: 9 additions & 3 deletions spec/services/ccms/requestors/applicant_add_requestor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ module Requestors

let(:address) do
create(:address,
address_line_one: "102",
address_line_two: "Petty France",
address_line_one: "102 Petty France",
address_line_two: "St James Park",
county: "Westminster",
city: "London",
postcode: "SW1H9AJ")
end
Expand All @@ -33,8 +34,13 @@ module Requestors
command: "clientbim:ClientAddRQ",
transaction_id: expected_tx_id,
matching: [
"<common:AddressLine1>#{applicant.address.address_line_one} #{applicant.address.address_line_two}</common:AddressLine1>",
"<clientbio:NINumber>#{applicant.national_insurance_number}</clientbio:NINumber>",
"<common:AddressLine1>#{applicant.address.address_line_one}</common:AddressLine1>",
"<common:AddressLine2>#{applicant.address.address_line_two}</common:AddressLine2>",
"<common:City>#{applicant.address.city}</common:City>",
"<common:County>#{applicant.address.county}</common:County>",
"<common:Country>GBR</common:Country>",
"<common:PostalCode>SW1H 9AJ</common:PostalCode>",
],
)
end
Expand Down
3 changes: 1 addition & 2 deletions spec/services/ccms/requestors/case_add_requestor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module Requestors

let(:applicant) do
create(:applicant,
:with_address_for_xml_fixture,
first_name: "Shery",
last_name: "Ledner",
national_insurance_number: "EG587804M",
Expand All @@ -48,7 +47,7 @@ module Requestors
trust_value: 600)
end

let(:address) { create(:address, postcode: "GH08NY") }
let(:address) { create(:address, address_line_one: "10 Foobar Lane", address_line_two: "Bluewater", city: "Ipswich", county: "Essex", postcode: "GH08NY") }
let(:provider) { create(:provider, username: "saturnina", firm:, email: "[email protected]") }
let(:firm) { create(:firm, ccms_id: 169) }
let(:opponents) { create_list(:opponent, 1, first_name: "Joffrey", last_name: "Test-Opponent") }
Expand Down
9 changes: 6 additions & 3 deletions spec/services/ccms/submitters/add_applicant_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ module Submitters
matching: [
"<common:Surname>#{applicant.last_name}</common:Surname>",
"<common:FirstName>#{applicant.first_name}</common:FirstName>",
"<common:AddressLine1>#{address.first_lines}</common:AddressLine1>",
"<common:AddressLine1>#{address.address_line_one}</common:AddressLine1>",
"<common:AddressLine2>#{address.address_line_two}</common:AddressLine2>",
"<common:City>#{address.city}</common:City>",
"<common:PostalCode>#{address.postcode}</common:PostalCode>",
],
Expand Down Expand Up @@ -99,7 +100,8 @@ module Submitters
matching: [
"<common:Surname>#{applicant.last_name}</common:Surname>",
"<common:FirstName>#{applicant.first_name}</common:FirstName>",
"<common:AddressLine1>#{address.first_lines}</common:AddressLine1>",
"<common:AddressLine1>#{address.address_line_one}</common:AddressLine1>",
"<common:AddressLine2>#{address.address_line_two}</common:AddressLine2>",
"<common:City>#{address.city}</common:City>",
"<common:PostalCode>#{address.postcode}</common:PostalCode>",
],
Expand Down Expand Up @@ -132,7 +134,8 @@ module Submitters
matching: [
"<common:Surname>#{applicant.last_name}</common:Surname>",
"<common:FirstName>#{applicant.first_name}</common:FirstName>",
"<common:AddressLine1>#{address.first_lines}</common:AddressLine1>",
"<common:AddressLine1>#{address.address_line_one}</common:AddressLine1>",
"<common:AddressLine2>#{address.address_line_two}</common:AddressLine2>",
"<common:City>#{address.city}</common:City>",
"<common:PostalCode>#{address.postcode}</common:PostalCode>",
],
Expand Down
4 changes: 2 additions & 2 deletions spec/services/ccms/submitters/add_case_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module Submitters
command: "casebim:CaseAddRQ",
transaction_id: "20190301030405123456",
matching: [
"<casebio:PreferredAddress>CLIENT</casebio:PreferredAddress>",
"<casebio:PreferredAddress>CASE</casebio:PreferredAddress>",
"<casebio:ProviderOfficeID>#{legal_aid_application.office.ccms_id}</casebio:ProviderOfficeID>",
],
)
Expand Down Expand Up @@ -180,7 +180,7 @@ module Submitters
command: "casebim:CaseAddRQ",
transaction_id: "20190301030405123456",
matching: [
"<casebio:PreferredAddress>CLIENT</casebio:PreferredAddress>",
"<casebio:PreferredAddress>CASE</casebio:PreferredAddress>",
"<casebio:ProviderOfficeID>#{legal_aid_application.office.ccms_id}</casebio:ProviderOfficeID>",
],
)
Expand Down

0 comments on commit 336b0db

Please sign in to comment.