From a32e0a9d434e75ab5c93f4e93bcdc88bd6d6fc70 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 1 Apr 2022 14:04:01 +0200 Subject: [PATCH] round down decay amount and balance --- backend/src/graphql/model/Decay.ts | 2 +- backend/src/graphql/model/Transaction.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/model/Decay.ts b/backend/src/graphql/model/Decay.ts index f1204e730..ba09702fa 100644 --- a/backend/src/graphql/model/Decay.ts +++ b/backend/src/graphql/model/Decay.ts @@ -11,7 +11,7 @@ export class Decay { duration: number | null, ) { this.balance = balance - this.decay = decay + this.decay = decay.toDecimalPlaces(2, Decimal.ROUND_FLOOR) this.start = start this.end = end this.duration = duration diff --git a/backend/src/graphql/model/Transaction.ts b/backend/src/graphql/model/Transaction.ts index 684224175..d641e038e 100644 --- a/backend/src/graphql/model/Transaction.ts +++ b/backend/src/graphql/model/Transaction.ts @@ -12,8 +12,8 @@ export class Transaction { this.user = user this.previous = transaction.previous this.typeId = transaction.typeId - this.amount = transaction.amount - this.balance = transaction.balance + this.amount = transaction.amount.toDecimalPlaces(2, Decimal.ROUND_DOWN) + 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)