clean up how note tags are used
This commit is contained in:
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
const api = require('@actual-app/api');
|
const api = require('@actual-app/api');
|
||||||
const { closeBudget, ensurePayee, getAccountBalance, getAccountNote, getLastTransactionDate, openBudget, showPercent } = require('./utils');
|
const { closeBudget, ensurePayee, getAccountBalance, getAccountNote, getLastTransactionDate, getTagValue, openBudget, showPercent } = require('./utils');
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
@@ -17,8 +17,8 @@ require("dotenv").config();
|
|||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
if (note.indexOf('interestRate:') > -1 && note.indexOf('interestDay:') > -1) {
|
if (note.indexOf('interestRate:') > -1 && note.indexOf('interestDay:') > -1) {
|
||||||
let interestRate = parseFloat(note.split('interestRate:')[1].split(' ')[0]);
|
let interestRate = parseFloat(getTagValue(note, 'interestRate'));
|
||||||
const interestDay = parseInt(note.split('interestDay:')[1].split(' ')[0]);
|
const interestDay = parseInt(getTagValue(note, 'interestDay'));
|
||||||
|
|
||||||
const interestTransactionDate = new Date();
|
const interestTransactionDate = new Date();
|
||||||
if (interestTransactionDate.getDate() < interestDay) {
|
if (interestTransactionDate.getDate() < interestDay) {
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ async function getRentCast(URL) {
|
|||||||
|
|
||||||
let ownership = 1;
|
let ownership = 1;
|
||||||
if (note.indexOf('ownership:') > -1) {
|
if (note.indexOf('ownership:') > -1) {
|
||||||
ownership = parseFloat(note.split('ownership:')[1].split(' ')[0]);
|
ownership = parseFloat(getTagValue(note, 'ownership'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Fetching RentCast for account:', account.name);
|
console.log('Fetching RentCast for account:', account.name);
|
||||||
|
|||||||
+3
-3
@@ -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');
|
const api = require('@actual-app/api');
|
||||||
|
|
||||||
function getValueAtPath(obj, path) {
|
function getValueAtPath(obj, path) {
|
||||||
@@ -51,10 +51,10 @@ async function getBitcoinPrice() {
|
|||||||
const cutoffDate = new Date();
|
const cutoffDate = new Date();
|
||||||
cutoffDate.setDate(cutoffDate.getDate() + 1);
|
cutoffDate.setDate(cutoffDate.getDate() + 1);
|
||||||
const note = await getAccountNote(account, cutoffDate);
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
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 = targetBalance - currentBalance;
|
const diff = targetBalance - currentBalance;
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ const Utils = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTagValue: function (note, tag, defaultValue=undefined) {
|
getTagValue: function (note, tag, defaultValue=undefined) {
|
||||||
|
if (!note) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
tag += ':'
|
tag += ':'
|
||||||
const tagIndex = note.indexOf(tag);
|
const tagIndex = note.indexOf(tag);
|
||||||
if (tagIndex === -1) {
|
if (tagIndex === -1) {
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
const { Builder, Browser, By, until } = require('selenium-webdriver')
|
const { Builder, Browser, By, until } = require('selenium-webdriver')
|
||||||
const api = require('@actual-app/api');
|
const api = require('@actual-app/api');
|
||||||
const { closeBudget, ensurePayee, getAccountBalance, getAccountNote, openBudget, showPercent, sleep } = require('./utils');
|
const { closeBudget, ensurePayee, getAccountBalance, getAccountNote, getTagValue, openBudget, showPercent, sleep } = require('./utils');
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
|
|
||||||
async function getZestimate(URL) {
|
async function getZestimate(URL) {
|
||||||
@@ -43,11 +43,11 @@ async function getZestimate(URL) {
|
|||||||
const note = await getAccountNote(account);
|
const note = await getAccountNote(account);
|
||||||
|
|
||||||
if (note && note.indexOf('zestimate:') > -1) {
|
if (note && note.indexOf('zestimate:') > -1) {
|
||||||
const URL = note.split('zestimate:')[1].split(' ')[0];
|
const URL = getTagValue(note, 'zestimate');
|
||||||
|
|
||||||
let ownership = 1;
|
let ownership = 1;
|
||||||
if (note.indexOf('ownership:') > -1) {
|
if (note.indexOf('ownership:') > -1) {
|
||||||
ownership = parseFloat(note.split('ownership:')[1].split(' ')[0]);
|
ownership = parseFloat(getTagValue(note, 'ownership'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Fetching zestimate for account:', account.name);
|
console.log('Fetching zestimate for account:', account.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user