Skip to content

Commit

Permalink
fixed pending
Browse files Browse the repository at this point in the history
  • Loading branch information
ga128k committed Jan 23, 2024
1 parent a687374 commit b0516d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -90,7 +95,7 @@ import { SaveTransaction, TransactionDetail } from "ynab";
);
if (
matchedImportTransaction &&
matchedImportTransaction.flag_color === "blue"
matchedImportTransaction.cleared === "uncleared"
) {
console.log(
`Transaction ${formatTransaction(
Expand Down
2 changes: 1 addition & 1 deletion ynab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit b0516d3

Please sign in to comment.