From cc86a81117cc51b4906642912fad27a190aa9f29 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 1 Apr 2022 14:13:49 +0200 Subject: [PATCH] round decay values in transaction graphql model --- backend/src/graphql/model/Transaction.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index d641e038e..0ffb4c0bd 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -16,11 +16,18 @@ export class Transaction { this.balance = transaction.balance.balance.toDecimalPlaces(2, Decimal.ROUND_DOWN) this.balanceDate = transaction.balanceDate if (!transaction.decayStart) { - this.decay = new Decay(transaction.balance, new Decimal(0), null, null, null) + // TODO: hot fix, we should separate decay calculation from decay graphql model + this.decay = new Decay( + transaction.balance.toDecimalPlaces(2, Decimal.ROUND_DOWN), + new Decimal(0), + null, + null, + null, + ) } else { this.decay = new Decay( - transaction.balance, - transaction.decay, + transaction.balance.toDecimalPlaces(2, Decimal.ROUND_DOWN), + transaction.decay.toDecimalPlaces(2, Decimal.ROUND_FLOOR), transaction.decayStart, transaction.balanceDate, Math.round((transaction.balanceDate.getTime() - transaction.decayStart.getTime()) / 1000),