diff --git a/apps/engine/src/providers/teller/transform.ts b/apps/engine/src/providers/teller/transform.ts index 7b2b13aae0..fe11e36b9b 100644 --- a/apps/engine/src/providers/teller/transform.ts +++ b/apps/engine/src/providers/teller/transform.ts @@ -91,24 +91,22 @@ export const mapTransactionCategory = ({ type TransformTransactionPayload = { transaction: TransformTransaction; - accountType: AccountType; }; export const transformTransaction = ({ transaction, - accountType, }: TransformTransactionPayload): BaseTransaction => { const method = mapTransactionMethod(transaction.type); - - const amount = formatAmountForAsset({ - amount: +transaction.amount, - type: accountType, - }); + const amount = +transaction.amount; + const description = + (transaction?.details?.counterparty?.name && + capitalCase(transaction.details.counterparty.name)) || + null; return { date: transaction.date, name: transaction.description && capitalCase(transaction.description), - description: null, + description, method, internal_id: transaction.id, amount, diff --git a/apps/website/src/components/hero.tsx b/apps/website/src/components/hero.tsx index e60f880f43..234b9fd1d8 100644 --- a/apps/website/src/components/hero.tsx +++ b/apps/website/src/components/hero.tsx @@ -80,7 +80,7 @@ export function Hero() {
Used by over{" "} - 4000+ + 4100+ {" "} businesses.
diff --git a/packages/jobs/src/transactions/sync.ts b/packages/jobs/src/transactions/sync.ts index c232ea94ef..8e3d1fd582 100644 --- a/packages/jobs/src/transactions/sync.ts +++ b/packages/jobs/src/transactions/sync.ts @@ -76,20 +76,26 @@ client.defineJob({ return null; } - const { error: transactionsError, data: transactionsData } = - await supabase - .from("transactions") - .upsert(transactions, { - onConflict: "internal_id", - ignoreDuplicates: true, - }) - .select("*"); + const { + error: transactionsError, + data: transactionsData, + statusText, + } = await supabase + .from("transactions") + .upsert(transactions, { + onConflict: "internal_id", + }) + .select("*"); if (transactionsError) { await io.logger.error("Transactions error", transactionsError); } - if (transactionsData && transactionsData?.length > 0) { + if ( + statusText === "Created" && + transactionsData && + transactionsData?.length > 0 + ) { await io.sendEvent("🔔 Send notifications", { name: Events.TRANSACTIONS_NOTIFICATION, payload: { diff --git a/packages/providers/src/teller/__snapshots__/transform.test.ts.snap b/packages/providers/src/teller/__snapshots__/transform.test.ts.snap index a03936e49c..1f323e3dbe 100644 --- a/packages/providers/src/teller/__snapshots__/transform.test.ts.snap +++ b/packages/providers/src/teller/__snapshots__/transform.test.ts.snap @@ -2,13 +2,13 @@ exports[`Transform pending transaction 1`] = ` { - "amount": -83.62, + "amount": 83.62, "balance": null, "bank_account_id": "123", - "category": null, + "category": "income", "currency": "USD", "date": "2024-03-05", - "description": null, + "description": "Bank Of Many", "internal_id": "123_txn_os41r5u90e29shubl2000", "method": "other", "name": "Online Check Deposit", @@ -19,10 +19,10 @@ exports[`Transform pending transaction 1`] = ` exports[`Transform card payment transaction 1`] = ` { - "amount": 68.9, + "amount": -68.9, "balance": "83431.46", "bank_account_id": "123", - "category": "income", + "category": null, "currency": "USD", "date": "2024-03-01", "description": null, @@ -36,10 +36,10 @@ exports[`Transform card payment transaction 1`] = ` exports[`Transform income transaction 1`] = ` { - "amount": 20.21, + "amount": -20.21, "balance": "83296.40", "bank_account_id": "123", - "category": "income", + "category": null, "currency": "USD", "date": "2024-03-03", "description": null, @@ -59,7 +59,7 @@ exports[`Transform type transfer 1`] = ` "category": "transfer", "currency": "USD", "date": "2024-01-27", - "description": null, + "description": "Yourself", "internal_id": "123_txn_os41r5ua0e29shubl2001", "method": "transfer", "name": "Recurring Transfer To Savings", diff --git a/packages/providers/src/teller/transform.ts b/packages/providers/src/teller/transform.ts index eff7732093..af9d71b4be 100644 --- a/packages/providers/src/teller/transform.ts +++ b/packages/providers/src/teller/transform.ts @@ -89,23 +89,31 @@ export const mapTransactionCategory = ({ } }; +export const transformDescription = (transaction: Transaction) => { + const description = + transaction?.details?.counterparty?.name && + capitalCase(transaction.details.counterparty.name); + + if (transaction.description !== description && description) { + return capitalCase(description); + } + + return null; +}; + export const transformTransaction = ({ transaction, teamId, bankAccountId, - accountType, }: TransformTransaction): BaseTransaction => { const method = mapTransactionMethod(transaction.type); - - const amount = formatAmountForAsset({ - amount: +transaction.amount, - type: accountType, - }); + const amount = +transaction.amount; + const description = transformDescription(transaction); return { date: transaction.date, name: transaction.description && capitalCase(transaction.description), - description: null, + description, method, internal_id: `${teamId}_${transaction.id}`, amount,