diff --git a/libs/server/features/src/providers/teller/teller.etl.ts b/libs/server/features/src/providers/teller/teller.etl.ts index ac4e8315..6891de97 100644 --- a/libs/server/features/src/providers/teller/teller.etl.ts +++ b/libs/server/features/src/providers/teller/teller.etl.ts @@ -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 { 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 { maxRetries: 3, } ) + if (account!.classification === AccountClassification.asset) { + transactions.forEach((t) => { + t.amount = String(Number(t.amount) * -1) + }) + } return transactions }) diff --git a/libs/server/shared/src/utils/teller-utils.ts b/libs/server/shared/src/utils/teller-utils.ts index 6e76cf1b..32102afb 100644 --- a/libs/server/shared/src/utils/teller-utils.ts +++ b/libs/server/shared/src/utils/teller-utils.ts @@ -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'