Compare commits
2 Commits
cbf68f8657
...
718fde2643
Author | SHA1 | Date | |
---|---|---|---|
|
718fde2643 | ||
|
4736dc0427 |
@ -38,7 +38,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ResponseEntity<List<HsOfficeCoopSharesTransactionResource>> listCoopShares(
|
public ResponseEntity<List<HsOfficeCoopSharesTransactionResource>> getListOfCoopShares(
|
||||||
final String currentSubject,
|
final String currentSubject,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final UUID membershipUuid,
|
final UUID membershipUuid,
|
||||||
@ -57,7 +57,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<HsOfficeCoopSharesTransactionResource> postCoopSharesTransaction(
|
public ResponseEntity<HsOfficeCoopSharesTransactionResource> postNewCoopSharesTransaction(
|
||||||
final String currentSubject,
|
final String currentSubject,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
final HsOfficeCoopSharesTransactionInsertResource requestBody) {
|
final HsOfficeCoopSharesTransactionInsertResource requestBody) {
|
||||||
@ -80,7 +80,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ResponseEntity<HsOfficeCoopSharesTransactionResource> getCoopShareTransactionByUuid(
|
public ResponseEntity<HsOfficeCoopSharesTransactionResource> geSingletCoopShareTransactionByUuid(
|
||||||
final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) {
|
final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) {
|
||||||
|
|
||||||
context.define(currentSubject, assumedRoles);
|
context.define(currentSubject, assumedRoles);
|
||||||
@ -132,8 +132,8 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
|
|||||||
|
|
||||||
final BiConsumer<HsOfficeCoopSharesTransactionInsertResource, HsOfficeCoopSharesTransactionEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
|
final BiConsumer<HsOfficeCoopSharesTransactionInsertResource, HsOfficeCoopSharesTransactionEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
|
||||||
if ( resource.getRevertedShareTxUuid() != null ) {
|
if ( resource.getRevertedShareTxUuid() != null ) {
|
||||||
entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getRevertedShareTxUuid())
|
entity.setRevertedShareTx(coopSharesTransactionRepo.findByUuid(resource.getRevertedShareTxUuid())
|
||||||
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] adjustedShareTxUuid %s not found".formatted(resource.getRevertedShareTxUuid()))));
|
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] revertedShareTxUuid %s not found".formatted(resource.getRevertedShareTxUuid()))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE
|
|||||||
.withProp(HsOfficeCoopSharesTransactionEntity::getShareCount)
|
.withProp(HsOfficeCoopSharesTransactionEntity::getShareCount)
|
||||||
.withProp(HsOfficeCoopSharesTransactionEntity::getReference)
|
.withProp(HsOfficeCoopSharesTransactionEntity::getReference)
|
||||||
.withProp(HsOfficeCoopSharesTransactionEntity::getComment)
|
.withProp(HsOfficeCoopSharesTransactionEntity::getComment)
|
||||||
.withProp(at -> ofNullable(at.getAdjustedShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null))
|
.withProp(at -> ofNullable(at.getRevertedShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null))
|
||||||
.withProp(at -> ofNullable(at.getAdjustmentShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null))
|
.withProp(at -> ofNullable(at.getReversalShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null))
|
||||||
.quotedValues(false);
|
.quotedValues(false);
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ -71,7 +71,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE
|
|||||||
* The signed value which directly affects the booking balance.
|
* The signed value which directly affects the booking balance.
|
||||||
*
|
*
|
||||||
* <p>This means, that a SUBSCRIPTION is always positive, a CANCELLATION is always negative,
|
* <p>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</p> more information.
|
* See {@link HsOfficeCoopSharesTransactionType} for</p> more information.
|
||||||
*/
|
*/
|
||||||
@Column(name = "valuedate")
|
@Column(name = "valuedate")
|
||||||
@ -93,14 +93,14 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE
|
|||||||
private String comment;
|
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
|
@OneToOne
|
||||||
@JoinColumn(name = "adjustedsharetxuuid")
|
@JoinColumn(name = "revertedsharetxuuid")
|
||||||
private HsOfficeCoopSharesTransactionEntity adjustedShareTx;
|
private HsOfficeCoopSharesTransactionEntity revertedShareTx;
|
||||||
|
|
||||||
@OneToOne(mappedBy = "adjustedShareTx")
|
@OneToOne(mappedBy = "revertedShareTx")
|
||||||
private HsOfficeCoopSharesTransactionEntity adjustmentShareTx;
|
private HsOfficeCoopSharesTransactionEntity reversalShareTx;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HsOfficeCoopSharesTransactionEntity load() {
|
public HsOfficeCoopSharesTransactionEntity load() {
|
||||||
|
@ -2,9 +2,9 @@ package net.hostsharing.hsadminng.hs.office.coopshares;
|
|||||||
|
|
||||||
public enum HsOfficeCoopSharesTransactionType {
|
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
|
* shares signed, e.g. with the declaration of accession, value >0
|
||||||
|
@ -6,7 +6,7 @@ components:
|
|||||||
HsOfficeCoopSharesTransactionType:
|
HsOfficeCoopSharesTransactionType:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- ADJUSTMENT # FIXME: rename to REVERSAL
|
- REVERSAL
|
||||||
- SUBSCRIPTION
|
- SUBSCRIPTION
|
||||||
- CANCELLATION
|
- CANCELLATION
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ components:
|
|||||||
HsOfficeReferencedCoopSharesTransaction:
|
HsOfficeReferencedCoopSharesTransaction:
|
||||||
description:
|
description:
|
||||||
Similar to `HsOfficeCoopSharesTransaction` but without the self-referencing properties
|
Similar to `HsOfficeCoopSharesTransaction` but without the self-referencing properties
|
||||||
(`adjustedShareTx` and `adjustmentShareTx`), to avoid recursive JSON.
|
(`revertedShareTx` and `reversalShareTx`), to avoid recursive JSON.
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
uuid:
|
uuid:
|
||||||
|
@ -2,7 +2,7 @@ get:
|
|||||||
tags:
|
tags:
|
||||||
- hs-office-coopShares
|
- hs-office-coopShares
|
||||||
description: 'Fetch a single share transaction by its uuid, if visible for the current subject.'
|
description: 'Fetch a single share transaction by its uuid, if visible for the current subject.'
|
||||||
operationId: getCoopShareTransactionByUuid
|
operationId: geSingletCoopShareTransactionByUuid
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
|
@ -3,7 +3,7 @@ get:
|
|||||||
description: Returns the list of (optionally filtered) cooperative share transactions which are visible to the current subject or any of it's assumed roles.
|
description: Returns the list of (optionally filtered) cooperative share transactions which are visible to the current subject or any of it's assumed roles.
|
||||||
tags:
|
tags:
|
||||||
- hs-office-coopShares
|
- hs-office-coopShares
|
||||||
operationId: listCoopShares
|
operationId: getListOfCoopShares
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
@ -46,7 +46,7 @@ post:
|
|||||||
summary: Adds a new cooperative share transaction.
|
summary: Adds a new cooperative share transaction.
|
||||||
tags:
|
tags:
|
||||||
- hs-office-coopShares
|
- hs-office-coopShares
|
||||||
operationId: postCoopSharesTransaction
|
operationId: postNewCoopSharesTransaction
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
--changeset michael.hoennig:hs-office-coopshares-MAIN-TABLE endDelimiter:--//
|
--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;
|
CREATE CAST (character varying as hs_office.CoopSharesTransactionType) WITH INOUT AS IMPLICIT;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ create table if not exists hs_office.coopsharetx
|
|||||||
valueDate date not null,
|
valueDate date not null,
|
||||||
shareCount integer not null,
|
shareCount integer not null,
|
||||||
reference varchar(48) not null,
|
reference varchar(48) not null,
|
||||||
adjustedShareTxUuid uuid unique REFERENCES hs_office.coopsharetx(uuid) DEFERRABLE INITIALLY DEFERRED,
|
revertedShareTxUuid uuid unique REFERENCES hs_office.coopsharetx(uuid) DEFERRABLE INITIALLY DEFERRED,
|
||||||
comment varchar(512)
|
comment varchar(512)
|
||||||
);
|
);
|
||||||
--//
|
--//
|
||||||
@ -28,8 +28,8 @@ create table if not exists hs_office.coopsharetx
|
|||||||
|
|
||||||
alter table hs_office.coopsharetx
|
alter table hs_office.coopsharetx
|
||||||
add constraint reverse_entry_missing
|
add constraint reverse_entry_missing
|
||||||
check ( transactionType = 'ADJUSTMENT' and adjustedShareTxUuid is not null
|
check ( transactionType = 'REVERSAL' and revertedShareTxUuid is not null
|
||||||
or transactionType <> 'ADJUSTMENT' and adjustedShareTxUuid is null);
|
or transactionType <> 'REVERSAL' and revertedShareTxUuid is null);
|
||||||
--//
|
--//
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
@ -27,12 +27,12 @@ begin
|
|||||||
raise notice 'creating test coopSharesTransaction: %', givenPartnerNumber::text || givenMemberNumberSuffix;
|
raise notice 'creating test coopSharesTransaction: %', givenPartnerNumber::text || givenMemberNumberSuffix;
|
||||||
subscriptionEntryUuid := uuid_generate_v4();
|
subscriptionEntryUuid := uuid_generate_v4();
|
||||||
insert
|
insert
|
||||||
into hs_office.coopsharetx(uuid, membershipuuid, transactiontype, valuedate, sharecount, reference, comment, adjustedShareTxUuid)
|
into hs_office.coopsharetx(uuid, membershipuuid, transactiontype, valuedate, sharecount, reference, comment, revertedShareTxUuid)
|
||||||
values
|
values
|
||||||
(uuid_generate_v4(), membership.uuid, 'SUBSCRIPTION', '2010-03-15', 4, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-1', 'initial subscription', null),
|
(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),
|
(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),
|
(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; $$;
|
end; $$;
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
@ -795,23 +795,23 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
|||||||
? HsOfficeCoopSharesTransactionType.SUBSCRIPTION
|
? HsOfficeCoopSharesTransactionType.SUBSCRIPTION
|
||||||
: "UNSUBSCRIPTION".equals(rec.getString("action"))
|
: "UNSUBSCRIPTION".equals(rec.getString("action"))
|
||||||
? HsOfficeCoopSharesTransactionType.CANCELLATION
|
? HsOfficeCoopSharesTransactionType.CANCELLATION
|
||||||
: HsOfficeCoopSharesTransactionType.ADJUSTMENT
|
: HsOfficeCoopSharesTransactionType.REVERSAL
|
||||||
)
|
)
|
||||||
.shareCount(rec.getInteger("quantity"))
|
.shareCount(rec.getInteger("quantity"))
|
||||||
.comment(rec.getString("comment"))
|
.comment(rec.getString("comment"))
|
||||||
.reference(member.getMemberNumber().toString())
|
.reference(member.getMemberNumber().toString())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (shareTransaction.getTransactionType() == HsOfficeCoopSharesTransactionType.ADJUSTMENT) {
|
if (shareTransaction.getTransactionType() == HsOfficeCoopSharesTransactionType.REVERSAL) {
|
||||||
final var negativeValue = -shareTransaction.getShareCount();
|
final var negativeValue = -shareTransaction.getShareCount();
|
||||||
final var adjustedShareTx = coopShares.values().stream().filter(a ->
|
final var revertedShareTx = coopShares.values().stream().filter(a ->
|
||||||
a.getTransactionType() != HsOfficeCoopSharesTransactionType.ADJUSTMENT &&
|
a.getTransactionType() != HsOfficeCoopSharesTransactionType.REVERSAL &&
|
||||||
a.getMembership() == shareTransaction.getMembership() &&
|
a.getMembership() == shareTransaction.getMembership() &&
|
||||||
a.getShareCount() == negativeValue)
|
a.getShareCount() == negativeValue)
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseThrow(() -> new IllegalStateException(
|
.orElseThrow(() -> new IllegalStateException(
|
||||||
"cannot determine share reverse entry for adjustment " + shareTransaction));
|
"cannot determine share reverse entry for adjustment " + shareTransaction));
|
||||||
shareTransaction.setAdjustedShareTx(adjustedShareTx);
|
shareTransaction.setRevertedShareTx(revertedShareTx);
|
||||||
}
|
}
|
||||||
coopShares.put(rec.getInteger("member_share_id"), shareTransaction);
|
coopShares.put(rec.getInteger("member_share_id"), shareTransaction);
|
||||||
});
|
});
|
||||||
|
@ -62,7 +62,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class ListCoopSharesTransactions {
|
class getListOfCoopSharesTransactions {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canViewAllCoopSharesTransactions() {
|
void globalAdmin_canViewAllCoopSharesTransactions() {
|
||||||
@ -108,21 +108,21 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
"valueDate": "2022-10-20",
|
"valueDate": "2022-10-20",
|
||||||
"reference": "ref 1000202-3",
|
"reference": "ref 1000202-3",
|
||||||
"comment": "some subscription",
|
"comment": "some subscription",
|
||||||
"adjustmentShareTx": {
|
"reversalShareTx": {
|
||||||
"transactionType": "ADJUSTMENT",
|
"transactionType": "REVERSAL",
|
||||||
"shareCount": -2,
|
"shareCount": -2,
|
||||||
"valueDate": "2022-10-21",
|
"valueDate": "2022-10-21",
|
||||||
"reference": "ref 1000202-4",
|
"reference": "ref 1000202-4",
|
||||||
"comment": "some adjustment"
|
"comment": "some reversal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"transactionType": "ADJUSTMENT",
|
"transactionType": "REVERSAL",
|
||||||
"shareCount": -2,
|
"shareCount": -2,
|
||||||
"valueDate": "2022-10-21",
|
"valueDate": "2022-10-21",
|
||||||
"reference": "ref 1000202-4",
|
"reference": "ref 1000202-4",
|
||||||
"comment": "some adjustment",
|
"comment": "some reversal",
|
||||||
"adjustedShareTx": {
|
"revertedShareTx": {
|
||||||
"transactionType": "SUBSCRIPTION",
|
"transactionType": "SUBSCRIPTION",
|
||||||
"shareCount": 2,
|
"shareCount": 2,
|
||||||
"valueDate": "2022-10-20",
|
"valueDate": "2022-10-20",
|
||||||
@ -191,7 +191,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void globalAdmin_canAddCoopSharesAdjustmentTransaction() {
|
void globalAdmin_canAddCoopSharesReversalTransaction() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101);
|
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101);
|
||||||
@ -215,12 +215,12 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"membership.uuid": "%s",
|
"membership.uuid": "%s",
|
||||||
"transactionType": "ADJUSTMENT",
|
"transactionType": "REVERSAL",
|
||||||
"shareCount": %s,
|
"shareCount": %s,
|
||||||
"valueDate": "2022-10-30",
|
"valueDate": "2022-10-30",
|
||||||
"reference": "test ref adjustment",
|
"reference": "test reversal ref",
|
||||||
"comment": "some coop shares adjustment transaction",
|
"comment": "some coop shares reversal transaction",
|
||||||
"adjustedShareTx.uuid": "%s"
|
"revertedShareTx.uuid": "%s"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
givenMembership.getUuid(),
|
givenMembership.getUuid(),
|
||||||
@ -235,12 +235,12 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
|
|||||||
.body("uuid", isUuidValid())
|
.body("uuid", isUuidValid())
|
||||||
.body("", lenientlyEquals("""
|
.body("", lenientlyEquals("""
|
||||||
{
|
{
|
||||||
"transactionType": "ADJUSTMENT",
|
"transactionType": "REVERSAL",
|
||||||
"shareCount": -13,
|
"shareCount": -13,
|
||||||
"valueDate": "2022-10-30",
|
"valueDate": "2022-10-30",
|
||||||
"reference": "test ref adjustment",
|
"reference": "test reversal ref",
|
||||||
"comment": "some coop shares adjustment transaction",
|
"comment": "some coop shares reversal transaction",
|
||||||
"adjustedShareTx": {
|
"revertedShareTx": {
|
||||||
"transactionType": "SUBSCRIPTION",
|
"transactionType": "SUBSCRIPTION",
|
||||||
"shareCount": 13,
|
"shareCount": 13,
|
||||||
"valueDate": "2022-10-20",
|
"valueDate": "2022-10-20",
|
||||||
|
@ -73,7 +73,7 @@ class HsOfficeCoopSharesTransactionControllerRestTest {
|
|||||||
|
|
||||||
SHARES_COUNT_MUST_NOT_BE_NULL(
|
SHARES_COUNT_MUST_NOT_BE_NULL(
|
||||||
requestBody -> requestBody
|
requestBody -> requestBody
|
||||||
.with("transactionType", "ADJUSTMENT")
|
.with("transactionType", "REVERSAL")
|
||||||
.with("shareCount", 0),
|
.with("shareCount", 0),
|
||||||
"[shareCount must not be 0 but is \"0\"]"),
|
"[shareCount must not be 0 but is \"0\"]"),
|
||||||
|
|
||||||
|
@ -20,14 +20,14 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
final HsOfficeCoopSharesTransactionEntity givenCoopShareAdjustmentTransaction = HsOfficeCoopSharesTransactionEntity.builder()
|
final HsOfficeCoopSharesTransactionEntity givenCoopShareReversalTransaction = HsOfficeCoopSharesTransactionEntity.builder()
|
||||||
.membership(TEST_MEMBERSHIP)
|
.membership(TEST_MEMBERSHIP)
|
||||||
.reference("some-ref")
|
.reference("some-ref")
|
||||||
.valueDate(LocalDate.parse("2020-01-15"))
|
.valueDate(LocalDate.parse("2020-01-15"))
|
||||||
.transactionType(HsOfficeCoopSharesTransactionType.ADJUSTMENT)
|
.transactionType(HsOfficeCoopSharesTransactionType.REVERSAL)
|
||||||
.shareCount(-4)
|
.shareCount(-4)
|
||||||
.comment("some comment")
|
.comment("some comment")
|
||||||
.adjustedShareTx(givenCoopSharesTransaction)
|
.revertedShareTx(givenCoopSharesTransaction)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final HsOfficeCoopSharesTransactionEntity givenEmptyCoopSharesTransaction = HsOfficeCoopSharesTransactionEntity.builder().build();
|
final HsOfficeCoopSharesTransactionEntity givenEmptyCoopSharesTransaction = HsOfficeCoopSharesTransactionEntity.builder().build();
|
||||||
@ -41,11 +41,11 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void toStringWithReverseEntryContainsReverseEntry() {
|
void toStringWithReverseEntryContainsReverseEntry() {
|
||||||
givenCoopSharesTransaction.setAdjustedShareTx(givenCoopShareAdjustmentTransaction);
|
givenCoopSharesTransaction.setRevertedShareTx(givenCoopShareReversalTransaction);
|
||||||
|
|
||||||
final var result = givenCoopSharesTransaction.toString();
|
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
|
@Test
|
||||||
|
@ -141,18 +141,18 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
|||||||
result,
|
result,
|
||||||
"CoopShareTransaction(M-1000101: 2010-03-15, SUBSCRIPTION, 4, ref 1000101-1, initial subscription)",
|
"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: 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-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:REV:-2)",
|
||||||
"CoopShareTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -2, ref 1000101-4, some adjustment, M-1000101:SUB:+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: 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: 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-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:REV:-2)",
|
||||||
"CoopShareTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -2, ref 1000202-4, some adjustment, M-1000202:SUB:+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: 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: 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-20, SUBSCRIPTION, 2, ref 1000303-3, some subscription, M-1000303:REV:-2)",
|
||||||
"CoopShareTransaction(M-1000303: 2022-10-21, ADJUSTMENT, -2, ref 1000303-4, some adjustment, M-1000303:SUB:+2)");
|
"CoopShareTransaction(M-1000303: 2022-10-21, REVERSAL, -2, ref 1000303-4, some reversal, M-1000303:SUB:+2)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -172,8 +172,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
|||||||
result,
|
result,
|
||||||
"CoopShareTransaction(M-1000202: 2010-03-15, SUBSCRIPTION, 4, ref 1000202-1, initial subscription)",
|
"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: 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-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:REV:-2)",
|
||||||
"CoopShareTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -2, ref 1000202-4, some adjustment, M-1000202:SUB:+2)");
|
"CoopShareTransaction(M-1000202: 2022-10-21, REVERSAL, -2, ref 1000202-4, some reversal, M-1000202:SUB:+2)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -210,8 +210,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
|||||||
result,
|
result,
|
||||||
"CoopShareTransaction(M-1000101: 2010-03-15, SUBSCRIPTION, 4, ref 1000101-1, initial subscription)",
|
"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: 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-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:REV:-2)",
|
||||||
"CoopShareTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -2, ref 1000101-4, some adjustment, M-1000101:SUB:+2)");
|
"CoopShareTransaction(M-1000101: 2022-10-21, REVERSAL, -2, ref 1000101-4, some reversal, M-1000101:SUB:+2)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransacti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
given("transactionType", "ADJUSTMENT");
|
given("transactionType", "REVERSAL");
|
||||||
given("shareCount", -100);
|
given("shareCount", -100);
|
||||||
given("revertedShareTx", uuid("CoopShares-Transaction with incorrect shareCount"));
|
given("revertedShareTx", uuid("CoopShares-Transaction with incorrect shareCount"));
|
||||||
return super.run();
|
return super.run();
|
||||||
|
Loading…
Reference in New Issue
Block a user