From 7e8cb824375e3b1834cd7ba3b45cc6d9040c514e Mon Sep 17 00:00:00 2001 From: Robert Dyer Date: Wed, 7 Aug 2024 07:57:27 -0500 Subject: [PATCH] clean util code --- utils.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/utils.js b/utils.js index 8cb149b..ad36c2a 100644 --- a/utils.js +++ b/utils.js @@ -1,7 +1,7 @@ const api = require('@actual-app/api'); require("dotenv").config(); -module.exports = { +const Utils = { openBudget: async function () { process.on('unhandledRejection', (reason, p) => { console.log('Unhandled Rejection at: Promise', p, 'reason:', reason); @@ -130,15 +130,7 @@ module.exports = { }, getAccountNote: async function (account) { - const notes = await api.runQuery( - api.q('notes') - .filter({ id: `account-${account.id}` }) - .select('*') - ); - if (notes.data.length && notes.data[0].note) { - return notes.data[0].note; - } - return undefined; + return Utils.getNote(`account-${account.id}`); }, setAccountNote: async function (account, note) { @@ -159,3 +151,5 @@ module.exports = { { style: 'percent', maximumFractionDigits: 2 }) }, }; + +module.exports = Utils;