From ee029294f1eec141632c20b41252fb71d7278003 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Thu, 12 Dec 2024 08:54:19 +0800 Subject: [PATCH] improve robustness --- src/lib/account.js | 2 +- src/stores/account.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/account.js b/src/lib/account.js index 09488cd8..d0eca60c 100644 --- a/src/lib/account.js +++ b/src/lib/account.js @@ -243,7 +243,7 @@ export function getAllFilteredAccountsBalance(categorizedAccounts, accountFilter isLiability: account.isLiability, currency: account.currency }); - } else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts) { + } else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts && account.subAccounts) { for (let subAccountIdx = 0; subAccountIdx < account.subAccounts.length; subAccountIdx++) { const subAccount = account.subAccounts[subAccountIdx]; diff --git a/src/stores/account.js b/src/stores/account.js index 7344db56..e5736811 100644 --- a/src/stores/account.js +++ b/src/stores/account.js @@ -188,9 +188,11 @@ export const useAccountsStore = defineStore('accounts', { if (account.type === accountConstants.allAccountTypes.SingleAccount) { allAccounts.push(account); } else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts) { - for (let j = 0; j < account.subAccounts.length; j++) { - const subAccount = account.subAccounts[j]; - allAccounts.push(subAccount); + if (account.subAccounts) { + for (let j = 0; j < account.subAccounts.length; j++) { + const subAccount = account.subAccounts[j]; + allAccounts.push(subAccount); + } } } } @@ -210,9 +212,11 @@ export const useAccountsStore = defineStore('accounts', { if (account.type === accountConstants.allAccountTypes.SingleAccount) { allVisibleAccounts.push(account); } else if (account.type === accountConstants.allAccountTypes.MultiSubAccounts) { - for (let j = 0; j < account.subAccounts.length; j++) { - const subAccount = account.subAccounts[j]; - allVisibleAccounts.push(subAccount); + if (account.subAccounts) { + for (let j = 0; j < account.subAccounts.length; j++) { + const subAccount = account.subAccounts[j]; + allVisibleAccounts.push(subAccount); + } } } }