coop-shares-transaction-reverse-entry

This commit is contained in:
Marc O. Sandlus 2024-04-12 11:27:21 +02:00
parent 3d4e853c56
commit 0fda68e01b
4 changed files with 9 additions and 9 deletions

View File

@ -136,9 +136,9 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
}
final BiConsumer<HsOfficeCoopSharesTransactionInsertResource, HsOfficeCoopSharesTransactionEntity> RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> {
if ( resource.getReverseEntryUuid() != null ) {
entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getReverseEntryUuid())
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] reverseEntityUuid %s not found".formatted(resource.getReverseEntryUuid()))));
if ( resource.getAdjustedShareTxUuid() != null ) {
entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getAdjustedShareTxUuid())
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] adjustedShareTxUuid %s not found".formatted(resource.getAdjustedShareTxUuid()))));
}
};
}

View File

@ -73,7 +73,7 @@ components:
maxLength: 48
comment:
type: string
reverseEntryUuid:
adjustedShareTxUuid:
type: string
format: uuid
required:

View File

@ -227,7 +227,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased
"valueDate": "2022-10-30",
"reference": "test ref adjustment",
"comment": "some coop shares adjustment transaction",
"reverseEntryUuid": "%s"
"adjustedShareTxUuid": "%s"
}
""".formatted(
givenMembership.getUuid(),

View File

@ -51,23 +51,23 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
}
@Test
void toShortStringContainsOnlyMemberNumberAndShareCountOnly() {
void toShortStringContainsOnlyAbbreviatedString() {
final var result = givenCoopSharesTransaction.toShortString();
assertThat(result).isEqualTo("M-1000101+4");
assertThat(result).isEqualTo("M-1000101:SUB:+4");
}
@Test
void toStringEmptyTransactionDoesNotThrowException() {
final var result = givenEmptyCoopSharesTransaction.toString();
assertThat(result).isEqualTo("CoopShareTransaction(0)");
assertThat(result).isEqualTo("CoopShareTransaction(null: 0)");
}
@Test
void toShortStringEmptyTransactionDoesNotThrowException() {
final var result = givenEmptyCoopSharesTransaction.toShortString();
assertThat(result).isEqualTo("null+0");
assertThat(result).isEqualTo("null:nul:+0");
}
}