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', 'sync-teller-institutions',
{}, {},
{ {
repeat: { cron: '0 0 */1 * *' }, // Run every 24 hours repeat: { cron: '0 */24 * * *' }, // Run every 24 hours
} }
) )

View file

@ -163,27 +163,21 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
private async _extractTransactions(accessToken: string, accountIds: string[]) { private async _extractTransactions(accessToken: string, accountIds: string[]) {
const accountTransactions = await Promise.all( const accountTransactions = await Promise.all(
accountIds.map((accountId) => accountIds.map(async (accountId) => {
SharedUtil.paginate({ const transactions = await SharedUtil.withRetry(
pageSize: 1000, // TODO: Check with Teller on max page size () =>
fetchData: async () => { this.teller.getTransactions({
const transactions = await SharedUtil.withRetry( accountId,
() => accessToken,
this.teller.getTransactions({ }),
accountId, {
accessToken: accessToken, maxRetries: 3,
}), }
{ )
maxRetries: 3,
}
)
return transactions return transactions
}, })
})
)
) )
return accountTransactions.flat() return accountTransactions.flat()
} }
@ -220,10 +214,10 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
${transactionId}, ${transactionId},
${date}::date, ${date}::date,
${description}, ${description},
${DbUtil.toDecimal(-amount)}, ${DbUtil.toDecimal(Number(amount))},
${status === 'pending'}, ${status === 'pending'},
${'USD'}, ${'USD'},
${details.counterparty.name ?? ''}, ${details.counterparty?.name ?? ''},
${type}, ${type},
${details.category ?? ''} ${details.category ?? ''}
)` )`

View file

@ -11,7 +11,7 @@ import { Duration } from 'luxon'
/** /**
* Update this with the max window that Teller supports * 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( export function getAccountBalanceData(
{ balance, currency }: Pick<TellerTypes.AccountWithBalances, 'balance' | 'currency'>, { balance, currency }: Pick<TellerTypes.AccountWithBalances, 'balance' | 'currency'>,
@ -24,14 +24,11 @@ export function getAccountBalanceData(
| 'availableBalanceStrategy' | 'availableBalanceStrategy'
| 'currencyCode' | 'currencyCode'
> { > {
const sign = classification === 'liability' ? -1 : 1
return { return {
currentBalanceProvider: new Prisma.Decimal( currentBalanceProvider: new Prisma.Decimal(balance.ledger ? Number(balance.ledger) : 0),
balance.ledger ? sign * Number(balance.ledger) : 0
),
currentBalanceStrategy: 'current', currentBalanceStrategy: 'current',
availableBalanceProvider: new Prisma.Decimal( availableBalanceProvider: new Prisma.Decimal(
balance.available ? sign * Number(balance.available) : 0 balance.available ? Number(balance.available) : 0
), ),
availableBalanceStrategy: 'available', availableBalanceStrategy: 'available',
currencyCode: currency, currencyCode: currency,

View file

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