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

Commit

Permalink
add start date
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriguestiago0 committed Nov 25, 2024
1 parent d60b9b9 commit 8307b4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 6 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const EDENRED_ACCOUNT = process.env.EDENRED_ACCOUNT || "";
const ACTUAL_ACCOUNT = process.env.ACTUAL_ACCOUNT || "";
const CRON_EXPRESSION = process.env.CRON_EXPRESSION || "";
const ACTUAL_SYNC_ID = process.env.ACTUAL_SYNC_ID || "";
const IMPORT_FROM = process.env.IMPORT_FROM || "";


function getAppConfigFromEnv() {
Expand Down Expand Up @@ -43,6 +44,9 @@ function getAppConfigFromEnv() {
EDENRED_ACCOUNT_MAPPING[edenred] = actualSplit;
ACTUAL_ACCOUNT_MAPPING[actualSplit] = edenred;
}
if (IMPORT_FROM == "") {
IMPORT_FROM = "1970-01-01"
}
const appConfig = {
APP_PORT,
APP_URL,
Expand All @@ -54,7 +58,8 @@ function getAppConfigFromEnv() {
ACTUAL_SERVER_URL,
ACTUAL_SERVER_PASSWORD,
ACTUAL_SYNC_ID,
CRON_EXPRESSION
CRON_EXPRESSION,
IMPORT_FROM
}

// Assert that all required environment variables are set
Expand Down
6 changes: 4 additions & 2 deletions edenredService.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { config } = require("dotenv");
const { getAppConfigFromEnv } = require("./config");
const crypto = require('crypto');

Expand Down Expand Up @@ -39,7 +40,8 @@ const getAllTransactions = async (token, accountId) => {
},
})
.then((response) => response.json())
.then((json) => json.data.movementList)
.then((json) =>
json.data.movementList)
.catch((err) => {
console.error("error occured", err);
});
Expand All @@ -55,7 +57,7 @@ async function getTransactions(accountId) {
transactionID = crypto.createHash('sha256').update(transaction.transactionName+transaction.transactionDate+transaction.amount).digest('hex');

date = transaction.transactionDate.split("T")[0]
if (date < '2024-06-21') {
if (date < appConfig.IMPORT_FROM) {
return;
}
parsedTransactions.push({
Expand Down
4 changes: 0 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ const cli = meow(
alias: "a",
type: "string",
},
since: {
alias: "s",
type: "string",
},
},
}
);
Expand Down

0 comments on commit 8307b4f

Please sign in to comment.