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 new file mode 100644 index 00000000..ebc097b4 --- /dev/null +++ b/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql @@ -0,0 +1,39 @@ +CREATE OR REPLACE VIEW hs_integration.ticket_customer_user AS +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, + 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, + 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, + 1 AS valid + FROM hs_office.partner p + JOIN hs_office.relation AS pRel + ON pRel.type = 'PARTNER' + AND pRel.uuid = p.partnerRelUuid + JOIN hs_office.relation AS dRel + ON dRel.type = 'DEBITOR' + AND dRel.anchorUuid = pRel.holderUuid + JOIN hs_office.debitor AS debitor + ON debitor.debitorreluuid = dRel.uuid + AND debitor.debitornumbersuffix = '00' + JOIN hs_office.relation AS rs1 ON rs1.uuid = p.partnerreluuid AND rs1.type = 'PARTNER' + JOIN hs_office.relation AS relation ON relation.anchoruuid = rs1.holderuuid + JOIN hs_office.contact AS c ON c.uuid = relation.contactuuid + JOIN hs_office.person AS per ON per.uuid = relation.holderuuid +where debitor.defaultprefix != 'hsh' +and relation.type != 'DEBITOR' +group by c.emailaddresses, c.phonenumbers; diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index dda5e0d9..b97e3f2d 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -174,4 +174,6 @@ databaseChangeLog: - include: file: db/changelog/9-hs-global/9100-hs-integration-schema.sql - include: - file: db/changelog/9-hs-global/9110-integration-kimai.sql \ No newline at end of file + file: db/changelog/9-hs-global/9110-integration-kimai.sql + - include: + file: db/changelog/9-hs-global/9120-integration-znuny.sql \ No newline at end of file