Skip to content

Commit

Permalink
improve get value
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriguestiago0 committed Jan 4, 2025
1 parent 6a081ee commit 567cc3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function ghostfolioSync() {
}
])
} else {
console.log("No difference found for account " + account + '(' + actualBalance + ')' + '[' + actualAccount + '(' + actualBalance + ')' + ']');
console.log("No difference found for account " + account + '(' + actualBalance + ')' + '(' + actualBalance + ')');
}
}
await finalize(actual);
Expand Down
17 changes: 9 additions & 8 deletions ghostfolio.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ const appConfig = getAppConfigFromEnv();

async function getAccountBalance(accountId) {
token = 'Bearer ' + appConfig.GHOSTFOLIO_TOKEN
url = appConfig.GHOSTFOLIO_SERVER_URL+ '/api/v1/account/' + accountId
balance = await fetch(url, {
url = appConfig.GHOSTFOLIO_SERVER_URL+ '/api/v1/account'
accounts = await fetch(url, {
method: 'GET',
headers: {
'Authorization': token
},
})
.then((response) => response.json())
.then((json) => json.value)
.catch((err) => {
console.error("error occured", err);
});
.then((response) => response.json())
.then((json) => json.accounts)
.catch((err) => {
console.error("error occured", err);
});
account = accounts.filter((account) => account.id == accountId);

return Math.floor(balance*100);
return Math.floor(account[0].value*100);
}

module.exports = {
Expand Down

0 comments on commit 567cc3c

Please sign in to comment.