A local-first personal finance app
update synced account balance in db if available (#3452)
Matt Fiddaman17fd06894a7b
diff --git a/packages/loot-core/src/server/accounts/sync.ts b/packages/loot-core/src/server/accounts/sync.tsindex 891763a0aa..9209026d26 100644--- a/packages/loot-core/src/server/accounts/sync.ts+++ b/packages/loot-core/src/server/accounts/sync.ts@@ -54,6 +54,13 @@ function getAccountBalance(account) {}}+async function updateAccountBalance(id, balance) {+ await db.runQuery('UPDATE accounts SET balance_current = ? WHERE id = ?', [+ amountToInteger(balance),+ id,+ ]);+}+export async function getGoCardlessAccounts(userId, userKey, id) {const userToken = await asyncStorage.getItem('user-token');if (!userToken) return;@@ -694,7 +701,7 @@ export async function syncAccount();}- const { transactions: originalTransactions } = download;+ const { transactions: originalTransactions, accountBalance } = download;if (originalTransactions.length === 0) {return { added: [], updated: [] };@@ -713,6 +720,8 @@ export async function syncAccount(useStrictIdChecking,);+ if (accountBalance) await updateAccountBalance(id, accountBalance);+return result;});} else {diff --git a/upcoming-release-notes/3452.md b/upcoming-release-notes/3452.mdnew file mode 100644index 0000000000..d1de146fda--- /dev/null+++ b/upcoming-release-notes/3452.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [matt-fidd]+---++Update synced account balance in db if available