From ef1502c7261c63d3c4d01de1b69bcb42c2a8e64a Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 28 Nov 2024 11:04:39 +0100 Subject: [PATCH] fix for matching asset transactions --- .../hs/migration/BaseOfficeDataImport.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java index 3ab17692..e8e5090f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -880,17 +880,20 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { coopAssets.put(rec.getInteger("member_asset_id"), assetTransaction); }); - coopAssets.values().forEach(assetTransaction -> { + + coopAssets.entrySet().forEach(entry -> { + final var legacyId = entry.getKey(); + final var assetTransaction = entry.getValue(); if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.REVERSAL) { - connectToRelatedRevertedAssetTx(assetTransaction); + connectToRelatedRevertedAssetTx(legacyId, assetTransaction); } if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.TRANSFER) { - connectToRelatedAdoptionAssetTx(assetTransaction); + connectToRelatedAdoptionAssetTx(legacyId, assetTransaction); } }); } - private static void connectToRelatedRevertedAssetTx(final HsOfficeCoopAssetsTransactionEntity assetTransaction) { + private static void connectToRelatedRevertedAssetTx(final int legacyId, final HsOfficeCoopAssetsTransactionEntity assetTransaction) { final var negativeValue = assetTransaction.getAssetValue().negate(); final var revertedAssetTx = coopAssets.values().stream().filter(a -> a.getTransactionType() != HsOfficeCoopAssetsTransactionType.REVERSAL && @@ -903,10 +906,11 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { //revertedAssetTx.setAssetReversalTx(assetTransaction); } - private static void connectToRelatedAdoptionAssetTx(final HsOfficeCoopAssetsTransactionEntity assetTransaction) { + private static void connectToRelatedAdoptionAssetTx(final int legacyId, final HsOfficeCoopAssetsTransactionEntity assetTransaction) { final var negativeValue = assetTransaction.getAssetValue().negate(); final var adoptionAssetTx = coopAssets.values().stream().filter(a -> a.getTransactionType() == HsOfficeCoopAssetsTransactionType.ADOPTION && + (!a.getValueDate().equals(LocalDate.of( 2014 , 12 , 31)) || a.getComment().contains(Integer.toString(assetTransaction.getMembership().getMemberNumber()/100))) && a.getMembership() != assetTransaction.getMembership() && a.getValueDate().equals(assetTransaction.getValueDate()) && a.getAssetValue().equals(negativeValue))