Skip to content

Instantly share code, notes, and snippets.

@crazydevman
Created December 10, 2023 20:08
Show Gist options
  • Save crazydevman/e31a303decd503ddf0401f8638747fe2 to your computer and use it in GitHub Desktop.
Save crazydevman/e31a303decd503ddf0401f8638747fe2 to your computer and use it in GitHub Desktop.
Actual SimpleFIN Sync set account notes about sync status
diff --git a/sync.js b/sync.js
index 215f6b5..c8c42d4 100644
--- a/sync.js
+++ b/sync.js
@@ -1,5 +1,6 @@
const simpleFIN = require('./simpleFIN')
const api = require('@actual-app/api');
+const actualInjected = require('@actual-app/api/dist/injected')
let _accessKey
let _linkedAccounts
@@ -58,12 +59,19 @@ async function sync () {
}
})
try {
-
-
-
const importedTransactions = await api.importTransactions(accountId, transactions)
const accountName = allAccounts.find(f => f.id === accountId).name
console.log(`| ${accountName.padEnd(25, ' ')} | ${importedTransactions.added.length.toString().padStart(9, ' ')} | ${importedTransactions.updated.length.toString().padStart(9, ' ')} |`)
+ const balanceDate = new Date(allTrans.accounts.find(f => f.id == simpleFINAccountId)['balance-date'] * 1000);
+ const formatter = new Intl.NumberFormat('en-US', {
+ style: 'currency',
+ currency: 'USD',
+ });
+
+ const balance = allTrans.accounts.find(f => f.id == simpleFINAccountId).balance
+ const accountNote = "Transactions synced at " + balanceDate.toLocaleString() + " with balance " + formatter.format(balance);
+ const noteId = 'account-' + accountId;
+ await actualInjected.send('notes-save', { id: noteId, note: accountNote });
} catch (ex) {
console.log(ex)
throw ex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment