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,