TP-202405-filtered_import #78

Merged
hsh-michaelhoennig merged 7 commits from TP-202405-filtered_import into master 2024-07-16 10:23:16 +02:00
Showing only changes of commit 83e3ed142e - Show all commits

View File

@ -134,6 +134,17 @@ public class ImportOfficeData extends ContextBasedTest {
static int relationId = 2000000;
private static final List<Integer> IGNORE_BUSINESS_PARTNERS = Arrays.asList(
512167, // 11139, partner without contractual contact
512170, // 11142, partner without contractual contact
-1
);
private static final List<Integer> IGNORE_CONTACTS = Arrays.asList(
90547, // Kontakt hat keine Rolle
-1
);
@Value("${spring.datasource.url}")
private String jdbcUrl;
@ -171,7 +182,7 @@ public class ImportOfficeData extends ContextBasedTest {
@Order(1010)
void importBusinessPartners() {
try (Reader reader = resourceReader("migration/business-partners.csv")) {
try (Reader reader = resourceReader("migration.data/business-partners.csv")) {
final var lines = readAllLines(reader);
importBusinessPartners(justHeader(lines), withoutHeader(lines));
} catch (Exception e) {
@ -217,7 +228,7 @@ public class ImportOfficeData extends ContextBasedTest {
@Order(1020)
void importContacts() {
try (Reader reader = resourceReader("migration/contacts.csv")) {
try (Reader reader = resourceReader("migration.data/contacts.csv")) {
final var lines = readAllLines(reader);
importContacts(justHeader(lines), withoutHeader(lines));
} catch (Exception e) {
@ -317,7 +328,7 @@ public class ImportOfficeData extends ContextBasedTest {
@Order(1030)
void importSepaMandates() {
try (Reader reader = resourceReader("migration/sepa-mandates.csv")) {
try (Reader reader = resourceReader("migration.data/sepa-mandates.csv")) {
final var lines = readAllLines(reader);
importSepaMandates(justHeader(lines), withoutHeader(lines));
} catch (Exception e) {
@ -349,7 +360,7 @@ public class ImportOfficeData extends ContextBasedTest {
@Test
@Order(1040)
void importCoopShares() {
try (Reader reader = resourceReader("migration/share-transactions.csv")) {
try (Reader reader = resourceReader("migration.data/share-transactions.csv")) {
final var lines = readAllLines(reader);
importCoopShares(justHeader(lines), withoutHeader(lines));
} catch (Exception e) {
@ -376,7 +387,7 @@ public class ImportOfficeData extends ContextBasedTest {
@Order(1050)
void importCoopAssets() {
try (Reader reader = resourceReader("migration/asset-transactions.csv")) {
try (Reader reader = resourceReader("migration.data/asset-transactions.csv")) {
final var lines = readAllLines(reader);
importCoopAssets(justHeader(lines), withoutHeader(lines));
} catch (Exception e) {
@ -736,6 +747,10 @@ public class ImportOfficeData extends ContextBasedTest {
.map(this::trimAll)
.map(row -> new Record(columns, row))
.forEach(rec -> {
if (this.IGNORE_BUSINESS_PARTNERS.contains(rec.getInteger("bp_id"))) {
return;
}
final var person = HsOfficePersonEntity.builder().build();
final var partnerRel = addRelation(
@ -837,6 +852,11 @@ public class ImportOfficeData extends ContextBasedTest {
.map(row -> new Record(columns, row))
.forEach(rec -> {
final var bpId = rec.getInteger("bp_id");
if (this.IGNORE_BUSINESS_PARTNERS.contains(bpId)) {
return;
}
final var member = ofNullable(memberships.get(bpId))
.orElseGet(() -> createOnDemandMembership(bpId));
@ -907,6 +927,10 @@ public class ImportOfficeData extends ContextBasedTest {
.forEach(rec -> {
final var debitor = debitors.get(rec.getInteger("bp_id"));
if (this.IGNORE_BUSINESS_PARTNERS.contains(rec.getInteger("bp_id"))) {
return;
}
final var sepaMandate = HsOfficeSepaMandateEntity.builder()
.debitor(debitor)
.bankAccount(HsOfficeBankAccountEntity.builder()
@ -938,6 +962,13 @@ public class ImportOfficeData extends ContextBasedTest {
final var contactId = rec.getInteger("contact_id");
final var bpId = rec.getInteger("bp_id");
if (this.IGNORE_CONTACTS.contains(contactId)) {
return;
}
if (this.IGNORE_BUSINESS_PARTNERS.contains(bpId)) {
return;
}
if (rec.getString("roles").isBlank()) {
fail("empty roles assignment not allowed for contact_id: " + contactId);
}