From 5ef048fcf9ff2eb560b6d7508aad6b512af655c9 Mon Sep 17 00:00:00 2001 From: Pascal Zumkehr Date: Tue, 10 Dec 2024 17:42:33 +0100 Subject: [PATCH] Transmit postbox and care_of to abacus addresses (HIT-806) --- app/domain/invoices/abacus/subject.rb | 4 +- .../invoices/abacus/subject_interface_spec.rb | 46 ++++++++++++------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/app/domain/invoices/abacus/subject.rb b/app/domain/invoices/abacus/subject.rb index ef21b1588..fbefe33ef 100644 --- a/app/domain/invoices/abacus/subject.rb +++ b/app/domain/invoices/abacus/subject.rb @@ -9,7 +9,7 @@ module Invoices module Abacus class Subject < Entity RELEVANT_ATTRIBUTES = %w[first_name last_name email language gender street - housenumber zip_code town country].freeze + housenumber postbox address_care_of zip_code town country].freeze SALUTATION_IDS = { mister: 1, @@ -76,6 +76,8 @@ def address_attrs # rubocop:disable Metrics/AbcSize subject_id: subject_id, street: entity.street.to_s[0, 50], house_number: entity.housenumber.to_s[0, 9], + post_office_box_text: entity.postbox.to_s[0, 20], + address_supplement: entity.address_care_of.to_s[0, 60], post_code: entity.zip_code[0, 15], city: entity.town.to_s[0, 50], country_id: entity.country || Countries.default.upcase, diff --git a/spec/domain/invoices/abacus/subject_interface_spec.rb b/spec/domain/invoices/abacus/subject_interface_spec.rb index ee056fab3..ab46da110 100644 --- a/spec/domain/invoices/abacus/subject_interface_spec.rb +++ b/spec/domain/invoices/abacus/subject_interface_spec.rb @@ -21,6 +21,8 @@ street: "Belpstrasse", housenumber: "37", zip_code: "3007", + postbox: "Postfach 23", + address_care_of: "c/o Frau Müller", town: "Bern", gender: "w" ) @@ -219,7 +221,17 @@ request: { method: :post, path: "Addresses", - params: {city: "Thun", country_id: "CH", house_number: "", post_code: "3600", street: "", subject_id: 600002, valid_from: Date.current} + params: { + address_supplement: "", + city: "Thun", + country_id: "CH", + house_number: "", + post_code: "3600", + street: "", + post_office_box_text: "", + subject_id: 600002, + valid_from: Date.current + } } ) @@ -262,7 +274,7 @@ def stub_update_subject_request end def stub_create_address_request - body = "{\"SubjectId\":#{person.id},\"Street\":\"Belpstrasse\",\"HouseNumber\":\"37\",\"PostCode\":\"3007\",\"City\":\"Bern\",\"CountryId\":\"CH\",\"ValidFrom\":\"#{today.strftime("%Y-%m-%d")}\"}" + body = "{\"SubjectId\":#{person.id},\"Street\":\"Belpstrasse\",\"HouseNumber\":\"37\",\"PostOfficeBoxText\":\"Postfach 23\",\"AddressSupplement\":\"c/o Frau Müller\",\"PostCode\":\"3007\",\"City\":\"Bern\",\"CountryId\":\"CH\",\"ValidFrom\":\"#{today.strftime("%Y-%m-%d")}\"}" stub_simple_request(:post, "Addresses", body) end @@ -335,8 +347,8 @@ def get_subject_response "@odata.etag" => "W/\"ea2246585da92c0f2789e718fea4dfb29d56005e7d51c6e27cb5994b8838b5b0\"", "Id" => "e65440b5-eb47-9482-21b0-a647a3972e0b", "SubjectId" => person.id, "ValidFrom" => "2024-05-08", "Street" => "Belpstrasse", "HouseNumber" => "37", "City" => "Bern", "PostCode" => "3007", "PostCodeSupplement" => 0, "CountryId" => "CH", "State" => "BE", - "DwellingNumber" => "", "MunicipalityCode" => "351", "BuildingNumber" => 0, "AddressSupplement" => "", "StreetSupplement" => "", - "PostOfficeBoxText" => "", "PostOfficeBoxNumber" => "", "OpenLocationCode" => "", "Coordinates" => nil + "DwellingNumber" => "", "MunicipalityCode" => "351", "BuildingNumber" => 0, "AddressSupplement" => "c/o Frau Müller", "StreetSupplement" => "", + "PostOfficeBoxText" => "Postfach 23", "PostOfficeBoxNumber" => "", "OpenLocationCode" => "", "Coordinates" => nil }], "Communications" => [{ "@odata.etag" => "W/\"f86b82e3bbf253df0eb29c2406cb3619d611d9300d1cd7daa8a3f0403857ad90\"", @@ -430,7 +442,7 @@ def fetch_batch_existing_response Accept: application/json\r \r {"Name":"Hillary","FirstName":"Edmund","Language":"de","SalutationId":2,"Id":600001,\r - "Addresses":[{"Id":"e65440b","SubjectId":600001,"ValidFrom":"2024-05-08","Street":"Belpstrasse","HouseNumber":"37","City":"Bern","PostCode":"3007","CountryId":"CH","State":"BE"}],\r + "Addresses":[{"Id":"e65440b","SubjectId":600001,"ValidFrom":"2024-05-08","Street":"Belpstrasse","HouseNumber":"37","PostOfficeBoxText":"Postfach 23","PostOfficeBoxNumber":"23","StreetSupplement":"","AddressSupplement":"c/o Frau Müller","City":"Bern","PostCode":"3007","CountryId":"CH","State":"BE"}],\r "Communications":[{"Id":"ef83129d","SubjectId":600001,"Type":"EMail","Value":"e.hillary@hitobito.example.com","Category":"Private"}], "Customers":[{"Id":600001,"SubjectId":600001,"Status":"Active"}]}\r --batch-boundary-3f8b206b-4aec-4616-bd28-asdasdfasdf\r @@ -442,7 +454,7 @@ def fetch_batch_existing_response Accept: application/json\r \r {"Name":"Norgay","FirstName":"Tenzing","Language":"de","SalutationId":2,"Id":600002,\r - "Addresses":[{"Id":"e65440b","SubjectId":600002,"ValidFrom":"2024-05-08","Street":"Hauptstrasse","HouseNumber":"1","City":"Thun","PostCode":"3600","CountryId":"CH","State":"BE"}],\r + "Addresses":[{"Id":"e65440b","SubjectId":600002,"ValidFrom":"2024-05-08","Street":"Hauptstrasse","HouseNumber":"1","PostOfficeBoxText":"","PostOfficeBoxNumber":"","StreetSupplement":"","AddressSupplement":"","City":"Thun","PostCode":"3600","CountryId":"CH","State":"BE"}],\r "Communications":[{"Id":"ef83129d","SubjectId":600002,"Type":"EMail","Value":"tenzing@hitobito.example.com","Category":"Private"}], "Customers":[{"Id":600002,"SubjectId":600002,"Status":"Active"}]}\r --batch-boundary-3f8b206b-4aec-4616-bd28-asdasdfasdf\r @@ -454,7 +466,7 @@ def fetch_batch_existing_response Accept: application/json\r \r {"Name":"Norgay","FirstName":"Nima","Language":"de","SalutationId":1,"Id":600004,\r - "Addresses":[{"Id":"e65440b","SubjectId":600004,"ValidFrom":"2024-05-08","Street":"","HouseNumber":"","City":"Thun","PostCode":"3600","CountryId":"CH","State":"BE"}],\r + "Addresses":[{"Id":"e65440b","SubjectId":600004,"ValidFrom":"2024-05-08","Street":"","HouseNumber":"","PostOfficeBoxText":"","PostOfficeBoxNumber":"","StreetSupplement":"","AddressSupplement":"","City":"Thun","PostCode":"3600","CountryId":"CH","State":"BE"}],\r "Communications":[{"Id":"ef83129d","SubjectId":600004,"Type":"EMail","Value":"n.norgay@hitobito.example.com","Category":"Private"}]}\r --batch-boundary-3f8b206b-4aec-4616-bd28-asdasdfasdf--\r HTTP @@ -479,7 +491,7 @@ def fetch_batch_various_response Accept: application/json\r \r {"Name":"Norgay","FirstName":"Tenzing","Language":"de","SalutationId":2,"Id":600002,\r - "Addresses":[{"Id":"e65440b","SubjectId":600002,"ValidFrom":"2024-05-08","Street":"Hauptstrasse","HouseNumber":"1","City":"Thun","PostCode":"3600","CountryId":"CH","State":"BE"}],\r + "Addresses":[{"Id":"e65440b","SubjectId":600002,"ValidFrom":"2024-05-08","Street":"Hauptstrasse","HouseNumber":"1","PostOfficeBoxText":"Postfach 23","AddressSupplement":"c/o Frau Müller","City":"Thun","PostCode":"3600","CountryId":"CH","State":"BE"}],\r "Communications":[{"Id":"ef83129d","SubjectId":600002,"Type":"EMail","Value":"tenzing@hitobito.example.com","Category":"Private"}], "Customers":[{"Id":600002,"SubjectId":600002,"Status":"Active"}]}\r --batch-boundary-3f8b206b-4aec-4616-bd28-asdasdfasdf\r @@ -618,7 +630,7 @@ def create_batch_associations_body Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600001,"Street":"Belpstrasse","HouseNumber":"37","PostCode":"3007","City":"Bern","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600001,"Street":"Belpstrasse","HouseNumber":"37","PostOfficeBoxText":"Postfach 23","AddressSupplement":"c/o Frau Müller","PostCode":"3007","City":"Bern","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-c1ccbe572649\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -645,7 +657,7 @@ def create_batch_associations_body Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600002,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600002,"Street":"","HouseNumber":"","PostOfficeBoxText":"","AddressSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-c1ccbe572649\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -672,7 +684,7 @@ def create_batch_associations_body Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600004,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600004,"Street":"","HouseNumber":"","PostOfficeBoxText":"","AddressSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-c1ccbe572649\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -732,7 +744,7 @@ def create_batch_associations_response Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600002,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600002,"Street":"","HouseNumber":"","PostOfficeBoxText":"","AddressSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-asdasdfasdf\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -759,7 +771,7 @@ def create_batch_associations_response Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600004,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600004,"Street":"","HouseNumber":"","PostOfficeBoxText":"","AddressSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-asdasdfasdf\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -792,7 +804,7 @@ def create_batch_associations_partition_body Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600004,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600004,"Street":"","HouseNumber":"","PostOfficeBoxText":"","AddressSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-c1ccbe572649\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -825,7 +837,7 @@ def create_batch_associations_partition_response Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600004,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600004,"Street":"","HouseNumber":"","PostOfficeBoxText":"","PostOfficeBoxNumber":"","AddressSupplement":"","StreetSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-asdasdfasdf\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -858,7 +870,7 @@ def update_batch_body Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600002,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600002,"Street":"","HouseNumber":"","PostOfficeBoxText":"","AddressSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-c1ccbe572649\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r @@ -938,7 +950,7 @@ def update_batch_partition_body Content-Type: application/json\r Accept: application/json\r \r - {"SubjectId":600002,"Street":"","HouseNumber":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r + {"SubjectId":600002,"Street":"","HouseNumber":"","PostOfficeBoxText":"","AddressSupplement":"","PostCode":"3600","City":"Thun","CountryId":"CH","ValidFrom":"#{today}"}\r --batch-boundary-3f8b206b-4aec-4616-bd28-c1ccbe572649\r Content-Type: application/http\r Content-Transfer-Encoding: binary\r