diff --git a/apps/workers/src/main.ts b/apps/workers/src/main.ts index a0cf5e82..890b16d5 100644 --- a/apps/workers/src/main.ts +++ b/apps/workers/src/main.ts @@ -140,7 +140,7 @@ syncInstitutionQueue.add( 'sync-teller-institutions', {}, { - repeat: { cron: '0 0 */1 * *' }, // Run every 24 hours + repeat: { cron: '0 */24 * * *' }, // Run every 24 hours } ) diff --git a/libs/server/features/src/providers/teller/teller.etl.ts b/libs/server/features/src/providers/teller/teller.etl.ts index b81e2a4b..ac4e8315 100644 --- a/libs/server/features/src/providers/teller/teller.etl.ts +++ b/libs/server/features/src/providers/teller/teller.etl.ts @@ -163,27 +163,21 @@ export class TellerETL implements IETL { private async _extractTransactions(accessToken: string, accountIds: string[]) { const accountTransactions = await Promise.all( - accountIds.map((accountId) => - SharedUtil.paginate({ - pageSize: 1000, // TODO: Check with Teller on max page size - fetchData: async () => { - const transactions = await SharedUtil.withRetry( - () => - this.teller.getTransactions({ - accountId, - accessToken: accessToken, - }), - { - maxRetries: 3, - } - ) + accountIds.map(async (accountId) => { + const transactions = await SharedUtil.withRetry( + () => + this.teller.getTransactions({ + accountId, + accessToken, + }), + { + maxRetries: 3, + } + ) - return transactions - }, - }) - ) + return transactions + }) ) - return accountTransactions.flat() } @@ -220,10 +214,10 @@ export class TellerETL implements IETL { ${transactionId}, ${date}::date, ${description}, - ${DbUtil.toDecimal(-amount)}, + ${DbUtil.toDecimal(Number(amount))}, ${status === 'pending'}, ${'USD'}, - ${details.counterparty.name ?? ''}, + ${details.counterparty?.name ?? ''}, ${type}, ${details.category ?? ''} )` diff --git a/libs/server/shared/src/utils/teller-utils.ts b/libs/server/shared/src/utils/teller-utils.ts index ec44700a..6e76cf1b 100644 --- a/libs/server/shared/src/utils/teller-utils.ts +++ b/libs/server/shared/src/utils/teller-utils.ts @@ -11,7 +11,7 @@ import { Duration } from 'luxon' /** * Update this with the max window that Teller supports */ -export const TELLER_WINDOW_MAX = Duration.fromObject({ years: 1 }) +export const TELLER_WINDOW_MAX = Duration.fromObject({ years: 2 }) export function getAccountBalanceData( { balance, currency }: Pick, @@ -24,14 +24,11 @@ export function getAccountBalanceData( | 'availableBalanceStrategy' | 'currencyCode' > { - const sign = classification === 'liability' ? -1 : 1 return { - currentBalanceProvider: new Prisma.Decimal( - balance.ledger ? sign * Number(balance.ledger) : 0 - ), + currentBalanceProvider: new Prisma.Decimal(balance.ledger ? Number(balance.ledger) : 0), currentBalanceStrategy: 'current', availableBalanceProvider: new Prisma.Decimal( - balance.available ? sign * Number(balance.available) : 0 + balance.available ? Number(balance.available) : 0 ), availableBalanceStrategy: 'available', currencyCode: currency, diff --git a/libs/teller-api/src/types/transactions.ts b/libs/teller-api/src/types/transactions.ts index 1d482aa8..cb37111a 100644 --- a/libs/teller-api/src/types/transactions.ts +++ b/libs/teller-api/src/types/transactions.ts @@ -38,7 +38,7 @@ export type Transaction = { details: { category?: DetailCategory processing_status: DetailProcessingStatus - counterparty: { + counterparty?: { name?: string type?: 'organization' | 'person' }