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:
commit
ac0e938caa
4 changed files with 20 additions and 29 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -163,15 +163,12 @@ 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({
|
|
||||||
pageSize: 1000, // TODO: Check with Teller on max page size
|
|
||||||
fetchData: async () => {
|
|
||||||
const transactions = await SharedUtil.withRetry(
|
const transactions = await SharedUtil.withRetry(
|
||||||
() =>
|
() =>
|
||||||
this.teller.getTransactions({
|
this.teller.getTransactions({
|
||||||
accountId,
|
accountId,
|
||||||
accessToken: accessToken,
|
accessToken,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
maxRetries: 3,
|
maxRetries: 3,
|
||||||
|
@ -179,11 +176,8 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
|
||||||
)
|
)
|
||||||
|
|
||||||
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 ?? ''}
|
||||||
)`
|
)`
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue