[Bug]: Balance not updating when syncing an investment account linked to a bank with SimpleFin #1082

Closed
opened 2026-02-28 19:31:21 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @mmcc-xx on GitHub (May 6, 2024).

Verified issue does not already exist?

  • I have searched and found no existing issue
  • I will be providing steps how to reproduce the bug (in most cases this will also mean uploading a demo budget file)

What happened?

I initially thought this was an enhancement request, but upon looking at the code, I think it is supposed to work already.

I have some accounts linked to banks with SimpleFin. When I sync those accounts, new transactions are retrieved but the balance does not get updated.

I think the problem is in the updateAccountBalance function in packages/loot-core/src/server/accounts/sync.ts
It calls amountToInteger(balance), but balance is an array of two objects, not a numeric.

So what db.RunQuery sees is

sql = "UPDATE accounts SET balance_current = ? WHERE id = ?", params = (2) [NaN, redacted], fetchAll = undefined

To reproduce:

  1. set up an account linked to a bank with SimpleFin. Make this an account whose balance changes without associated transactions, like a brokerage account
  2. Wait a day or so for the real balance to change
  3. Sync the account. Note that the balance does not update in Actual.
  4. Open the console for the browser and dig into the debug output. Note that the new balance was returned by SimpleFin

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

Chrome

Operating System

Windows 10

Originally created by @mmcc-xx on GitHub (May 6, 2024). ### Verified issue does not already exist? - [X] I have searched and found no existing issue - [X] I will be providing steps how to reproduce the bug (in most cases this will also mean uploading a demo budget file) ### What happened? I initially thought this was an enhancement request, but upon looking at the code, I think it is supposed to work already. I have some accounts linked to banks with SimpleFin. When I sync those accounts, new transactions are retrieved but the balance does not get updated. I think the problem is in the updateAccountBalance function in packages/loot-core/src/server/accounts/sync.ts It calls amountToInteger(balance), but balance is an array of two objects, not a numeric. So what db.RunQuery sees is ``` sql = "UPDATE accounts SET balance_current = ? WHERE id = ?", params = (2) [NaN, redacted], fetchAll = undefined ``` To reproduce: 1) set up an account linked to a bank with SimpleFin. Make this an account whose balance changes without associated transactions, like a brokerage account 2) Wait a day or so for the real balance to change 3) Sync the account. Note that the balance does not update in Actual. 4) Open the console for the browser and dig into the debug output. Note that the new balance was returned by SimpleFin ### Where are you hosting Actual? Docker ### What browsers are you seeing the problem on? Chrome ### Operating System Windows 10
GiteaMirror added the bug label 2026-02-28 19:31:22 -06:00
Author
Owner

@mmcc-xx commented on GitHub (May 6, 2024):

I think if updateAccountBalance looked something like this...

async function updateAccountBalance(id, balance) {
  await db.runQuery('UPDATE accounts SET balance_current = ? WHERE id = ?', [
    //amountToInteger(balance),
    amountToInteger(balance[0].balanceAmount.amount),
    id,
  ]);
}

... it would work correctly. At least amountToInteger returns a value with balance[0].balanceAmount.amount passed in, and it appears to be the correct current balance as an integer in cents. However, I don't know how to actually get a code change working as I know little about typescript apps.

@mmcc-xx commented on GitHub (May 6, 2024): I think if updateAccountBalance looked something like this... ``` async function updateAccountBalance(id, balance) { await db.runQuery('UPDATE accounts SET balance_current = ? WHERE id = ?', [ //amountToInteger(balance), amountToInteger(balance[0].balanceAmount.amount), id, ]); } ``` ... it would work correctly. At least amountToInteger returns a value with balance[0].balanceAmount.amount passed in, and it appears to be the correct current balance as an integer in cents. However, I don't know how to actually get a code change working as I know little about typescript apps.
Author
Owner

@mmcc-xx commented on GitHub (May 6, 2024):

I got the front end running locally and was able to test my change. runQuery now sees...

sql = "UPDATE accounts SET balance_current = ? WHERE id = ?", params = (2) [<correct new balance>, redacted], fetchAll = undefined

... but the new balance is not displayed in the UI, even after refreshing.

@mmcc-xx commented on GitHub (May 6, 2024): I got the front end running locally and was able to test my change. runQuery now sees... ``` sql = "UPDATE accounts SET balance_current = ? WHERE id = ?", params = (2) [<correct new balance>, redacted], fetchAll = undefined ``` ... but the new balance is not displayed in the UI, even after refreshing.
Author
Owner

@mmcc-xx commented on GitHub (May 7, 2024):

I exported the sqlite database to poke around at it... in the accounts table, there are fields for balance_current balance available and balance_limit but they are all NULL for all accounts. Are these fields not used?

@mmcc-xx commented on GitHub (May 7, 2024): I exported the sqlite database to poke around at it... in the accounts table, there are fields for balance_current balance available and balance_limit but they are all NULL for all accounts. Are these fields not used?
Author
Owner

@shall0pass commented on GitHub (May 7, 2024):

The balances are controlled by the transactions in that account. You can't just update an account balance. You have to add or modify a transaction in that account for a new balance to be displayed.

@shall0pass commented on GitHub (May 7, 2024): The balances are controlled by the transactions in that account. You can't just update an account balance. You have to add or modify a transaction in that account for a new balance to be displayed.
Author
Owner

@mmcc-xx commented on GitHub (May 7, 2024):

The balances are controlled by the transactions in that account. You can't just update an account balance. You have to add or modify a transaction in that account for a new balance to be displayed.

I take it then that the balance fields in the accounts table aren't used?

@mmcc-xx commented on GitHub (May 7, 2024): > The balances are controlled by the transactions in that account. You can't just update an account balance. You have to add or modify a transaction in that account for a new balance to be displayed. I take it then that the balance fields in the accounts table aren't used?
Author
Owner

@shall0pass commented on GitHub (May 7, 2024):

Everywhere balance_current is used : https://github.com/search?q=repo%3Aactualbudget%2Factual%20balance_current&type=code

Everywhere balance_limit is used: https://github.com/search?q=repo%3Aactualbudget%2Factual+balance_limit&type=code

I'm assuming it's not used outside of the mock tests.

@shall0pass commented on GitHub (May 7, 2024): Everywhere balance_current is used : https://github.com/search?q=repo%3Aactualbudget%2Factual%20balance_current&type=code Everywhere balance_limit is used: https://github.com/search?q=repo%3Aactualbudget%2Factual+balance_limit&type=code I'm assuming it's not used outside of the mock tests.
Author
Owner

@youngcw commented on GitHub (May 8, 2024):

I don't think this is a bug, since that field in the db isn't used. My guess is that field was just lofty goals that have yet to go anywhere. Its fine having a feature request for this.

Any complaints to closing this issue?

@youngcw commented on GitHub (May 8, 2024): I don't think this is a bug, since that field in the db isn't used. My guess is that field was just lofty goals that have yet to go anywhere. Its fine having a feature request for this. Any complaints to closing this issue?
Author
Owner

@mmcc-xx commented on GitHub (May 9, 2024):

I don't think this is a bug, since that field in the db isn't used. My guess is that field was just lofty goals that have yet to go anywhere. Its fine having a feature request for this.

Any complaints to closing this issue?

Fine with me

@mmcc-xx commented on GitHub (May 9, 2024): > I don't think this is a bug, since that field in the db isn't used. My guess is that field was just lofty goals that have yet to go anywhere. Its fine having a feature request for this. > > Any complaints to closing this issue? Fine with me
Author
Owner

@mmcc-xx commented on GitHub (May 9, 2024):

The feature request I submitted is here: https://github.com/actualbudget/actual/issues/2718

@mmcc-xx commented on GitHub (May 9, 2024): The feature request I submitted is here: https://github.com/actualbudget/actual/issues/2718
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#1082