Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] API call for getting account balance #2189

Closed
1 of 2 tasks
MirariFang opened this issue Jan 7, 2024 · 2 comments · May be fixed by #2930
Closed
1 of 2 tasks

[Feature] API call for getting account balance #2189

MirariFang opened this issue Jan 7, 2024 · 2 comments · May be fixed by #2930
Labels
feature This issue is a feature request needs votes Please upvote this feature request if you would like to see it implemented!

Comments

@MirariFang
Copy link

Verified feature request does not already exist?

  • I have searched and found no existing issue

💻

  • Would you like to implement this feature?

Pitch: what problem are you trying to solve?

Hi there, I'm trying to implement my own tools to interact with the Actual, but I didn't find any API calls that could simply give me the total balance of an account. Although I probably could just get all transactions with a super early starting date and sum them up, it's a little bit more tedious than getting the value in one go.
Just curious, is this intentional by design? Why the Account object can't simply include a "balance" field? Or am I missing anything?
Thanks.

Describe your ideal solution to this problem

Add balance field to Account, which has the current balance value of that account.

Teaching and learning

No response

@MirariFang MirariFang added the feature This issue is a feature request label Jan 7, 2024
@github-actions github-actions bot added the needs votes Please upvote this feature request if you would like to see it implemented! label Jan 7, 2024
Copy link
Contributor

github-actions bot commented Jan 7, 2024

✨ Thanks for sharing your idea! ✨

This repository uses lodash style issue management for enhancements. That means enhancement issues are automatically closed. This doesn’t mean we don’t accept feature requests, though! We will consider implementing ones that receive many upvotes, and we welcome contributions for any feature requests marked as needing votes (just post a comment first so we can help you make a successful contribution).

The enhancement backlog can be found here: https://github.com/actualbudget/actual/issues?q=label%3A%22needs+votes%22+sort%3Areactions-%2B1-desc+

Don’t forget to upvote the top comment with 👍!

@github-actions github-actions bot closed this as completed Jan 7, 2024
@turt2live
Copy link
Contributor

turt2live commented Apr 7, 2024

In the meantime, developers can use the ActualQL feature:

// Get balances for all accounts as of a certain date
const balancesAllAccounts = (await runQuery(q('transactions')
    .filter({ date: { $lte: '2024-03-31' } })
    .groupBy('account.id')
    .select(['account.id', 'account.name', {balance: {$sum: "$amount"}}])
)).data;

// Get balance for a single account as of a certain date
const balanceMyAccount = (await runQuery(q('transactions')
    .filter({
        date: { $lte: '2024-03-31' },
        'account.id': 'YOUR-ACCOUNT-UUID-HERE',
    })
    .select(['account.id', 'account.name', {balance: {$sum: "$amount"}}])
)).data;

If you need the current balance as of 'today', either put that date into the filter or remove that condition entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue is a feature request needs votes Please upvote this feature request if you would like to see it implemented!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants