fix billable and general boolean recognition in ImportOfficeData

This commit is contained in:
Michael Hoennig 2024-01-30 17:52:35 +01:00
parent 572061b3cf
commit 901e9a4868

View File

@ -50,6 +50,7 @@ import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.lang.Boolean.parseBoolean;
import static java.util.Arrays.stream; import static java.util.Arrays.stream;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange;
@ -681,7 +682,7 @@ public class ImportOfficeData extends ContextBasedTest {
.debitorNumberSuffix((byte) 0) .debitorNumberSuffix((byte) 0)
.defaultPrefix(rec.getString("member_code").replace("hsh00-", "")) .defaultPrefix(rec.getString("member_code").replace("hsh00-", ""))
.partner(partner) .partner(partner)
.billable(rec.isEmpty("free")) .billable(rec.isEmpty("free") || rec.getString("free").equals("f"))
.vatReverseCharge(rec.getBoolean("exempt_vat")) .vatReverseCharge(rec.getBoolean("exempt_vat"))
.vatBusiness("GROSS".equals(rec.getString("indicator_vat"))) // TODO: remove .vatBusiness("GROSS".equals(rec.getString("indicator_vat"))) // TODO: remove
.vatId(rec.getString("uid_vat")) .vatId(rec.getString("uid_vat"))
@ -888,7 +889,9 @@ public class ImportOfficeData extends ContextBasedTest {
final var contractualMissing = new HashSet<Integer>(); final var contractualMissing = new HashSet<Integer>();
partners.forEach( (id, partner) -> { partners.forEach( (id, partner) -> {
final var partnerPerson = partner.getPerson(); final var partnerPerson = partner.getPerson();
if (relationships.values().stream().filter(rel -> rel.getRelHolder() == partnerPerson && rel.getRelType() == HsOfficeRelationshipType.REPRESENTATIVE).findFirst().isEmpty()) { if (relationships.values().stream()
.filter(rel -> rel.getRelHolder() == partnerPerson && rel.getRelType() == HsOfficeRelationshipType.REPRESENTATIVE)
.findFirst().isEmpty()) {
addRelationship(partnerPerson, partnerPerson, partner.getContact(), HsOfficeRelationshipType.REPRESENTATIVE); addRelationship(partnerPerson, partnerPerson, partner.getContact(), HsOfficeRelationshipType.REPRESENTATIVE);
contractualMissing.add(partner.getPartnerNumber()); contractualMissing.add(partner.getPartnerNumber());
} }
@ -1145,7 +1148,8 @@ class Record {
boolean getBoolean(final String columnName) { boolean getBoolean(final String columnName) {
final String value = getString(columnName); final String value = getString(columnName);
return isNotBlank(value) && Boolean.parseBoolean(value.trim()); return isNotBlank(value) &&
( parseBoolean(value.trim()) || value.trim().startsWith("t"));
} }
Integer getInteger(final String columnName) { Integer getInteger(final String columnName) {