coop-assets-transaction-reverse-entry #37
@ -50,6 +50,7 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, RbacO
|
|||||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue)
|
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue)
|
||||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getReference)
|
.withProp(HsOfficeCoopAssetsTransactionEntity::getReference)
|
||||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getComment)
|
.withProp(HsOfficeCoopAssetsTransactionEntity::getComment)
|
||||||
|
.withProp(at -> ofNullable(at.getReverseEntry()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null))
|
||||||
.quotedValues(false);
|
.quotedValues(false);
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ -93,6 +94,13 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, RbacO
|
|||||||
@Column(name = "comment")
|
@Column(name = "comment")
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionally, the corresponding transaction for an adjustment transaction,
|
||||||
|
* linked in both directions.
|
||||||
|
*/
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "reverseentryuuid")
|
||||||
|
private HsOfficeCoopAssetsTransactionEntity reverseEntry;
|
||||||
|
|
||||||
public String getTaggedMemberNumber() {
|
public String getTaggedMemberNumber() {
|
||||||
return ofNullable(membership).map(HsOfficeMembershipEntity::toShortString).orElse("M-?????");
|
return ofNullable(membership).map(HsOfficeMembershipEntity::toShortString).orElse("M-?????");
|
||||||
|
@ -17,14 +17,15 @@ CREATE CAST (character varying as HsOfficeCoopAssetsTransactionType) WITH INOUT
|
|||||||
|
|
||||||
create table if not exists hs_office_coopassetstransaction
|
create table if not exists hs_office_coopassetstransaction
|
||||||
(
|
(
|
||||||
uuid uuid unique references RbacObject (uuid) initially deferred,
|
uuid uuid unique references RbacObject (uuid) initially deferred,
|
||||||
version int not null default 0,
|
version int not null default 0,
|
||||||
membershipUuid uuid not null references hs_office_membership(uuid),
|
membershipUuid uuid not null references hs_office_membership(uuid),
|
||||||
transactionType HsOfficeCoopAssetsTransactionType not null,
|
transactionType HsOfficeCoopAssetsTransactionType not null,
|
||||||
valueDate date not null,
|
valueDate date not null,
|
||||||
assetValue money,
|
assetValue money not null,
|
||||||
reference varchar(48),
|
reference varchar(48) not null,
|
||||||
comment varchar(512)
|
reverseEntryUuid uuid references hs_office_coopassetstransaction (uuid),
|
||||||
|
comment varchar(512)
|
||||||
);
|
);
|
||||||
--//
|
--//
|
||||||
|
|
||||||
|
@ -16,14 +16,36 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest {
|
|||||||
.valueDate(LocalDate.parse("2020-01-01"))
|
.valueDate(LocalDate.parse("2020-01-01"))
|
||||||
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
|
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
|
||||||
.assetValue(new BigDecimal("128.00"))
|
.assetValue(new BigDecimal("128.00"))
|
||||||
|
.comment("some comment")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
final HsOfficeCoopAssetsTransactionEntity givenCoopAssetAdjustmentTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
|
||||||
|
.membership(TEST_MEMBERSHIP)
|
||||||
|
.reference("some-ref")
|
||||||
|
.valueDate(LocalDate.parse("2020-01-15"))
|
||||||
|
.transactionType(HsOfficeCoopAssetsTransactionType.ADJUSTMENT)
|
||||||
|
.assetValue(new BigDecimal("-128.00"))
|
||||||
|
.comment("some comment")
|
||||||
|
.reverseEntry(givenCoopAssetTransaction)
|
||||||
|
.build();
|
||||||
|
|
||||||
final HsOfficeCoopAssetsTransactionEntity givenEmptyCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder().build();
|
final HsOfficeCoopAssetsTransactionEntity givenEmptyCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder().build();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void toStringContainsAlmostAllPropertiesAccount() {
|
void toStringContainsAllNonNullProperties() {
|
||||||
final var result = givenCoopAssetTransaction.toString();
|
final var result = givenCoopAssetTransaction.toString();
|
||||||
|
|
||||||
assertThat(result).isEqualTo("CoopAssetsTransaction(M-1000101: 2020-01-01, DEPOSIT, 128.00, some-ref)");
|
assertThat(result).isEqualTo("CoopAssetsTransaction(M-1000101: 2020-01-01, DEPOSIT, 128.00, some-ref, some comment)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void toStringWithReverseEntryContainsReverseEntry() {
|
||||||
|
givenCoopAssetTransaction.setReverseEntry(givenCoopAssetAdjustmentTransaction);
|
||||||
|
|
||||||
|
final var result = givenCoopAssetTransaction.toString();
|
||||||
|
|
||||||
|
assertThat(result).isEqualTo("CoopAssetsTransaction(M-1000101: 2020-01-01, DEPOSIT, 128.00, some-ref, some comment, M-1000101:-128.00)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user