diff --git a/pkg/models/user_app_cloud_setting.go b/pkg/models/user_app_cloud_setting.go index 1c6a712c..ea6e69a2 100644 --- a/pkg/models/user_app_cloud_setting.go +++ b/pkg/models/user_app_cloud_setting.go @@ -27,6 +27,8 @@ var ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES = map[string]UserApplicationClo "autoSaveTransactionDraft": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING, "autoGetCurrentGeoLocation": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN, "alwaysShowTransactionPicturesInMobileTransactionEditPage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN, + // Account List Page + "totalAmountExcludeAccountIds": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING_BOOLEAN_MAP, // Exchange Rates Data Page "currencySortByInExchangeRatesPage": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER, // Statistics Settings diff --git a/src/core/setting.ts b/src/core/setting.ts index dfcfb312..23700c15 100644 --- a/src/core/setting.ts +++ b/src/core/setting.ts @@ -45,6 +45,8 @@ export interface ApplicationSettings extends BaseApplicationSetting { autoSaveTransactionDraft: string; autoGetCurrentGeoLocation: boolean; alwaysShowTransactionPicturesInMobileTransactionEditPage: boolean; + // Account List Page + totalAmountExcludeAccountIds: Record; // Exchange Rates Data Page currencySortByInExchangeRatesPage: number; // Statistics Settings @@ -101,6 +103,8 @@ export const ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES: Record, allAccountsMap: Record): void { +export function selectAll(filterAccountIds: Record, allAccountsMap: Record, skipHiddenAccount: boolean): void { for (const accountId in filterAccountIds) { if (!Object.prototype.hasOwnProperty.call(filterAccountIds, accountId)) { continue; @@ -273,13 +273,17 @@ export function selectAll(filterAccountIds: Record, allAccounts const account = allAccountsMap[accountId]; + if (skipHiddenAccount && account && account.hidden) { + continue; + } + if (account && account.type === AccountType.SingleAccount.type) { filterAccountIds[account.id] = false; } } } -export function selectNone(filterAccountIds: Record, allAccountsMap: Record): void { +export function selectNone(filterAccountIds: Record, allAccountsMap: Record, skipHiddenAccount: boolean): void { for (const accountId in filterAccountIds) { if (!Object.prototype.hasOwnProperty.call(filterAccountIds, accountId)) { continue; @@ -287,13 +291,17 @@ export function selectNone(filterAccountIds: Record, allAccount const account = allAccountsMap[accountId]; + if (skipHiddenAccount && account && account.hidden) { + continue; + } + if (account && account.type === AccountType.SingleAccount.type) { filterAccountIds[account.id] = true; } } } -export function selectInvert(filterAccountIds: Record, allAccountsMap: Record): void { +export function selectInvert(filterAccountIds: Record, allAccountsMap: Record, skipHiddenAccount: boolean): void { for (const accountId in filterAccountIds) { if (!Object.prototype.hasOwnProperty.call(filterAccountIds, accountId)) { continue; @@ -301,6 +309,10 @@ export function selectInvert(filterAccountIds: Record, allAccou const account = allAccountsMap[accountId]; + if (skipHiddenAccount && account && account.hidden) { + continue; + } + if (account && account.type === AccountType.SingleAccount.type) { filterAccountIds[account.id] = !filterAccountIds[account.id]; } diff --git a/src/locales/de.json b/src/locales/de.json index 7c6174c3..f33e9c1d 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -1372,6 +1372,7 @@ "All Types": "Alle Typen", "More": "Mehr", "All": "Alle", + "Partial": "Partial", "Today": "Heute", "Yesterday": "Gestern", "Recent 7 days": "Letzte 7 Tage", @@ -1610,6 +1611,7 @@ "Unable to save account": "Konto kann nicht gespeichert werden", "Show Hidden Accounts": "Versteckte Konten anzeigen", "Hide Hidden Accounts": "Versteckte Konten ausblenden", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "Konto kann nicht abgerufen werden", "Unable to hide this account": "Dieses Konto kann nicht ausgeblendet werden", "Unable to unhide this account": "Dieses Konto kann nicht eingeblendet werden", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Bestätigung jedes mal anzeigen", "Automatically Add Geolocation": "Geolocation automatisch hinzufügen", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Wechselkursdatenseite", "Exchange Rate": "Wechselkurs", "Enable Animation": "Animation aktivieren", diff --git a/src/locales/en.json b/src/locales/en.json index 8beb2897..7a4b6709 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1372,6 +1372,7 @@ "All Types": "All Types", "More": "More", "All": "All", + "Partial": "Partial", "Today": "Today", "Yesterday": "Yesterday", "Recent 7 days": "Recent 7 days", @@ -1610,6 +1611,7 @@ "Unable to save account": "Unable to save account", "Show Hidden Accounts": "Show Hidden Accounts", "Hide Hidden Accounts": "Hide Hidden Accounts", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "Unable to retrieve account", "Unable to hide this account": "Unable to hide this account", "Unable to unhide this account": "Unable to unhide this account", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Show Confirmation Every Time", "Automatically Add Geolocation": "Automatically Add Geolocation", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Exchange Rates Data Page", "Exchange Rate": "Exchange Rate", "Enable Animation": "Enable Animation", diff --git a/src/locales/es.json b/src/locales/es.json index f355d8ba..2f14a9fc 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -1372,6 +1372,7 @@ "All Types": "Todos los tipos", "More": "Más", "All": "Todo", + "Partial": "Partial", "Today": "Hoy", "Yesterday": "Ayer", "Recent 7 days": "Últimos 7 días", @@ -1610,6 +1611,7 @@ "Unable to save account": "No se puede guardar la cuenta", "Show Hidden Accounts": "Mostrar cuentas ocultas", "Hide Hidden Accounts": "Ocultar cuentas ocultas", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "No se puede recuperar la cuenta", "Unable to hide this account": "No se puede ocultar esta cuenta", "Unable to unhide this account": "No se puede mostrar esta cuenta", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Mostrar confirmación cada vez", "Automatically Add Geolocation": "Agregar geolocalización automáticamente", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Página de datos de tipos de cambio", "Exchange Rate": "Tipo de cambio", "Enable Animation": "Habilitar animación", diff --git a/src/locales/it.json b/src/locales/it.json index 4b4b6606..f3f79d9c 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -1372,6 +1372,7 @@ "All Types": "Tutti i tipi", "More": "Altro", "All": "Tutti", + "Partial": "Partial", "Today": "Oggi", "Yesterday": "Ieri", "Recent 7 days": "Ultimi 7 giorni", @@ -1610,6 +1611,7 @@ "Unable to save account": "Impossibile salvare l'account", "Show Hidden Accounts": "Mostra account nascosti", "Hide Hidden Accounts": "Nascondi account nascosti", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "Impossibile recuperare l'account", "Unable to hide this account": "Impossibile nascondere questo account", "Unable to unhide this account": "Impossibile mostrare questo account", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Mostra conferma ogni volta", "Automatically Add Geolocation": "Aggiungi automaticamente geolocalizzazione", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Pagina dati tassi di cambio", "Exchange Rate": "Tasso di cambio", "Enable Animation": "Abilita animazione", diff --git a/src/locales/ja.json b/src/locales/ja.json index dea42017..a77b7c76 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -1372,6 +1372,7 @@ "All Types": "全種類", "More": "さらに", "All": "すべて", + "Partial": "Partial", "Today": "今日", "Yesterday": "昨日", "Recent 7 days": "直近7日間", @@ -1610,6 +1611,7 @@ "Unable to save account": "口座を保存できません", "Show Hidden Accounts": "非表示口座を表示します", "Hide Hidden Accounts": "非表示口座を隠します", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "口座を取得できません", "Unable to hide this account": "この口座は非表示にできません", "Unable to unhide this account": "この口座は非表示を解除できません", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "確認を毎回表示", "Automatically Add Geolocation": "座標を自動的に追加", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "為替レートデータページ", "Exchange Rate": "為替レート", "Enable Animation": "アニメーションの有効", diff --git a/src/locales/pt_BR.json b/src/locales/pt_BR.json index a7261303..ad535dee 100644 --- a/src/locales/pt_BR.json +++ b/src/locales/pt_BR.json @@ -1372,6 +1372,7 @@ "All Types": "Todos os Tipos", "More": "Mais", "All": "Todos", + "Partial": "Partial", "Today": "Hoje", "Yesterday": "Ontem", "Recent 7 days": "Últimos 7 dias", @@ -1610,6 +1611,7 @@ "Unable to save account": "Não foi possível salvar conta", "Show Hidden Accounts": "Mostrar Contas Ocultas", "Hide Hidden Accounts": "Ocultar Contas Ocultas", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "Não foi possível recuperar conta", "Unable to hide this account": "Não foi possível ocultar esta conta", "Unable to unhide this account": "Não foi possível desocultar esta conta", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Mostrar Confirmação Toda Vez", "Automatically Add Geolocation": "Adicionar Geolocalização Automaticamente", "Always Show Transaction Pictures": "Sempre Mostrar Imagens de Transações", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Página de Dados de Taxas de Câmbio", "Exchange Rate": "Taxa de Câmbio", "Enable Animation": "Habilitar Animação", diff --git a/src/locales/ru.json b/src/locales/ru.json index 4f1096a7..0ad03188 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1372,6 +1372,7 @@ "All Types": "Все типы", "More": "Еще", "All": "Все", + "Partial": "Partial", "Today": "Сегодня", "Yesterday": "Вчера", "Recent 7 days": "Последние 7 дней", @@ -1610,6 +1611,7 @@ "Unable to save account": "Не удалось сохранить счет", "Show Hidden Accounts": "Показать скрытые счета", "Hide Hidden Accounts": "Скрыть скрытые счета", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "Не удалось получить счет", "Unable to hide this account": "Не удалось скрыть этот счет", "Unable to unhide this account": "Не удалось отобразить этот счет", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Показывать подтверждение каждый раз", "Automatically Add Geolocation": "Автоматически добавлять геолокацию", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Страница данных о курсах валют", "Exchange Rate": "Курс обмена", "Enable Animation": "Включить анимацию", diff --git a/src/locales/uk.json b/src/locales/uk.json index 1d16b410..3a6ae1dd 100644 --- a/src/locales/uk.json +++ b/src/locales/uk.json @@ -1372,6 +1372,7 @@ "All Types": "Усі типи", "More": "Більше", "All": "Усе", + "Partial": "Partial", "Today": "Сьогодні", "Yesterday": "Вчора", "Recent 7 days": "Останні 7 днів", @@ -1610,6 +1611,7 @@ "Unable to save account": "Не вдалося зберегти рахунок", "Show Hidden Accounts": "Показати приховані рахунки", "Hide Hidden Accounts": "Приховати приховані рахунки", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "Не вдалося отримати рахунок", "Unable to hide this account": "Не вдалося приховати цей рахунок", "Unable to unhide this account": "Не вдалося відобразити цей рахунок", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Показувати підтвердження щоразу", "Automatically Add Geolocation": "Автоматично додавати геолокацію", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Сторінка курсів валют", "Exchange Rate": "Курс обміну", "Enable Animation": "Увімкнути анімацію", diff --git a/src/locales/vi.json b/src/locales/vi.json index 27e3fba0..c6243dfb 100644 --- a/src/locales/vi.json +++ b/src/locales/vi.json @@ -1372,6 +1372,7 @@ "All Types": "Tất cả các loại", "More": "Thêm", "All": "Tất cả", + "Partial": "Partial", "Today": "Hôm nay", "Yesterday": "Hôm qua", "Recent 7 days": "7 ngày gần đây", @@ -1610,6 +1611,7 @@ "Unable to save account": "Không thể lưu tài khoản", "Show Hidden Accounts": "Hiển thị tài khoản ẩn", "Hide Hidden Accounts": "Ẩn tài khoản ẩn", + "Set Accounts Included in Total": "Set Accounts Included in Total", "Unable to retrieve account": "Không thể lấy tài khoản", "Unable to hide this account": "Không thể ẩn tài khoản này", "Unable to unhide this account": "Không thể hiển thị tài khoản này", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "Hiển thị xác nhận mỗi lần", "Automatically Add Geolocation": "Tự động thêm vị trí địa lý", "Always Show Transaction Pictures": "Always Show Transaction Pictures", + "Account List Page": "Account List Page", + "Accounts Included in Total": "Accounts Included in Total", "Exchange Rates Data Page": "Trang dữ liệu tỷ giá hối đoái", "Exchange Rate": "Tỷ giá hối đoái", "Enable Animation": "Bật hoạt ảnh", diff --git a/src/locales/zh_Hans.json b/src/locales/zh_Hans.json index e6796ae0..0402d7cc 100644 --- a/src/locales/zh_Hans.json +++ b/src/locales/zh_Hans.json @@ -1372,6 +1372,7 @@ "All Types": "全部类型", "More": "更多", "All": "全部", + "Partial": "部分", "Today": "今天", "Yesterday": "昨天", "Recent 7 days": "最近7天", @@ -1610,6 +1611,7 @@ "Unable to save account": "无法保存账户", "Show Hidden Accounts": "显示隐藏的账户", "Hide Hidden Accounts": "不显示隐藏的账户", + "Set Accounts Included in Total": "设置计入总金额的账户", "Unable to retrieve account": "无法获取账户", "Unable to hide this account": "无法隐藏账户", "Unable to unhide this account": "无法取消隐藏账户", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "每次提示确认", "Automatically Add Geolocation": "自动添加地理位置", "Always Show Transaction Pictures": "总是显示交易图片", + "Account List Page": "账户列表页面", + "Accounts Included in Total": "计入总金额的账户", "Exchange Rates Data Page": "汇率数据页面", "Exchange Rate": "汇率", "Enable Animation": "启用动画", diff --git a/src/locales/zh_Hant.json b/src/locales/zh_Hant.json index f8c3a77b..e651f426 100644 --- a/src/locales/zh_Hant.json +++ b/src/locales/zh_Hant.json @@ -1372,6 +1372,7 @@ "All Types": "全部類型", "More": "更多", "All": "全部", + "Partial": "部分", "Today": "今天", "Yesterday": "昨天", "Recent 7 days": "最近7天", @@ -1610,6 +1611,7 @@ "Unable to save account": "無法儲存帳戶", "Show Hidden Accounts": "顯示隱藏的帳戶", "Hide Hidden Accounts": "不顯示隱藏的帳戶", + "Set Accounts Included in Total": "設定計入總金額的帳戶", "Unable to retrieve account": "無法取得帳戶", "Unable to hide this account": "無法隱藏帳戶", "Unable to unhide this account": "無法取消隱藏帳戶", @@ -1886,6 +1888,8 @@ "Show Confirmation Every Time": "每次提示確認", "Automatically Add Geolocation": "自動新增地理位置", "Always Show Transaction Pictures": "總是顯示交易圖片", + "Account List Page": "帳戶清單頁面", + "Accounts Included in Total": "計入總金額的帳戶", "Exchange Rates Data Page": "匯率資料頁面", "Exchange Rate": "匯率", "Enable Animation": "啟用動畫", diff --git a/src/stores/account.ts b/src/stores/account.ts index c6335be0..643516f9 100644 --- a/src/stores/account.ts +++ b/src/stores/account.ts @@ -1,6 +1,7 @@ import { ref, computed } from 'vue'; import { defineStore } from 'pinia'; +import { useSettingsStore } from './setting.ts'; import { useUserStore } from './user.ts'; import { useExchangeRatesStore } from './exchangeRates.ts'; @@ -21,6 +22,7 @@ import services from '@/lib/services.ts'; import logger from '@/lib/logger.ts'; export const useAccountsStore = defineStore('accounts', () => { + const settingsStore = useSettingsStore(); const userStore = useUserStore(); const exchangeRatesStore = useExchangeRatesStore(); @@ -484,7 +486,9 @@ export const useAccountsStore = defineStore('accounts', () => { return '***'; } - const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, () => true); + const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account => + !settingsStore.appSettings.totalAmountExcludeAccountIds[account.id] + ); let netAssets = 0; let hasUnCalculatedAmount = false; @@ -515,7 +519,9 @@ export const useAccountsStore = defineStore('accounts', () => { return '***'; } - const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account => account.isAsset || false); + const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account => + !settingsStore.appSettings.totalAmountExcludeAccountIds[account.id] && (account.isAsset || false) + ); let totalAssets = 0; let hasUnCalculatedAmount = false; @@ -546,7 +552,9 @@ export const useAccountsStore = defineStore('accounts', () => { return '***'; } - const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account => account.isLiability || false); + const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account => + !settingsStore.appSettings.totalAmountExcludeAccountIds[account.id] && (account.isLiability || false) + ); let totalLiabilities = 0; let hasUnCalculatedAmount = false; diff --git a/src/stores/setting.ts b/src/stores/setting.ts index ffa27f20..60cc7a67 100644 --- a/src/stores/setting.ts +++ b/src/stores/setting.ts @@ -220,6 +220,13 @@ export const useSettingsStore = defineStore('settings', () => { updateUserApplicationCloudSettingValue('alwaysShowTransactionPicturesInMobileTransactionEditPage', value); } + // Account List Page + function setTotalAmountExcludeAccountIds(value: Record): void { + updateApplicationSettingsValue('totalAmountExcludeAccountIds', value); + appSettings.value.totalAmountExcludeAccountIds = value; + updateUserApplicationCloudSettingValue('totalAmountExcludeAccountIds', value); + } + // Exchange Rates Data Page function setCurrencySortByInExchangeRatesPage(value: number): void { updateApplicationSettingsValue('currencySortByInExchangeRatesPage', value); @@ -429,6 +436,8 @@ export const useSettingsStore = defineStore('settings', () => { setAutoSaveTransactionDraft, setAutoGetCurrentGeoLocation, setAlwaysShowTransactionPicturesInMobileTransactionEditPage, + // -- Account List Page + setTotalAmountExcludeAccountIds, // -- Exchange Rates Data Page setCurrencySortByInExchangeRatesPage, // -- Statistics Settings diff --git a/src/views/base/settings/AccountFilterSettingPageBase.ts b/src/views/base/settings/AccountFilterSettingPageBase.ts index fd28fb9e..4937f476 100644 --- a/src/views/base/settings/AccountFilterSettingPageBase.ts +++ b/src/views/base/settings/AccountFilterSettingPageBase.ts @@ -39,6 +39,10 @@ export function useAccountFilterSettingPageBase(type?: string) { } }); + const allowHiddenAccount = computed(() => { + return type === 'statisticsDefault' || type === 'statisticsCurrent' || type === 'transactionListCurrent'; + }); + const allCategorizedAccounts = computed(() => getCategorizedAccountsWithVisibleCount(accountsStore.allCategorizedAccountsMap)); const hasAnyAvailableAccount = computed(() => accountsStore.allAvailableAccountsCount > 0); @@ -64,6 +68,10 @@ export function useAccountFilterSettingPageBase(type?: string) { const account = accountsStore.allAccountsMap[accountId]; + if (!allowHiddenAccount.value && account.hidden) { + continue; + } + if (type === 'transactionListCurrent' && transactionsStore.allFilterAccountIdsCount > 0) { allAccountIds[account.id] = true; } else { @@ -91,6 +99,9 @@ export function useAccountFilterSettingPageBase(type?: string) { } filterAccountIds.value = allAccountIds; return true; + } else if (type === 'accountListTotalAmount') { + filterAccountIds.value = Object.assign(allAccountIds, settingsStore.appSettings.totalAmountExcludeAccountIds); + return true; } else { return false; } @@ -109,6 +120,10 @@ export function useAccountFilterSettingPageBase(type?: string) { const account = accountsStore.allAccountsMap[accountId]; + if (!allowHiddenAccount.value && account.hidden) { + continue; + } + if (!isAccountOrSubAccountsAllChecked(account, filterAccountIds.value)) { filteredAccountIds[accountId] = true; isAllSelected = false; @@ -135,6 +150,8 @@ export function useAccountFilterSettingPageBase(type?: string) { if (changed) { transactionsStore.updateTransactionListInvalidState(true); } + } else if (type === 'accountListTotalAmount') { + settingsStore.setTotalAmountExcludeAccountIds(filteredAccountIds); } return changed; @@ -148,6 +165,7 @@ export function useAccountFilterSettingPageBase(type?: string) { // computed states title, applyText, + allowHiddenAccount, allCategorizedAccounts, hasAnyAvailableAccount, hasAnyVisibleAccount, diff --git a/src/views/base/settings/AppCloudSyncPageBase.ts b/src/views/base/settings/AppCloudSyncPageBase.ts index 28e2c986..5a70c00e 100644 --- a/src/views/base/settings/AppCloudSyncPageBase.ts +++ b/src/views/base/settings/AppCloudSyncPageBase.ts @@ -47,6 +47,12 @@ export const ALL_APPLICATION_CLOUD_SETTINGS: CategorizedApplicationCloudSettingI { settingKey: 'alwaysShowTransactionPicturesInMobileTransactionEditPage', settingName: 'Always Show Transaction Pictures', mobile: true, desktop: false } ] }, + { + categoryName: 'Account List Page', + items: [ + { settingKey: 'totalAmountExcludeAccountIds', settingName: 'Accounts Included in Total', mobile: true, desktop: true }, + ] + }, { categoryName: 'Exchange Rates Data Page', items: [ diff --git a/src/views/base/settings/AppSettingsPageBase.ts b/src/views/base/settings/AppSettingsPageBase.ts index 7a707110..a27fc662 100644 --- a/src/views/base/settings/AppSettingsPageBase.ts +++ b/src/views/base/settings/AppSettingsPageBase.ts @@ -1,8 +1,9 @@ -import { computed } from 'vue'; +import { ref, computed } from 'vue'; import { useI18n } from '@/locales/helpers.ts'; import { useSettingsStore } from '@/stores/setting.ts'; +import { useAccountsStore } from '@/stores/account.ts'; import { useTransactionsStore } from '@/stores/transaction.ts'; import { useOverviewStore } from '@/stores/overview.ts'; import { useStatisticsStore } from '@/stores/statistics.ts'; @@ -14,10 +15,13 @@ export function useAppSettingPageBase() { const { tt, getAllTimezones, getAllTimezoneTypesUsedForStatistics, getAllCurrencySortingTypes, setTimeZone } = useI18n(); const settingsStore = useSettingsStore(); + const accountsStore = useAccountsStore(); const transactionsStore = useTransactionsStore(); const overviewStore = useOverviewStore(); const statisticsStore = useStatisticsStore(); + const loadingAccounts = ref(false); + const allThemes = computed(() => { return [ { name: tt('System Default'), value: 'auto' }, @@ -38,6 +42,8 @@ export function useAppSettingPageBase() { ]; }); + const hasAnyVisibleAccount = computed(() => accountsStore.allVisibleAccountsCount > 0); + const timeZone = computed({ get: () => settingsStore.appSettings.timeZone, set: (value) => { @@ -108,7 +114,50 @@ export function useAppSettingPageBase() { set: (value: number) => settingsStore.setCurrencySortByInExchangeRatesPage(value) }); + const accountsIncludedInTotalDisplayContent = computed(() => { + if (loadingAccounts.value || !accountsStore.allVisiblePlainAccounts || !accountsStore.allVisiblePlainAccounts.length) { + return ''; + } + + const excludeAccountIds = settingsStore.appSettings.totalAmountExcludeAccountIds; + let hasExcludeAccount = false; + + for (const accountId in excludeAccountIds) { + if (!Object.prototype.hasOwnProperty.call(excludeAccountIds, accountId)) { + continue; + } + + if (excludeAccountIds[accountId]) { + hasExcludeAccount = true; + break; + } + } + + if (!hasExcludeAccount) { + return tt('All'); + } + + let allVisibleAccountExcluded = true; + + for (let i = 0; i < accountsStore.allVisiblePlainAccounts.length; i++) { + const account = accountsStore.allVisiblePlainAccounts[i]; + + if (!excludeAccountIds[account.id]) { + allVisibleAccountExcluded = false; + break; + } + } + + if (allVisibleAccountExcluded) { + return tt('None'); + } + + return tt('Partial'); + }); + return { + // states + loadingAccounts, // computed states allThemes, allTimezones, @@ -116,6 +165,7 @@ export function useAppSettingPageBase() { allCurrencySortingTypes, allAutoSaveTransactionDraftTypes, timeZone, + hasAnyVisibleAccount, isAutoUpdateExchangeRatesData, showAccountBalance, showAmountInHomePage, @@ -125,6 +175,7 @@ export function useAppSettingPageBase() { showTagInTransactionListPage, autoSaveTransactionDraft, isAutoGetCurrentGeoLocation, - currencySortByInExchangeRatesPage + currencySortByInExchangeRatesPage, + accountsIncludedInTotalDisplayContent }; } diff --git a/src/views/desktop/accounts/ListPage.vue b/src/views/desktop/accounts/ListPage.vue index 804c720f..7e3a2620 100644 --- a/src/views/desktop/accounts/ListPage.vue +++ b/src/views/desktop/accounts/ListPage.vue @@ -80,6 +80,10 @@ + + @@ -248,6 +252,11 @@ + + + + @@ -258,6 +267,7 @@ import ConfirmDialog from '@/components/desktop/ConfirmDialog.vue'; import SnackBar from '@/components/desktop/SnackBar.vue'; import EditDialog from './list/dialogs/EditDialog.vue'; +import AccountFilterSettingsCard from '@/views/desktop/common/cards/AccountFilterSettingsCard.vue'; import { ref, computed, useTemplateRef, watch } from 'vue'; import { useDisplay } from 'vuetify'; @@ -273,6 +283,7 @@ import type { Account } from '@/models/account.ts'; import { mdiEyeOutline, mdiEyeOffOutline, + mdiCalculatorVariantOutline, mdiRefresh, mdiSquareRounded, mdiMenu, @@ -317,7 +328,9 @@ const activeTab = ref('accountPage'); const activeSubAccount = ref>({}); const alwaysShowNav = ref(display.mdAndUp.value); const showNav = ref(display.mdAndUp.value); +const showAccountsIncludedInTotalDialog = ref(false); +const hasAnyVisibleAccount = computed(() => accountsStore.allVisibleAccountsCount > 0); const activeAccountCategory = computed(() => AccountCategory.valueOf(activeAccountCategoryType.value)); const activeAccountCategoryTotalBalance = computed(() => accountCategoryTotalBalance(activeAccountCategory.value)); diff --git a/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue b/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue index 3101ba70..24dc8d8f 100644 --- a/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue +++ b/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue @@ -192,6 +192,32 @@ + + + + + + + + + + + + + + @@ -214,30 +240,45 @@ + + + + + + diff --git a/src/views/desktop/common/cards/AccountFilterSettingsCard.vue b/src/views/desktop/common/cards/AccountFilterSettingsCard.vue index ffa83934..b2a86c98 100644 --- a/src/views/desktop/common/cards/AccountFilterSettingsCard.vue +++ b/src/views/desktop/common/cards/AccountFilterSettingsCard.vue @@ -22,13 +22,13 @@ :title="tt('Invert Selection')" :disabled="!hasAnyVisibleAccount" @click="selectInvertAccounts"> - + + v-if="allowHiddenAccount && !showHidden" @click="showHidden = true"> + v-if="allowHiddenAccount && showHidden" @click="showHidden = false"> @@ -53,13 +53,13 @@ :title="tt('Invert Selection')" :disabled="!hasAnyVisibleAccount" @click="selectInvertAccounts"> - + + v-if="allowHiddenAccount && !showHidden" @click="showHidden = true"> + v-if="allowHiddenAccount && showHidden" @click="showHidden = false"> @@ -196,6 +196,7 @@ const { filterAccountIds, title, applyText, + allowHiddenAccount, allCategorizedAccounts, hasAnyAvailableAccount, hasAnyVisibleAccount, @@ -245,7 +246,7 @@ function updateAccountSelected(account: Account, value: boolean | null): void { } function selectAllAccounts(): void { - selectAll(filterAccountIds.value, accountsStore.allAccountsMap); + selectAll(filterAccountIds.value, accountsStore.allAccountsMap, !allowHiddenAccount.value); if (props.autoSave) { save(); @@ -253,7 +254,7 @@ function selectAllAccounts(): void { } function selectNoneAccounts(): void { - selectNone(filterAccountIds.value, accountsStore.allAccountsMap); + selectNone(filterAccountIds.value, accountsStore.allAccountsMap, !allowHiddenAccount.value); if (props.autoSave) { save(); @@ -261,7 +262,7 @@ function selectNoneAccounts(): void { } function selectInvertAccounts(): void { - selectInvert(filterAccountIds.value, accountsStore.allAccountsMap); + selectInvert(filterAccountIds.value, accountsStore.allAccountsMap, !allowHiddenAccount.value); if (props.autoSave) { save(); diff --git a/src/views/mobile/accounts/ListPage.vue b/src/views/mobile/accounts/ListPage.vue index de4c996d..392c465e 100644 --- a/src/views/mobile/accounts/ListPage.vue +++ b/src/views/mobile/accounts/ListPage.vue @@ -159,6 +159,9 @@ {{ tt('Show Hidden Accounts') }} {{ tt('Hide Hidden Accounts') }} + + {{ tt('Set Accounts Included in Total') }} + {{ tt('Cancel') }} @@ -223,6 +226,7 @@ const displayOrderSaving = ref(false); const firstShowingIds = computed(() => accountsStore.getFirstShowingIds(showHidden.value)); const lastShowingIds = computed(() => accountsStore.getLastShowingIds(showHidden.value)); +const hasAnyVisibleAccount = computed(() => accountsStore.allVisibleAccountsCount > 0); const noAvailableAccount = computed(() => { if (showHidden.value) { return accountsStore.allAvailableAccountsCount < 1; @@ -383,6 +387,10 @@ function saveSortResult(): void { }); } +function setAccountsIncludedInTotal(): void { + props.f7router.navigate('/settings/filter/account?type=accountListTotalAmount'); +} + function onSort(event: { el: { id: string }; from: number; to: number }): void { if (!event || !event.el || !event.el.id) { showToast('Unable to move account'); diff --git a/src/views/mobile/settings/AccountFilterSettingsPage.vue b/src/views/mobile/settings/AccountFilterSettingsPage.vue index 87053c49..3bafd0af 100644 --- a/src/views/mobile/settings/AccountFilterSettingsPage.vue +++ b/src/views/mobile/settings/AccountFilterSettingsPage.vue @@ -120,7 +120,7 @@ {{ tt('Select None') }} {{ tt('Invert Selection') }} - + {{ tt('Show Hidden Accounts') }} {{ tt('Hide Hidden Accounts') }} @@ -171,6 +171,7 @@ const { filterAccountIds, title, applyText, + allowHiddenAccount, allCategorizedAccounts, hasAnyAvailableAccount, hasAnyVisibleAccount, @@ -245,15 +246,15 @@ function updateAccountSelected(e: Event): void { } function selectAllAccounts(): void { - selectAll(filterAccountIds.value, accountsStore.allAccountsMap); + selectAll(filterAccountIds.value, accountsStore.allAccountsMap, !allowHiddenAccount.value); } function selectNoneAccounts(): void { - selectNone(filterAccountIds.value, accountsStore.allAccountsMap); + selectNone(filterAccountIds.value, accountsStore.allAccountsMap, !allowHiddenAccount.value); } function selectInvertAccounts(): void { - selectInvert(filterAccountIds.value, accountsStore.allAccountsMap); + selectInvert(filterAccountIds.value, accountsStore.allAccountsMap, !allowHiddenAccount.value); } function save(): void { diff --git a/src/views/mobile/settings/PageSettingsPage.vue b/src/views/mobile/settings/PageSettingsPage.vue index 2a623da7..afa09790 100644 --- a/src/views/mobile/settings/PageSettingsPage.vue +++ b/src/views/mobile/settings/PageSettingsPage.vue @@ -73,6 +73,18 @@ + {{ tt('Account List Page') }} + + + + + + {{ tt('Exchange Rates Data Page') }} (false); const showAutoSaveTransactionDraftPopup = ref(false); @@ -131,4 +150,22 @@ const alwaysShowTransactionPicturesInMobileTransactionEditPage = computed settingsStore.appSettings.alwaysShowTransactionPicturesInMobileTransactionEditPage, set: (value) => settingsStore.setAlwaysShowTransactionPicturesInMobileTransactionEditPage(value) }); + +function init(): void { + loadingAccounts.value = true; + + accountsStore.loadAllAccounts({ + force: false + }).then(() => { + loadingAccounts.value = false; + }).catch(error => { + loadingAccounts.value = false; + + if (!error.processed) { + showToast(error.message || error); + } + }); +} + +init();