workaround for the PostgreSQL money column type problem with thousands separator by using numeric

This commit is contained in:
Michael Hoennig 2024-11-14 14:24:30 +01:00
parent 07b5e4686b
commit 5f454a2ebe
2 changed files with 6 additions and 6 deletions

View File

@ -22,7 +22,7 @@ create table if not exists hs_office.coopassettx
membershipUuid uuid not null references hs_office.membership(uuid),
transactionType hs_office.CoopAssetsTransactionType not null,
valueDate date not null,
assetValue money not null,
assetValue numeric(12,2) not null, -- TODO.impl: use money type, but we had problems with Hibernate conversion
reference varchar(48) not null,
revertedAssetTxUuid uuid unique REFERENCES hs_office.coopassettx(uuid) DEFERRABLE INITIALLY DEFERRED,
comment varchar(512)
@ -44,12 +44,12 @@ alter table hs_office.coopassettx
--changeset michael.hoennig:hs-office-coopassets-ASSET-VALUE-CONSTRAINT endDelimiter:--//
-- ----------------------------------------------------------------------------
create or replace function hs_office.coopassetstx_check_positive_total(forMembershipUuid UUID, newAssetValue money)
create or replace function hs_office.coopassetstx_check_positive_total(forMembershipUuid UUID, newAssetValue numeric(12, 5))
returns boolean
language plpgsql as $$
declare
currentAssetValue money;
totalAssetValue money;
currentAssetValue numeric(12,2);
totalAssetValue numeric(12,2);
begin
select sum(cat.assetValue)
from hs_office.coopassettx cat

View File

@ -69,7 +69,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
.membership(givenMembership)
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
.assetValue(new BigDecimal("128.00"))
.assetValue(new BigDecimal("6,400.00"))
.valueDate(LocalDate.parse("2022-10-18"))
.reference("temp ref A")
.build();
@ -98,7 +98,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
.membership(givenMembership)
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
.assetValue(new BigDecimal("128.00"))
.assetValue(new BigDecimal("6400.00"))
.valueDate(LocalDate.parse("2022-10-18"))
.reference("temp ref B")
.build();