coop-assets-transaction-reverse-entry #37

Merged
hsh-michaelhoennig merged 7 commits from coop-assets-transaction-reverse-entry into master 2024-04-10 12:44:57 +02:00
3 changed files with 41 additions and 10 deletions
Showing only changes of commit 1e0583bab2 - Show all commits

View File

@ -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-?????");

View File

@ -22,8 +22,9 @@ create table if not exists hs_office_coopassetstransaction
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,
reverseEntryUuid uuid references hs_office_coopassetstransaction (uuid),
comment varchar(512) comment varchar(512)
); );
--// --//

View File

@ -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