From 499c82d924ef8f4f7fac6072f018fb2c195d9efb Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 12 Mar 2024 09:12:11 +0100 Subject: [PATCH 1/5] import debitor relationships (still using deprecated entity properties) --- .../office/debitor/HsOfficeDebitorEntity.java | 6 ++--- .../HsOfficeRelationshipType.java | 2 +- .../changelog/220-hs-office-relationship.sql | 2 +- .../hs/office/migration/ImportOfficeData.java | 24 +++++++++++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java index 29a9452d..0f92c6af 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java @@ -116,7 +116,7 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable { JOIN hs_office_relationship partnerRel ON partnerRel.uuid = partner.partnerRoleUUid AND partnerRel.relType = 'PARTNER' JOIN hs_office_relationship debitorRel - ON debitorRel.relAnchorUuid = partnerRel.relHolderUuid AND partnerRel.relType = 'ACCOUNTING' + ON debitorRel.relAnchorUuid = partnerRel.relHolderUuid AND partnerRel.relType = 'DEBITOR' WHERE debitorRel.uuid = debitor.debitorRelUuid) || to_char(debitorNumberSuffix, 'fm00') from hs_office_debitor as debitor @@ -137,7 +137,7 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable { fetchedBySql(""" SELECT * FROM hs_office_relationship AS r - WHERE r.relType = 'ACCOUNTING' AND r.relHolderUuid = ${REF}.debitorRelUuid + WHERE r.relType = 'DEBITOR' AND r.relHolderUuid = ${REF}.debitorRelUuid """), dependsOnColumn("debitorRelUuid")) .createPermission(DELETE).grantedTo("debitorRel", OWNER) @@ -148,7 +148,7 @@ public class HsOfficeDebitorEntity implements HasUuid, Stringifyable { dependsOnColumn("refundBankAccountUuid"), fetchedBySql(""" SELECT * FROM hs_office_relationship AS r - WHERE r.relType = 'ACCOUNTING' AND r.relHolderUuid = ${REF}.debitorRelUuid + WHERE r.relType = 'DEBITOR' AND r.relHolderUuid = ${REF}.debitorRelUuid """) ) .toRole("refundBankAccount", ADMIN).grantRole("debitorRel", AGENT) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipType.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipType.java index 2b9fe60c..57053b1c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipType.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipType.java @@ -6,7 +6,7 @@ public enum HsOfficeRelationshipType { EX_PARTNER, REPRESENTATIVE, VIP_CONTACT, - ACCOUNTING, + DEBITOR, OPERATIONS, SUBSCRIBER } diff --git a/src/main/resources/db/changelog/220-hs-office-relationship.sql b/src/main/resources/db/changelog/220-hs-office-relationship.sql index 44f9e500..a2abece1 100644 --- a/src/main/resources/db/changelog/220-hs-office-relationship.sql +++ b/src/main/resources/db/changelog/220-hs-office-relationship.sql @@ -9,8 +9,8 @@ CREATE TYPE HsOfficeRelationshipType AS ENUM ( 'PARTNER', 'EX_PARTNER', 'REPRESENTATIVE', + 'DEBITOR', 'VIP_CONTACT', - 'ACCOUNTING', 'OPERATIONS', 'SUBSCRIBER'); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index 929aa919..49e218f2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -220,6 +220,23 @@ public class ImportOfficeData extends ContextBasedTest { @Test @Order(1021) + void buildDebitorRelationships() { + debitors.forEach( (id, debitor) -> { + final var debitorRel = HsOfficeRelationshipEntity.builder() + .relType(HsOfficeRelationshipType.DEBITOR) + .relAnchor(debitor.getPartner().getPerson()) + .relHolder(debitor.getPartner().getPerson()) // just 1 debitor/partner in legacy hsadmin + .contact(debitor.getBillingContact()) + .build(); + if (debitorRel.getRelAnchor() != null && debitorRel.getRelHolder() != null && + debitorRel.getContact() != null ) { + relationships.put(relationshipId++, debitorRel); + } + }); + } + + @Test + @Order(1029) void verifyContacts() { assumeThatWeAreImportingControlledTestData(); @@ -289,8 +306,11 @@ public class ImportOfficeData extends ContextBasedTest { 2000013=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP JM GmbH', contact='Frau Tammy Meyer-VIP , JM GmbH'), 2000014=rel(relAnchor='?? Test PS', relType='OPERATIONS', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'), 2000015=rel(relAnchor='?? Test PS', relType='REPRESENTATIVE', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'), - 2000016=rel(relAnchor='NP Mellies, Michael', relType='SUBSCRIBER', relMark='operations-announce', relHolder='NP Fanninga, Frauke', contact='Frau Frauke Fanninga ') - } + 2000016=rel(relAnchor='NP Mellies, Michael', relType='SUBSCRIBER', relMark='operations-announce', relHolder='NP Fanninga, Frauke', contact='Frau Frauke Fanninga '), + 2000017=rel(relAnchor='NP Mellies, Michael', relType='DEBITOR', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '), + 2000018=rel(relAnchor='LP JM GmbH', relType='DEBITOR', relHolder='LP JM GmbH', contact='Frau Dr. Jenny Meyer-Billing , JM GmbH'), + 2000019=rel(relAnchor='?? Test PS', relType='DEBITOR', relHolder='?? Test PS', contact='Petra Schmidt , Test PS') + } """); } -- 2.39.5 From abfcbd8d58e94befcb034517a883c2df5df71cd1 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 12 Mar 2024 09:16:29 +0100 Subject: [PATCH 2/5] veryfy methods on 9 veryfy methods on 9 veryfy methods on 9 --- .../hs/office/migration/ImportOfficeData.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index 49e218f2..cfd9d4d1 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -175,7 +175,7 @@ public class ImportOfficeData extends ContextBasedTest { } @Test - @Order(1011) + @Order(1019) void verifyBusinessPartners() { assumeThatWeAreImportingControlledTestData(); @@ -327,7 +327,7 @@ public class ImportOfficeData extends ContextBasedTest { } @Test - @Order(1031) + @Order(1039) void verifySepaMandates() { assumeThatWeAreImportingControlledTestData(); @@ -359,7 +359,7 @@ public class ImportOfficeData extends ContextBasedTest { } @Test - @Order(1041) + @Order(1049) void verifyCoopShares() { assumeThatWeAreImportingControlledTestData(); @@ -386,7 +386,7 @@ public class ImportOfficeData extends ContextBasedTest { } @Test - @Order(1051) + @Order(1059) void verifyCoopAssets() { assumeThatWeAreImportingControlledTestData(); @@ -418,7 +418,7 @@ public class ImportOfficeData extends ContextBasedTest { } @Test - @Order(2001) + @Order(2009) void removeEmptyRelationships() { assumeThatWeAreImportingControlledTestData(); @@ -431,7 +431,7 @@ public class ImportOfficeData extends ContextBasedTest { idsToRemove.add(id); } }); - assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99 (partner+contractual roles) + assertThat(idsToRemove.size()).isEqualTo(9); // only from partner #99 (partner+contractual roles) idsToRemove.forEach(id -> relationships.remove(id)); } @@ -449,7 +449,7 @@ public class ImportOfficeData extends ContextBasedTest { idsToRemove.add(id); } }); - assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99 + assertThat(idsToRemove.size()).isEqualTo(9); // only from partner #99 idsToRemove.forEach(id -> partners.remove(id)); } @@ -467,7 +467,7 @@ public class ImportOfficeData extends ContextBasedTest { idsToRemove.add(id); } }); - assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99 + assertThat(idsToRemove.size()).isEqualTo(9); // only from partner #99 idsToRemove.forEach(id -> debitors.remove(id)); } -- 2.39.5 From 44bb661e7e0db3908126dcb0f0ce02405fd30acb Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 12 Mar 2024 10:09:01 +0100 Subject: [PATCH 3/5] fix renaming --- .../hsadminng/hs/office/migration/ImportOfficeData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index cfd9d4d1..5559b97c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -431,7 +431,7 @@ public class ImportOfficeData extends ContextBasedTest { idsToRemove.add(id); } }); - assertThat(idsToRemove.size()).isEqualTo(9); // only from partner #99 (partner+contractual roles) + assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99 (partner+contractual roles) idsToRemove.forEach(id -> relationships.remove(id)); } @@ -449,7 +449,7 @@ public class ImportOfficeData extends ContextBasedTest { idsToRemove.add(id); } }); - assertThat(idsToRemove.size()).isEqualTo(9); // only from partner #99 + assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99 idsToRemove.forEach(id -> partners.remove(id)); } -- 2.39.5 From 7e1b645e97e139f097516a872c1dab3fb03fc9ce Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 12 Mar 2024 10:09:09 +0100 Subject: [PATCH 4/5] use getPartnerRole --- .../hsadminng/hs/office/migration/ImportOfficeData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index 5559b97c..756c9618 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -224,8 +224,8 @@ public class ImportOfficeData extends ContextBasedTest { debitors.forEach( (id, debitor) -> { final var debitorRel = HsOfficeRelationshipEntity.builder() .relType(HsOfficeRelationshipType.DEBITOR) - .relAnchor(debitor.getPartner().getPerson()) - .relHolder(debitor.getPartner().getPerson()) // just 1 debitor/partner in legacy hsadmin + .relAnchor(debitor.getPartner().getPartnerRole().getRelHolder()) + .relHolder(debitor.getPartner().getPartnerRole().getRelHolder()) // just 1 debitor/partner in legacy hsadmin .contact(debitor.getBillingContact()) .build(); if (debitorRel.getRelAnchor() != null && debitorRel.getRelHolder() != null && -- 2.39.5 From 38623be54c20b9934580c98f1eb10b8ee6d1976a Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 12 Mar 2024 10:10:54 +0100 Subject: [PATCH 5/5] fix renaming --- .../hsadminng/hs/office/migration/ImportOfficeData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index 756c9618..0c86dc66 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -467,7 +467,7 @@ public class ImportOfficeData extends ContextBasedTest { idsToRemove.add(id); } }); - assertThat(idsToRemove.size()).isEqualTo(9); // only from partner #99 + assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99 idsToRemove.forEach(id -> debitors.remove(id)); } -- 2.39.5