1
0

add-reverse-mapping-for-assetsharestx-adjustment ()

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/38
Reviewed-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net>
This commit is contained in:
Michael Hoennig
2024-04-11 10:08:45 +02:00
parent f5de2a8850
commit 216886e5f4
6 changed files with 46 additions and 23 deletions

@@ -51,6 +51,7 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, RbacO
.withProp(HsOfficeCoopAssetsTransactionEntity::getReference)
.withProp(HsOfficeCoopAssetsTransactionEntity::getComment)
.withProp(at -> ofNullable(at.getAdjustedAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null))
.withProp(at -> ofNullable(at.getAdjustmentAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null))
.quotedValues(false);
@Id
@@ -101,8 +102,11 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, RbacO
@JoinColumn(name = "adjustedassettxuuid")
private HsOfficeCoopAssetsTransactionEntity adjustedAssetTx;
@OneToOne(mappedBy = "adjustedAssetTx")
private HsOfficeCoopAssetsTransactionEntity adjustmentAssetTx;
public String getTaggedMemberNumber() {
return ofNullable(membership).map(HsOfficeMembershipEntity::toShortString).orElse("M-?????");
return ofNullable(membership).map(HsOfficeMembershipEntity::toShortString).orElse("M-???????");
}
@Override
@@ -112,7 +116,10 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, RbacO
@Override
public String toShortString() {
return "%s:%+1.2f".formatted(getTaggedMemberNumber(), Optional.ofNullable(assetValue).orElse(BigDecimal.ZERO));
return "%s:%.3s:%+1.2f".formatted(
getTaggedMemberNumber(),
transactionType,
ofNullable(assetValue).orElse(BigDecimal.ZERO));
}
public static RbacView rbac() {

@@ -33,12 +33,14 @@ components:
comment:
type: string
adjustedAssetTx:
$ref: '#/components/schemas/HsOfficeAdjustedCoopAssetsTransaction'
$ref: '#/components/schemas/HsOfficeReferencedCoopAssetsTransaction'
adjustmentAssetTx:
$ref: '#/components/schemas/HsOfficeReferencedCoopAssetsTransaction'
HsOfficeAdjustedCoopAssetsTransaction:
HsOfficeReferencedCoopAssetsTransaction:
description:
Similar to `HsOfficeCoopAssetsTransaction` but without the `reverseEntry`,
otherwise the JSON would be recursive.
Similar to `HsOfficeCoopAssetsTransaction` but without the self-referencing properties
(`adjustedAssetTx` and `adjustmentAssetTx`), to avoid recursive JSON.
type: object
properties:
uuid: