mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
rounding in virtual decay transaction, pass hold available amount to virtual decay creation
This commit is contained in:
parent
9ed00edc52
commit
681d34b1dc
@ -201,7 +201,13 @@ export class TransactionResolver {
|
|||||||
// The virtual decay is always on the booked amount, not including the generated, not yet booked links,
|
// The virtual decay is always on the booked amount, not including the generated, not yet booked links,
|
||||||
// since the decay is substantially different when the amount is less
|
// since the decay is substantially different when the amount is less
|
||||||
transactions.push(
|
transactions.push(
|
||||||
virtualDecayTransaction(lastTransaction.balance, lastTransaction.balanceDate, now, self),
|
virtualDecayTransaction(
|
||||||
|
lastTransaction.balance,
|
||||||
|
lastTransaction.balanceDate,
|
||||||
|
now,
|
||||||
|
self,
|
||||||
|
sumHoldAvailableAmount,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
// virtual transaction for pending transaction-links sum
|
// virtual transaction for pending transaction-links sum
|
||||||
if (sumHoldAvailableAmount.greaterThan(0)) {
|
if (sumHoldAvailableAmount.greaterThan(0)) {
|
||||||
|
|||||||
@ -59,6 +59,7 @@ const virtualDecayTransaction = (
|
|||||||
balanceDate: Date,
|
balanceDate: Date,
|
||||||
time: Date = new Date(),
|
time: Date = new Date(),
|
||||||
user: User,
|
user: User,
|
||||||
|
holdAvailabeAmount: Decimal,
|
||||||
): Transaction => {
|
): Transaction => {
|
||||||
const decay = calculateDecay(balance, balanceDate, time)
|
const decay = calculateDecay(balance, balanceDate, time)
|
||||||
// const balance = decay.balance.minus(lastTransaction.balance)
|
// const balance = decay.balance.minus(lastTransaction.balance)
|
||||||
@ -67,10 +68,12 @@ const virtualDecayTransaction = (
|
|||||||
userId: -1,
|
userId: -1,
|
||||||
previous: -1,
|
previous: -1,
|
||||||
typeId: TransactionTypeId.DECAY,
|
typeId: TransactionTypeId.DECAY,
|
||||||
amount: decay.decay ? decay.decay : new Decimal(0), // new Decimal(0), // this kinda is wrong, but helps with the frontend query
|
amount: decay.decay ? decay.decay.toDecimalPlaces(2, Decimal.ROUND_FLOOR) : new Decimal(0), // new Decimal(0), // this kinda is wrong, but helps with the frontend query
|
||||||
balance: decay.balance,
|
balance: decay.balance
|
||||||
|
.minus(holdAvailabeAmount.toString())
|
||||||
|
.toDecimalPlaces(2, Decimal.ROUND_DOWN),
|
||||||
balanceDate: time,
|
balanceDate: time,
|
||||||
decay: decay.decay ? decay.decay : new Decimal(0),
|
decay: decay.decay ? decay.decay.toDecimalPlaces(2, Decimal.ROUND_FLOOR) : new Decimal(0),
|
||||||
decayStart: decay.start,
|
decayStart: decay.start,
|
||||||
memo: '',
|
memo: '',
|
||||||
creationDate: null,
|
creationDate: null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user