mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
remove unused fields from balance model
This commit is contained in:
parent
997ef9d72a
commit
a6e7036339
@ -5,33 +5,20 @@ import Decimal from 'decimal.js-light'
|
||||
export class Balance {
|
||||
constructor(data: {
|
||||
balance: Decimal
|
||||
decay: Decimal
|
||||
lastBookedBalance: Decimal
|
||||
balanceGDT: number | null
|
||||
count: number
|
||||
linkCount: number
|
||||
lastBookedDate?: Date | null
|
||||
}) {
|
||||
this.balance = data.balance
|
||||
this.decay = data.decay
|
||||
this.lastBookedBalance = data.lastBookedBalance
|
||||
this.balanceGDT = data.balanceGDT || null
|
||||
this.count = data.count
|
||||
this.linkCount = data.linkCount
|
||||
this.lastBookedDate = data.lastBookedDate || null
|
||||
}
|
||||
|
||||
// the actual balance, decay included
|
||||
@Field(() => Decimal)
|
||||
balance: Decimal
|
||||
|
||||
// the decay since the last booked balance
|
||||
@Field(() => Decimal)
|
||||
decay: Decimal
|
||||
|
||||
@Field(() => Decimal)
|
||||
lastBookedBalance: Decimal
|
||||
|
||||
@Field(() => Number, { nullable: true })
|
||||
balanceGDT: number | null
|
||||
|
||||
@ -42,8 +29,4 @@ export class Balance {
|
||||
// the count of transaction links
|
||||
@Field(() => Number)
|
||||
linkCount: number
|
||||
|
||||
// may be null as there may be no transaction
|
||||
@Field(() => Date, { nullable: true })
|
||||
lastBookedDate: Date | null
|
||||
}
|
||||
|
||||
@ -29,8 +29,6 @@ export class BalanceResolver {
|
||||
if (!lastTransaction) {
|
||||
return new Balance({
|
||||
balance: new Decimal(0),
|
||||
decay: new Decimal(0),
|
||||
lastBookedBalance: new Decimal(0),
|
||||
balanceGDT,
|
||||
count: 0,
|
||||
linkCount: 0,
|
||||
@ -69,12 +67,9 @@ export class BalanceResolver {
|
||||
balance: calculatedDecay.balance
|
||||
.minus(sumHoldAvailableAmount.toString())
|
||||
.toDecimalPlaces(2, Decimal.ROUND_DOWN), // round towards zero
|
||||
decay: calculatedDecay.decay.toDecimalPlaces(2, Decimal.ROUND_FLOOR), // round towards - infinity
|
||||
lastBookedBalance: lastTransaction.balance.toDecimalPlaces(2, Decimal.ROUND_DOWN),
|
||||
balanceGDT,
|
||||
count,
|
||||
linkCount,
|
||||
lastBookedDate: lastTransaction.balanceDate,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user