From 6db3587fab5d8312b5c50099894d5e6922f23524 Mon Sep 17 00:00:00 2001 From: Robert Dyer Date: Tue, 4 Mar 2025 19:25:00 -0600 Subject: [PATCH] fixes #20 - bitcoin sync was negated and ignoring transactions from today --- sync-bitcoin.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sync-bitcoin.js b/sync-bitcoin.js index 1ab5a3e..ead09d1 100644 --- a/sync-bitcoin.js +++ b/sync-bitcoin.js @@ -48,14 +48,16 @@ async function getBitcoinPrice() { if (account.closed) { continue; } - const note = await getAccountNote(account); + const cutoffDate = new Date(); + cutoffDate.setDate(cutoffDate.getDate() + 1); + const note = await getAccountNote(account, cutoffDate); if (!note || note.indexOf("BTC:") === -1) { continue; } const btc_amount = note.split('BTC:')[1].split(' ')[0]; const currentBalance = await getAccountBalance(account); const targetBalance = Math.round(bitcoinPrice * btc_amount * 100); - const diff = currentBalance - targetBalance; + const diff = targetBalance - currentBalance; if (diff != 0) { await api.importTransactions(account.id, [{ date: new Date(),