diff --git a/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql b/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql index 7c8f0d7e..adaa1ce4 100644 --- a/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql +++ b/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql @@ -9,19 +9,20 @@ SELECT max(p.partnernumber::text) as number, max(debitor.defaultprefix) as code, c.emailaddresses->>'main' as login, - max(per.salutation) as salut, - max(per.givenname) as firstname, - max(per.familyname) as lastname, - max(per.title) as title, - max(per.tradename) as firma, - max(c.postaladdress->>'co') as co, + (CASE WHEN max(per.salutation) <> '' THEN max(per.salutation) ELSE NULL END) as salut, + (CASE WHEN max(per.givenname) <> '' THEN max(per.givenname) ELSE NULL END) as firstname, + (CASE WHEN max(per.familyname) <> '' THEN max(per.familyname) ELSE NULL END) as lastname, + (CASE WHEN max(per.title) <> '' THEN max(per.title) ELSE NULL END) as title, + (CASE WHEN max(per.tradename) <> '' THEN max(per.tradename) ELSE NULL END) as firma, + (CASE WHEN max(c.postaladdress->>'co') <> '' THEN max(c.postaladdress->>'co') ELSE NULL END) as co, max(c.postaladdress->>'street') as street, max(c.postaladdress->>'zipcode') as zipcode, max(c.postaladdress->>'city') as city, max(c.postaladdress->>'country') as country, - c.phonenumbers->>'phone_office' as phoneoffice, + concat_ws(', '::text, c.phonenumbers->>'phone_office', c.phonenumbers->>'phone_private') AS phone, + c.phonenumbers->>'phone_office' as phone_office, + c.phonenumbers->>'phone_private' as phone_private, c.phonenumbers->>'phone_mobile' as mobile, - c.phonenumbers->>'phone_private' as phoneprivate, c.phonenumbers->>'fax' as fax, c.emailaddresses->>'main' as email, string_agg(CASE WHEN relation.mark IS NULL THEN relation.type::text ELSE CONCAT(relation.type::text, ':', relation.mark::text) END, '/'::text) AS comment,