From b0516d3194e95283833148e2df1cb704bbd076a4 Mon Sep 17 00:00:00 2001 From: ga128k Date: Tue, 23 Jan 2024 01:05:39 -0600 Subject: [PATCH] fixed pending --- index.ts | 11 ++++++++--- ynab.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 11dbd77..1e5a7ad 100644 --- a/index.ts +++ b/index.ts @@ -74,14 +74,19 @@ import { SaveTransaction, TransactionDetail } from "ynab"; const pendingTransactionsThatPosted: TransactionDetail[] = []; const pendingExistingTransactions = ynabTransactions.filter( - (t) => t.flag_color === "blue" && !t.deleted + (t) => + t.cleared === "uncleared" && + !t.deleted && + readyAccounts.find((account) => account.name === t.account_name) ); for (const existingPendingTransaction of pendingExistingTransactions) { const matchedImportTransaction = importTransactions.find( (t) => t.amount === existingPendingTransaction.amount && - t.payee_name === existingPendingTransaction.import_payee_name && + (!existingPendingTransaction.import_payee_name || + t.payee_name?.trim() === + existingPendingTransaction.import_payee_name.trim()) && Math.abs( new Date(t.date as string).getTime() - new Date(existingPendingTransaction.date as string).getTime() @@ -90,7 +95,7 @@ import { SaveTransaction, TransactionDetail } from "ynab"; ); if ( matchedImportTransaction && - matchedImportTransaction.flag_color === "blue" + matchedImportTransaction.cleared === "uncleared" ) { console.log( `Transaction ${formatTransaction( diff --git a/ynab.ts b/ynab.ts index 1f161fb..84d7cde 100644 --- a/ynab.ts +++ b/ynab.ts @@ -71,7 +71,7 @@ export const convertPendingTransactions = ( const ynabTransactions: SaveTransaction[] = []; pendingTransactions.forEach((t) => { - const amount = ynabAmount(t.amount.toString()); + let amount = ynabAmount(t.amount.toString()); const date = ynabDateFormat(new Date(t.charge_date)); const data: SaveTransaction = {