round decay values in transaction graphql model

This commit is contained in:
Moriz Wahl 2022-04-01 14:13:49 +02:00
parent ff04cf0cb5
commit cc86a81117

View File

@ -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),