diff --git a/app/models/address.rb b/app/models/address.rb index 2aea0ec638..c61e1450b0 100644 --- a/app/models/address.rb +++ b/app/models/address.rb @@ -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:, diff --git a/app/services/ccms/requestors/applicant_add_requestor.rb b/app/services/ccms/requestors/applicant_add_requestor.rb index 80e7ab2ded..37afcc299a 100644 --- a/app/services/ccms/requestors/applicant_add_requestor.rb +++ b/app/services/ccms/requestors/applicant_add_requestor.rb @@ -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) @@ -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 diff --git a/app/services/ccms/requestors/case_add_requestor.rb b/app/services/ccms/requestors/case_add_requestor.rb index d583c70250..ed8f0a8a0b 100644 --- a/app/services/ccms/requestors/case_add_requestor.rb +++ b/app/services/ccms/requestors/case_add_requestor.rb @@ -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) } @@ -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) diff --git a/spec/data/ccms/case_add_request.xml b/spec/data/ccms/case_add_request.xml index bbac910a65..9e87279916 100644 --- a/spec/data/ccms/case_add_request.xml +++ b/spec/data/ccms/case_add_request.xml @@ -25,7 +25,15 @@ Shery Ledner - CLIENT + CASE + + 10 Foobar Lane + Bluewater + Ipswich + Essex + GBR + GH0 8NY + 169 4727432767 @@ -664,7 +672,7 @@ POST_CODE text - GH08NY + GH0 8NY true @@ -1918,7 +1926,7 @@ POST_CODE text - GH08NY + GH0 8NY true diff --git a/spec/data/ccms/df_case_add_request.xml b/spec/data/ccms/df_case_add_request.xml index 850433fbca..684b873202 100644 --- a/spec/data/ccms/df_case_add_request.xml +++ b/spec/data/ccms/df_case_add_request.xml @@ -25,7 +25,15 @@ Shery Ledner - CLIENT + CASE + + 10 Foobar Lane + Bluewater + Ipswich + Essex + GBR + GH0 8NY + 169 4727432767 @@ -670,7 +678,7 @@ POST_CODE text - GH08NY + GH0 8NY true @@ -1936,7 +1944,7 @@ POST_CODE text - GH08NY + GH0 8NY true diff --git a/spec/data/ccms/non_default_client_involvement_type.xml b/spec/data/ccms/non_default_client_involvement_type.xml index 2b704cf106..7d1c400f38 100644 --- a/spec/data/ccms/non_default_client_involvement_type.xml +++ b/spec/data/ccms/non_default_client_involvement_type.xml @@ -25,7 +25,15 @@ Shery Ledner - CLIENT + CASE + + 10 Foobar Lane + Bluewater + Ipswich + Essex + GBR + GH0 8NY + 169 4727432767 @@ -664,7 +672,7 @@ POST_CODE text - GH08NY + GH0 8NY true @@ -1918,7 +1926,7 @@ POST_CODE text - GH08NY + GH0 8NY true diff --git a/spec/models/address_spec.rb b/spec/models/address_spec.rb index 5088089886..6a76356ee3 100644 --- a/spec/models/address_spec.rb +++ b/spec/models/address_spec.rb @@ -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 diff --git a/spec/services/ccms/requestors/applicant_add_requestor_spec.rb b/spec/services/ccms/requestors/applicant_add_requestor_spec.rb index 1cb532e641..dd21633b3a 100644 --- a/spec/services/ccms/requestors/applicant_add_requestor_spec.rb +++ b/spec/services/ccms/requestors/applicant_add_requestor_spec.rb @@ -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 @@ -33,8 +34,13 @@ module Requestors command: "clientbim:ClientAddRQ", transaction_id: expected_tx_id, matching: [ - "#{applicant.address.address_line_one} #{applicant.address.address_line_two}", + "#{applicant.national_insurance_number}", + "#{applicant.address.address_line_one}", + "#{applicant.address.address_line_two}", "#{applicant.address.city}", + "#{applicant.address.county}", + "GBR", + "SW1H 9AJ", ], ) end diff --git a/spec/services/ccms/requestors/case_add_requestor_spec.rb b/spec/services/ccms/requestors/case_add_requestor_spec.rb index 2583da638e..4baccb1609 100644 --- a/spec/services/ccms/requestors/case_add_requestor_spec.rb +++ b/spec/services/ccms/requestors/case_add_requestor_spec.rb @@ -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", @@ -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: "patrick_rath@example.net") } let(:firm) { create(:firm, ccms_id: 169) } let(:opponents) { create_list(:opponent, 1, first_name: "Joffrey", last_name: "Test-Opponent") } diff --git a/spec/services/ccms/submitters/add_applicant_service_spec.rb b/spec/services/ccms/submitters/add_applicant_service_spec.rb index 2d337e0834..cd86604a3f 100644 --- a/spec/services/ccms/submitters/add_applicant_service_spec.rb +++ b/spec/services/ccms/submitters/add_applicant_service_spec.rb @@ -56,7 +56,8 @@ module Submitters matching: [ "#{applicant.last_name}", "#{applicant.first_name}", - "#{address.first_lines}", + "#{address.address_line_one}", + "#{address.address_line_two}", "#{address.city}", "#{address.postcode}", ], @@ -99,7 +100,8 @@ module Submitters matching: [ "#{applicant.last_name}", "#{applicant.first_name}", - "#{address.first_lines}", + "#{address.address_line_one}", + "#{address.address_line_two}", "#{address.city}", "#{address.postcode}", ], @@ -132,7 +134,8 @@ module Submitters matching: [ "#{applicant.last_name}", "#{applicant.first_name}", - "#{address.first_lines}", + "#{address.address_line_one}", + "#{address.address_line_two}", "#{address.city}", "#{address.postcode}", ], diff --git a/spec/services/ccms/submitters/add_case_service_spec.rb b/spec/services/ccms/submitters/add_case_service_spec.rb index 081c9b09be..6ac31de046 100644 --- a/spec/services/ccms/submitters/add_case_service_spec.rb +++ b/spec/services/ccms/submitters/add_case_service_spec.rb @@ -115,7 +115,7 @@ module Submitters command: "casebim:CaseAddRQ", transaction_id: "20190301030405123456", matching: [ - "CLIENT", + "CASE", "#{legal_aid_application.office.ccms_id}", ], ) @@ -180,7 +180,7 @@ module Submitters command: "casebim:CaseAddRQ", transaction_id: "20190301030405123456", matching: [ - "CLIENT", + "CASE", "#{legal_aid_application.office.ccms_id}", ], )