persist shares+assets

This commit is contained in:
Michael Hoennig 2024-01-08 13:48:31 +01:00
parent 53d46da49a
commit 7e31e95d57
4 changed files with 32 additions and 20 deletions

View File

@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.hs.office.coopassets;
import lombok.*;
import net.hostsharing.hsadminng.errors.DisplayName;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
import net.hostsharing.hsadminng.repository.HasUuid;
import net.hostsharing.hsadminng.stringify.Stringify;
import net.hostsharing.hsadminng.stringify.Stringifyable;
import org.hibernate.annotations.GenericGenerator;
@ -23,7 +24,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
@NoArgsConstructor
@AllArgsConstructor
@DisplayName("CoopAssetsTransaction")
public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable {
public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUuid {
private static Stringify<HsOfficeCoopAssetsTransactionEntity> stringify = stringify(HsOfficeCoopAssetsTransactionEntity.class)
.withProp(e -> e.getMembership().getMemberNumber())

View File

@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.hs.office.coopshares;
import lombok.*;
import net.hostsharing.hsadminng.errors.DisplayName;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
import net.hostsharing.hsadminng.repository.HasUuid;
import net.hostsharing.hsadminng.stringify.Stringify;
import net.hostsharing.hsadminng.stringify.Stringifyable;
@ -20,7 +21,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
@NoArgsConstructor
@AllArgsConstructor
@DisplayName("CoopShareTransaction")
public class HsOfficeCoopSharesTransactionEntity implements Stringifyable {
public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUuid {
private static Stringify<HsOfficeCoopSharesTransactionEntity> stringify = stringify(HsOfficeCoopSharesTransactionEntity.class)
.withProp(e -> e.getMembership().getMemberNumber())

View File

@ -231,11 +231,9 @@ public class ImportOfficeTables extends ContextBasedTest {
assertThat(coopAssets.toString()).isEqualToIgnoringWhitespace("""
{
30000=CoopAssetsTransaction(10007, 2000-12-06, DEPOSIT, 1280.00, for subscription A),
31001=CoopAssetsTransaction(10010, 2000-12-06, DEPOSIT, 18.00, for subscription B),
31002=CoopAssetsTransaction(10010, 2000-12-06, -18.00, for subscription B),
31003=CoopAssetsTransaction(10010, 2000-12-06, DEPOSIT, 128.00, for subscription B),
31000=CoopAssetsTransaction(10010, 2000-12-06, DEPOSIT, 128.00, for subscription B),
32000=CoopAssetsTransaction(10007, 2005-01-10, DEPOSIT, 2560.00, for subscription C),
33001=CoopAssetsTransaction(10007, 2005-01-10, -512.00, for transfer to 10),
33001=CoopAssetsTransaction(10007, 2005-01-10, TRANSFER, -512.00, for transfer to 10),
33002=CoopAssetsTransaction(10010, 2005-01-10, ADOPTION, 512.00, for transfer from 7),
34001=CoopAssetsTransaction(10010, 2016-12-31, CLEARING, -8.00, for cancellation D),
34002=CoopAssetsTransaction(10010, 2016-12-31, DISBURSAL, -100.00, for cancellation D),
@ -267,7 +265,11 @@ public class ImportOfficeTables extends ContextBasedTest {
sepaMandates.forEach((id, mandate) -> em.persist(mandate));
updateLegacyIds(sepaMandates, "hs_office_sepamandate_legacy_id", "sepa_mandate_id");
// TODO: coopshares+coopassets
coopShares.forEach((id, shareTransaction) -> em.persist(shareTransaction));
updateLegacyIds(coopShares, "hs_office_coopsharestransaction_legacy_id", "member_share_id");
coopAssets.forEach((id, assetTransaction) -> em.persist(assetTransaction));
updateLegacyIds(coopShares, "hs_office_coopassetstransaction_legacy_id", "member_asset_id");
em.flush();
}
@ -392,15 +394,25 @@ public class ImportOfficeTables extends ContextBasedTest {
.forEach(rec -> {
final var member = memberships.get(rec.getInteger("bp_id"));
final var assetTypeMapping = new HashMap<String, HsOfficeCoopAssetsTransactionType>() {{
put("HANDOVER", HsOfficeCoopAssetsTransactionType.TRANSFER);
put("ADOPTION", HsOfficeCoopAssetsTransactionType.ADOPTION);
put("LOSS", HsOfficeCoopAssetsTransactionType.LOSS);
put("CLEARING", HsOfficeCoopAssetsTransactionType.CLEARING);
put("PRESCRIPTION", HsOfficeCoopAssetsTransactionType.LIMITATION);
put("PAYBACK", HsOfficeCoopAssetsTransactionType.DISBURSAL);
put("PAYMENT", HsOfficeCoopAssetsTransactionType.DEPOSIT);
}};
final var assetTypeMapping = new HashMap<String, HsOfficeCoopAssetsTransactionType>() {
{
put("HANDOVER", HsOfficeCoopAssetsTransactionType.TRANSFER);
put("ADOPTION", HsOfficeCoopAssetsTransactionType.ADOPTION);
put("LOSS", HsOfficeCoopAssetsTransactionType.LOSS);
put("CLEARING", HsOfficeCoopAssetsTransactionType.CLEARING);
put("PRESCRIPTION", HsOfficeCoopAssetsTransactionType.LIMITATION);
put("PAYBACK", HsOfficeCoopAssetsTransactionType.DISBURSAL);
put("PAYMENT", HsOfficeCoopAssetsTransactionType.DEPOSIT);
}
public HsOfficeCoopAssetsTransactionType get(final String key) {
final var value = super.get(key);
if ( value != null ) {
return value;
}
throw new IllegalStateException("no mapping value found for: " + key);
}
};
final var assetTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
.membership(member)

View File

@ -1,10 +1,8 @@
member_asset_id; bp_id; date; action; amount; comment
30000; 7; 2000-12-06; PAYMENT; 1280.00; for subscription A
31001; 10; 2000-12-06; PAYMENT; 18.00; for subscription B
31002; 10; 2000-12-06; ADJUSTMENT; -18.00; for subscription B
31003; 10; 2000-12-06; PAYMENT; 128.00; for subscription B
31000; 10; 2000-12-06; PAYMENT; 128.00; for subscription B
32000; 7; 2005-01-10; PAYMENT; 2560.00; for subscription C
33001; 7; 2005-01-10; TRANSFER; -512.00; for transfer to 10
33001; 7; 2005-01-10; HANDOVER; -512.00; for transfer to 10
33002; 10; 2005-01-10; ADOPTION; 512.00; for transfer from 7
34001; 10; 2016-12-31; CLEARING; -8.00; for cancellation D
34002; 10; 2016-12-31; PAYBACK; -100.00; for cancellation D

1 member_asset_id bp_id date action amount comment
2 30000 7 2000-12-06 PAYMENT 1280.00 for subscription A
3 31001 31000 10 2000-12-06 PAYMENT 18.00 128.00 for subscription B
31002 10 2000-12-06 ADJUSTMENT -18.00 for subscription B
31003 10 2000-12-06 PAYMENT 128.00 for subscription B
4 32000 7 2005-01-10 PAYMENT 2560.00 for subscription C
5 33001 7 2005-01-10 TRANSFER HANDOVER -512.00 for transfer to 10
6 33002 10 2005-01-10 ADOPTION 512.00 for transfer from 7
7 34001 10 2016-12-31 CLEARING -8.00 for cancellation D
8 34002 10 2016-12-31 PAYBACK -100.00 for cancellation D