From 718fde26432f047133064f25195cdf037b1fc162 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 07:08:29 +0100 Subject: [PATCH] adjust naming in CoopShares regarding ADJUSTMENT->REVERSAL --- .../HsOfficeCoopSharesTransactionEntity.java | 4 ++-- .../HsOfficeCoopSharesTransactionType.java | 4 ++-- .../hs-office-coopshares-schemas.yaml | 2 +- .../5110-hs-office-coopshares.sql | 6 ++--- .../5118-hs-office-coopshares-test-data.sql | 2 +- .../hs/migration/BaseOfficeDataImport.java | 6 ++--- ...esTransactionControllerAcceptanceTest.java | 22 +++++++++---------- ...opSharesTransactionControllerRestTest.java | 2 +- ...ceCoopSharesTransactionEntityUnitTest.java | 8 +++---- ...sTransactionRepositoryIntegrationTest.java | 20 ++++++++--------- .../CreateCoopSharesRevertTransaction.java | 2 +- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java index 3be9373f..54787ad7 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java @@ -71,7 +71,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE * The signed value which directly affects the booking balance. * *

This means, that a SUBSCRIPTION is always positive, a CANCELLATION is always negative, - * but an ADJUSTMENT can bei either positive or negative. + * but an REVERSAL can bei either positive or negative. * See {@link HsOfficeCoopSharesTransactionType} for

more information. */ @Column(name = "valuedate") @@ -93,7 +93,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE private String comment; /** - * Optionally, the UUID of the corresponding transaction for an adjustment transaction. + * Optionally, the UUID of the corresponding transaction for a REVERSAL transaction. */ @OneToOne @JoinColumn(name = "revertedsharetxuuid") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java index bcd46cb3..0a9b3176 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java @@ -2,9 +2,9 @@ package net.hostsharing.hsadminng.hs.office.coopshares; public enum HsOfficeCoopSharesTransactionType { /** - * correction of wrong bookings, with either positive or negative value + * reversal of wrong bookings, with either positive or negative value identical to reversed transaction */ - ADJUSTMENT, + REVERSAL, /** * shares signed, e.g. with the declaration of accession, value >0 diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml index ce5b25cc..8d190634 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml @@ -6,7 +6,7 @@ components: HsOfficeCoopSharesTransactionType: type: string enum: - - ADJUSTMENT # FIXME: rename to REVERSAL + - REVERSAL - SUBSCRIPTION - CANCELLATION diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql index e8845f51..2aa6fe72 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql @@ -4,7 +4,7 @@ --changeset michael.hoennig:hs-office-coopshares-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -CREATE TYPE hs_office.CoopSharesTransactionType AS ENUM ('ADJUSTMENT', 'SUBSCRIPTION', 'CANCELLATION'); +CREATE TYPE hs_office.CoopSharesTransactionType AS ENUM ('REVERSAL', 'SUBSCRIPTION', 'CANCELLATION'); CREATE CAST (character varying as hs_office.CoopSharesTransactionType) WITH INOUT AS IMPLICIT; @@ -28,8 +28,8 @@ create table if not exists hs_office.coopsharetx alter table hs_office.coopsharetx add constraint reverse_entry_missing - check ( transactionType = 'ADJUSTMENT' and revertedShareTxUuid is not null - or transactionType <> 'ADJUSTMENT' and revertedShareTxUuid is null); + check ( transactionType = 'REVERSAL' and revertedShareTxUuid is not null + or transactionType <> 'REVERSAL' and revertedShareTxUuid is null); --// -- ============================================================================ diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql index 0050e244..e7229595 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql @@ -32,7 +32,7 @@ begin (uuid_generate_v4(), membership.uuid, 'SUBSCRIPTION', '2010-03-15', 4, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-1', 'initial subscription', null), (uuid_generate_v4(), membership.uuid, 'CANCELLATION', '2021-09-01', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-2', 'cancelling some', null), (subscriptionEntryUuid, membership.uuid, 'SUBSCRIPTION', '2022-10-20', 2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-3', 'some subscription', null), - (uuid_generate_v4(), membership.uuid, 'ADJUSTMENT', '2022-10-21', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-4', 'some adjustment', subscriptionEntryUuid); + (uuid_generate_v4(), membership.uuid, 'REVERSAL', '2022-10-21', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-4', 'some reversal', subscriptionEntryUuid); end; $$; --// 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 ec4c7fec..626e4613 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -795,17 +795,17 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { ? HsOfficeCoopSharesTransactionType.SUBSCRIPTION : "UNSUBSCRIPTION".equals(rec.getString("action")) ? HsOfficeCoopSharesTransactionType.CANCELLATION - : HsOfficeCoopSharesTransactionType.ADJUSTMENT + : HsOfficeCoopSharesTransactionType.REVERSAL ) .shareCount(rec.getInteger("quantity")) .comment(rec.getString("comment")) .reference(member.getMemberNumber().toString()) .build(); - if (shareTransaction.getTransactionType() == HsOfficeCoopSharesTransactionType.ADJUSTMENT) { + if (shareTransaction.getTransactionType() == HsOfficeCoopSharesTransactionType.REVERSAL) { final var negativeValue = -shareTransaction.getShareCount(); final var revertedShareTx = coopShares.values().stream().filter(a -> - a.getTransactionType() != HsOfficeCoopSharesTransactionType.ADJUSTMENT && + a.getTransactionType() != HsOfficeCoopSharesTransactionType.REVERSAL && a.getMembership() == shareTransaction.getMembership() && a.getShareCount() == negativeValue) .findAny() diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java index e07ac85b..c2e6a11f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java @@ -109,19 +109,19 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased "reference": "ref 1000202-3", "comment": "some subscription", "reversalShareTx": { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": -2, "valueDate": "2022-10-21", "reference": "ref 1000202-4", - "comment": "some adjustment" + "comment": "some reversal" } }, { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": -2, "valueDate": "2022-10-21", "reference": "ref 1000202-4", - "comment": "some adjustment", + "comment": "some reversal", "revertedShareTx": { "transactionType": "SUBSCRIPTION", "shareCount": 2, @@ -191,7 +191,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased } @Test - void globalAdmin_canAddCoopSharesAdjustmentTransaction() { + void globalAdmin_canAddCoopSharesReversalTransaction() { context.define("superuser-alex@hostsharing.net"); final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101); @@ -215,11 +215,11 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased .body(""" { "membership.uuid": "%s", - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": %s, "valueDate": "2022-10-30", - "reference": "test ref adjustment", - "comment": "some coop shares adjustment transaction", + "reference": "test reversal ref", + "comment": "some coop shares reversal transaction", "revertedShareTx.uuid": "%s" } """.formatted( @@ -235,11 +235,11 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased .body("uuid", isUuidValid()) .body("", lenientlyEquals(""" { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": -13, "valueDate": "2022-10-30", - "reference": "test ref adjustment", - "comment": "some coop shares adjustment transaction", + "reference": "test reversal ref", + "comment": "some coop shares reversal transaction", "revertedShareTx": { "transactionType": "SUBSCRIPTION", "shareCount": 13, diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java index 7024c668..821e8871 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java @@ -73,7 +73,7 @@ class HsOfficeCoopSharesTransactionControllerRestTest { SHARES_COUNT_MUST_NOT_BE_NULL( requestBody -> requestBody - .with("transactionType", "ADJUSTMENT") + .with("transactionType", "REVERSAL") .with("shareCount", 0), "[shareCount must not be 0 but is \"0\"]"), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java index 8179f40e..3ec158f4 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java @@ -20,11 +20,11 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { .build(); - final HsOfficeCoopSharesTransactionEntity givenCoopShareAdjustmentTransaction = HsOfficeCoopSharesTransactionEntity.builder() + final HsOfficeCoopSharesTransactionEntity givenCoopShareReversalTransaction = HsOfficeCoopSharesTransactionEntity.builder() .membership(TEST_MEMBERSHIP) .reference("some-ref") .valueDate(LocalDate.parse("2020-01-15")) - .transactionType(HsOfficeCoopSharesTransactionType.ADJUSTMENT) + .transactionType(HsOfficeCoopSharesTransactionType.REVERSAL) .shareCount(-4) .comment("some comment") .revertedShareTx(givenCoopSharesTransaction) @@ -41,11 +41,11 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { @Test void toStringWithReverseEntryContainsReverseEntry() { - givenCoopSharesTransaction.setRevertedShareTx(givenCoopShareAdjustmentTransaction); + givenCoopSharesTransaction.setRevertedShareTx(givenCoopShareReversalTransaction); final var result = givenCoopSharesTransaction.toString(); - assertThat(result).isEqualTo("CoopShareTransaction(M-1000101: 2020-01-01, SUBSCRIPTION, 4, some-ref, some comment, M-1000101:ADJ:-4)"); + assertThat(result).isEqualTo("CoopShareTransaction(M-1000101: 2020-01-01, SUBSCRIPTION, 4, some-ref, some comment, M-1000101:REV:-4)"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java index ac74bee6..613ccc2b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java @@ -141,18 +141,18 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase result, "CoopShareTransaction(M-1000101: 2010-03-15, SUBSCRIPTION, 4, ref 1000101-1, initial subscription)", "CoopShareTransaction(M-1000101: 2021-09-01, CANCELLATION, -2, ref 1000101-2, cancelling some)", - "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:ADJ:-2)", - "CoopShareTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -2, ref 1000101-4, some adjustment, M-1000101:SUB:+2)", + "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:REV:-2)", + "CoopShareTransaction(M-1000101: 2022-10-21, REVERSAL, -2, ref 1000101-4, some reversal, M-1000101:SUB:+2)", "CoopShareTransaction(M-1000202: 2010-03-15, SUBSCRIPTION, 4, ref 1000202-1, initial subscription)", "CoopShareTransaction(M-1000202: 2021-09-01, CANCELLATION, -2, ref 1000202-2, cancelling some)", - "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:ADJ:-2)", - "CoopShareTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -2, ref 1000202-4, some adjustment, M-1000202:SUB:+2)", + "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:REV:-2)", + "CoopShareTransaction(M-1000202: 2022-10-21, REVERSAL, -2, ref 1000202-4, some reversal, M-1000202:SUB:+2)", "CoopShareTransaction(M-1000303: 2010-03-15, SUBSCRIPTION, 4, ref 1000303-1, initial subscription)", "CoopShareTransaction(M-1000303: 2021-09-01, CANCELLATION, -2, ref 1000303-2, cancelling some)", - "CoopShareTransaction(M-1000303: 2022-10-20, SUBSCRIPTION, 2, ref 1000303-3, some subscription, M-1000303:ADJ:-2)", - "CoopShareTransaction(M-1000303: 2022-10-21, ADJUSTMENT, -2, ref 1000303-4, some adjustment, M-1000303:SUB:+2)"); + "CoopShareTransaction(M-1000303: 2022-10-20, SUBSCRIPTION, 2, ref 1000303-3, some subscription, M-1000303:REV:-2)", + "CoopShareTransaction(M-1000303: 2022-10-21, REVERSAL, -2, ref 1000303-4, some reversal, M-1000303:SUB:+2)"); } @Test @@ -172,8 +172,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase result, "CoopShareTransaction(M-1000202: 2010-03-15, SUBSCRIPTION, 4, ref 1000202-1, initial subscription)", "CoopShareTransaction(M-1000202: 2021-09-01, CANCELLATION, -2, ref 1000202-2, cancelling some)", - "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:ADJ:-2)", - "CoopShareTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -2, ref 1000202-4, some adjustment, M-1000202:SUB:+2)"); + "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:REV:-2)", + "CoopShareTransaction(M-1000202: 2022-10-21, REVERSAL, -2, ref 1000202-4, some reversal, M-1000202:SUB:+2)"); } @Test @@ -210,8 +210,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase result, "CoopShareTransaction(M-1000101: 2010-03-15, SUBSCRIPTION, 4, ref 1000101-1, initial subscription)", "CoopShareTransaction(M-1000101: 2021-09-01, CANCELLATION, -2, ref 1000101-2, cancelling some)", - "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:ADJ:-2)", - "CoopShareTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -2, ref 1000101-4, some adjustment, M-1000101:SUB:+2)"); + "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:REV:-2)", + "CoopShareTransaction(M-1000101: 2022-10-21, REVERSAL, -2, ref 1000101-4, some reversal, M-1000101:SUB:+2)"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java index fc7fb6b9..06ef4101 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java @@ -19,7 +19,7 @@ public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransacti @Override protected HttpResponse run() { - given("transactionType", "ADJUSTMENT"); + given("transactionType", "REVERSAL"); given("shareCount", -100); given("revertedShareTx", uuid("CoopShares-Transaction with incorrect shareCount")); return super.run();