mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fix find last Transaction
This commit is contained in:
parent
ef6d697514
commit
1f765bd3f4
@ -376,7 +376,7 @@ describe('send coins', () => {
|
||||
mutation: sendCoins,
|
||||
variables: {
|
||||
email: 'peter@lustig.de',
|
||||
amount: 50,
|
||||
amount: 10,
|
||||
memo: 'first transaction',
|
||||
},
|
||||
}),
|
||||
@ -392,7 +392,7 @@ describe('send coins', () => {
|
||||
mutation: sendCoins,
|
||||
variables: {
|
||||
email: 'peter@lustig.de',
|
||||
amount: 50,
|
||||
amount: 20,
|
||||
memo: 'second transaction',
|
||||
},
|
||||
}),
|
||||
@ -408,7 +408,7 @@ describe('send coins', () => {
|
||||
mutation: sendCoins,
|
||||
variables: {
|
||||
email: 'peter@lustig.de',
|
||||
amount: 50,
|
||||
amount: 30,
|
||||
memo: 'third transaction',
|
||||
},
|
||||
}),
|
||||
@ -424,7 +424,7 @@ describe('send coins', () => {
|
||||
mutation: sendCoins,
|
||||
variables: {
|
||||
email: 'peter@lustig.de',
|
||||
amount: 50,
|
||||
amount: 40,
|
||||
memo: 'fourth transaction',
|
||||
},
|
||||
}),
|
||||
|
||||
@ -24,7 +24,7 @@ async function calculateBalance(
|
||||
time: Date,
|
||||
transactionLink?: dbTransactionLink | null,
|
||||
): Promise<{ balance: Decimal; decay: Decay; lastTransactionId: number } | null> {
|
||||
const lastTransaction = await Transaction.findOne({ userId }, { order: { balanceDate: 'DESC' } })
|
||||
const lastTransaction = await Transaction.findOne({ userId }, { order: { id: 'DESC' } })
|
||||
if (!lastTransaction) return null
|
||||
|
||||
const decay = calculateDecay(lastTransaction.balance, lastTransaction.balanceDate, time)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user