fix find last Transaction

This commit is contained in:
Ulf Gebhardt 2022-12-15 12:41:42 +01:00
parent ef6d697514
commit 1f765bd3f4
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 5 additions and 5 deletions

View File

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

View File

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