1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 07:25:19 +02:00

Merge pull request #184 from tmyracle/fix-txn-sign

Fix transaction sign
This commit is contained in:
Josh Pigford 2024-01-20 12:16:52 -06:00 committed by GitHub
commit 4b007713a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 7 deletions

View file

@ -1,4 +1,5 @@
import type { AccountConnection, PrismaClient } from '@prisma/client'
import { AccountClassification } from '@prisma/client'
import type { Logger } from 'winston'
import { AccountUtil, SharedUtil, type SharedType } from '@maybe-finance/shared'
import type { TellerApi, TellerTypes } from '@maybe-finance/teller-api'
@ -164,6 +165,12 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
private async _extractTransactions(accessToken: string, accountIds: string[]) {
const accountTransactions = await Promise.all(
accountIds.map(async (accountId) => {
const account = await this.prisma.account.findFirst({
where: {
tellerAccountId: accountId,
},
})
const transactions = await SharedUtil.withRetry(
() =>
this.teller.getTransactions({
@ -174,6 +181,11 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
maxRetries: 3,
}
)
if (account!.classification === AccountClassification.asset) {
transactions.forEach((t) => {
t.amount = String(Number(t.amount) * -1)
})
}
return transactions
})

View file

@ -1,10 +1,6 @@
import {
Prisma,
AccountCategory,
AccountType,
type Account,
type AccountClassification,
} from '@prisma/client'
import { Prisma, AccountCategory, AccountType } from '@prisma/client'
import type { AccountClassification } from '@prisma/client'
import type { Account } from '@prisma/client'
import type { TellerTypes } from '@maybe-finance/teller-api'
import { Duration } from 'luxon'