Skip to content

Commit

Permalink
Only add description if not the same
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Jun 28, 2024
1 parent 7af81ba commit 97c66c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
17 changes: 13 additions & 4 deletions packages/providers/src/teller/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,26 @@ 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,
}: 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,
Expand Down

0 comments on commit 97c66c3

Please sign in to comment.