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 #143 from tmyracle/teller-no-sync

Fix: Teller not syncing with live data
This commit is contained in:
Josh Pigford 2024-01-18 11:18:47 -06:00 committed by GitHub
commit ac0e938caa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 29 deletions

View file

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

View file

@ -163,15 +163,12 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
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 () => {
accountIds.map(async (accountId) => {
const transactions = await SharedUtil.withRetry(
() =>
this.teller.getTransactions({
accountId,
accessToken: accessToken,
accessToken,
}),
{
maxRetries: 3,
@ -179,11 +176,8 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
)
return transactions
},
})
)
)
return accountTransactions.flat()
}
@ -220,10 +214,10 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
${transactionId},
${date}::date,
${description},
${DbUtil.toDecimal(-amount)},
${DbUtil.toDecimal(Number(amount))},
${status === 'pending'},
${'USD'},
${details.counterparty.name ?? ''},
${details.counterparty?.name ?? ''},
${type},
${details.category ?? ''}
)`

View file

@ -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<TellerTypes.AccountWithBalances, 'balance' | 'currency'>,
@ -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,

View file

@ -38,7 +38,7 @@ export type Transaction = {
details: {
category?: DetailCategory
processing_status: DetailProcessingStatus
counterparty: {
counterparty?: {
name?: string
type?: 'organization' | 'person'
}