From cc0bc986f126c00475e848c7a77728220aafb275 Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Fri, 28 Jun 2024 09:43:25 +0200 Subject: [PATCH 1/4] Update teller amount --- apps/engine/src/providers/teller/transform.ts | 14 ++++++------- .../__snapshots__/transform.test.ts.snap | 20 +++++++++---------- packages/providers/src/teller/transform.ts | 13 ++++++------ 3 files changed, 22 insertions(+), 25 deletions(-) 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/packages/providers/src/teller/__snapshots__/transform.test.ts.snap b/packages/providers/src/teller/__snapshots__/transform.test.ts.snap index a03936e49c..c34b2b912d 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,13 +19,13 @@ 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, + "description": "Nordstrom", "internal_id": "123_txn_os41r5u90e29shubl2005", "method": "card_purchase", "name": "Nordstrom", @@ -36,13 +36,13 @@ 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, + "description": "Exxon Mobil", "internal_id": "123_txn_os41r5u90e29shubl2002", "method": "card_purchase", "name": "Exxon Mobil", @@ -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..107b82d990 100644 --- a/packages/providers/src/teller/transform.ts +++ b/packages/providers/src/teller/transform.ts @@ -93,19 +93,18 @@ 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 = + (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: `${teamId}_${transaction.id}`, amount, From 7af81bae6c43c8e6cade64de5a484c17d3084a3f Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Fri, 28 Jun 2024 09:48:17 +0200 Subject: [PATCH 2/4] Upsert in sync --- packages/jobs/src/transactions/sync.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) 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: { From 97c66c36a0c657dfbd9af301d1438be6f92799dd Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Fri, 28 Jun 2024 10:06:26 +0200 Subject: [PATCH 3/4] Only add description if not the same --- .../teller/__snapshots__/transform.test.ts.snap | 4 ++-- packages/providers/src/teller/transform.ts | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/providers/src/teller/__snapshots__/transform.test.ts.snap b/packages/providers/src/teller/__snapshots__/transform.test.ts.snap index c34b2b912d..1f323e3dbe 100644 --- a/packages/providers/src/teller/__snapshots__/transform.test.ts.snap +++ b/packages/providers/src/teller/__snapshots__/transform.test.ts.snap @@ -25,7 +25,7 @@ exports[`Transform card payment transaction 1`] = ` "category": null, "currency": "USD", "date": "2024-03-01", - "description": "Nordstrom", + "description": null, "internal_id": "123_txn_os41r5u90e29shubl2005", "method": "card_purchase", "name": "Nordstrom", @@ -42,7 +42,7 @@ exports[`Transform income transaction 1`] = ` "category": null, "currency": "USD", "date": "2024-03-03", - "description": "Exxon Mobil", + "description": null, "internal_id": "123_txn_os41r5u90e29shubl2002", "method": "card_purchase", "name": "Exxon Mobil", diff --git a/packages/providers/src/teller/transform.ts b/packages/providers/src/teller/transform.ts index 107b82d990..af9d71b4be 100644 --- a/packages/providers/src/teller/transform.ts +++ b/packages/providers/src/teller/transform.ts @@ -89,6 +89,18 @@ 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, @@ -96,10 +108,7 @@ export const transformTransaction = ({ }: TransformTransaction): BaseTransaction => { const method = mapTransactionMethod(transaction.type); const amount = +transaction.amount; - const description = - (transaction?.details?.counterparty?.name && - capitalCase(transaction.details.counterparty.name)) || - null; + const description = transformDescription(transaction); return { date: transaction.date, From 7168996e161384b0d0c5635c4b33def04528a0d6 Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Fri, 28 Jun 2024 10:07:12 +0200 Subject: [PATCH 4/4] Update hero --- apps/website/src/components/hero.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.