import-debitor-relationship (into intermediate data structure) #22

Merged
hsh-michaelhoennig merged 5 commits from import-debitor-relationship into master 2024-03-12 10:13:37 +01:00
4 changed files with 32 additions and 12 deletions

View File

@ -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)

View File

@ -6,7 +6,7 @@ public enum HsOfficeRelationshipType {
EX_PARTNER,
REPRESENTATIVE,
VIP_CONTACT,
ACCOUNTING,
DEBITOR,
OPERATIONS,
SUBSCRIBER
}

View File

@ -9,8 +9,8 @@ CREATE TYPE HsOfficeRelationshipType AS ENUM (
'PARTNER',
'EX_PARTNER',
'REPRESENTATIVE',
'DEBITOR',
'VIP_CONTACT',
'ACCOUNTING',
'OPERATIONS',
'SUBSCRIBER');

View File

@ -175,7 +175,7 @@ public class ImportOfficeData extends ContextBasedTest {
}
@Test
@Order(1011)
@Order(1019)
void verifyBusinessPartners() {
assumeThatWeAreImportingControlledTestData();
@ -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().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 &&
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')
}
""");
}
@ -307,7 +327,7 @@ public class ImportOfficeData extends ContextBasedTest {
}
@Test
@Order(1031)
@Order(1039)
void verifySepaMandates() {
assumeThatWeAreImportingControlledTestData();
@ -339,7 +359,7 @@ public class ImportOfficeData extends ContextBasedTest {
}
@Test
@Order(1041)
@Order(1049)
void verifyCoopShares() {
assumeThatWeAreImportingControlledTestData();
@ -366,7 +386,7 @@ public class ImportOfficeData extends ContextBasedTest {
}
@Test
@Order(1051)
@Order(1059)
void verifyCoopAssets() {
assumeThatWeAreImportingControlledTestData();
@ -398,7 +418,7 @@ public class ImportOfficeData extends ContextBasedTest {
}
@Test
@Order(2001)
@Order(2009)
void removeEmptyRelationships() {
assumeThatWeAreImportingControlledTestData();