fixes #20 - bitcoin sync was negated and ignoring transactions from today
This commit is contained in:
+4
-2
@@ -48,14 +48,16 @@ async function getBitcoinPrice() {
|
|||||||
if (account.closed) {
|
if (account.closed) {
|
||||||
continue;
|
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) {
|
if (!note || note.indexOf("BTC:") === -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const btc_amount = note.split('BTC:')[1].split(' ')[0];
|
const btc_amount = note.split('BTC:')[1].split(' ')[0];
|
||||||
const currentBalance = await getAccountBalance(account);
|
const currentBalance = await getAccountBalance(account);
|
||||||
const targetBalance = Math.round(bitcoinPrice * btc_amount * 100);
|
const targetBalance = Math.round(bitcoinPrice * btc_amount * 100);
|
||||||
const diff = currentBalance - targetBalance;
|
const diff = targetBalance - currentBalance;
|
||||||
if (diff != 0) {
|
if (diff != 0) {
|
||||||
await api.importTransactions(account.id, [{
|
await api.importTransactions(account.id, [{
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
|
|||||||
Reference in New Issue
Block a user