clean up how note tags are used

This commit is contained in:
Robert Dyer
2025-05-06 09:56:07 -05:00
parent 6b26484486
commit 226c8cb5bd
5 changed files with 13 additions and 10 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
const { closeBudget, openBudget, getTransactions, getAccountNote, getAccountBalance, ensurePayee } = require('./utils');
const { closeBudget, openBudget, getTransactions, getAccountNote, getAccountBalance, getTagValue, ensurePayee } = require('./utils');
const api = require('@actual-app/api');
function getValueAtPath(obj, path) {
@@ -51,10 +51,10 @@ async function getBitcoinPrice() {
const cutoffDate = new Date();
cutoffDate.setDate(cutoffDate.getDate() + 1);
const note = await getAccountNote(account, cutoffDate);
if (!note || note.indexOf("BTC:") === -1) {
const btc_amount = parseFloat(getTagValue(note, 'BTC', 0.0));
if (!btc_amount) {
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 = targetBalance - currentBalance;