mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +02:00
fix sign
This commit is contained in:
parent
df7e83efe7
commit
14b45aee2b
2 changed files with 16 additions and 8 deletions
|
@ -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<Connection, TellerRawData, TellerData> {
|
|||
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<Connection, TellerRawData, TellerData> {
|
|||
maxRetries: 3,
|
||||
}
|
||||
)
|
||||
if (account!.classification === AccountClassification.liability) {
|
||||
transactions.forEach((t) => {
|
||||
t.amount = String(Number(t.amount) * -1)
|
||||
})
|
||||
}
|
||||
|
||||
return transactions
|
||||
})
|
||||
|
@ -214,7 +226,7 @@ export class TellerETL implements IETL<Connection, TellerRawData, TellerData> {
|
|||
${transactionId},
|
||||
${date}::date,
|
||||
${description},
|
||||
${DbUtil.toDecimal(Number(amount))},
|
||||
${DbUtil.toDecimal(Number(-amount))},
|
||||
${status === 'pending'},
|
||||
${'USD'},
|
||||
${details.counterparty?.name ?? ''},
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue