Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriguestiago0 committed Dec 4, 2024
1 parent abd01ec commit 5dccc3a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
35 changes: 1 addition & 34 deletions actual.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,6 @@ function listAccounts(actualInstance) {
return actualInstance.getAccounts();
}

/**
* Only works for the past month
* @param {typeof actual} actualInstance
* @param {*} accountId
*/
async function getLastTransactionDate(actualInstance, accountId) {
const monthAgo = new Date();
monthAgo.setMonth(monthAgo.getMonth() -3);

const transactions = await actualInstance.getTransactions(accountId, monthAgo, new Date());

if (transactions.length === 0) {
return new Date(0);
}

// Transactions of the day are already imported, so start from the next day.
const last = new Date(transactions[0].date);
last.setDate(last.getDate() + 1);

return last;
}


async function importTransactions(actualInstance, accountId, transactions) {
console.info("Importing transactions raw data START:")
console.debug(transactions)
Expand All @@ -67,14 +44,6 @@ async function importTransactions(actualInstance, accountId, transactions) {
console.info("Actual logs: ", actualResult);
}

async function getBalance(actualInstance, accountId) {
const balance = await actualInstance.runQuery(q('transactions')
.filter({ account: accountId })
//.options({ splits: 'inline' })
.calculate({ $sum: '$amount' }),)
return balance.data;
}

/**
*
* @param {typeof actual} actualInstance
Expand All @@ -87,8 +56,6 @@ async function finalize(actualInstance) {
module.exports = {
initialize,
listAccounts,
getLastTransactionDate,
importTransactions,
finalize,
getBalance
finalize
}
1 change: 0 additions & 1 deletion edenredService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { config } = require("dotenv");
const { getAppConfigFromEnv } = require("./config");
const crypto = require('crypto');

Expand Down

0 comments on commit 5dccc3a

Please sign in to comment.