total amount on the account list page supports excluding specified accounts (#161)

This commit is contained in:
MaysWind
2025-06-29 22:27:34 +08:00
parent 90e862fbb1
commit 801c0f8572
25 changed files with 305 additions and 24 deletions
@@ -39,6 +39,10 @@ export function useAccountFilterSettingPageBase(type?: string) {
}
});
const allowHiddenAccount = computed<boolean>(() => {
return type === 'statisticsDefault' || type === 'statisticsCurrent' || type === 'transactionListCurrent';
});
const allCategorizedAccounts = computed<AccountCategoriesWithVisibleCount[]>(() => getCategorizedAccountsWithVisibleCount(accountsStore.allCategorizedAccountsMap));
const hasAnyAvailableAccount = computed<boolean>(() => 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,
@@ -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: [
+53 -2
View File
@@ -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<boolean>(false);
const allThemes = computed<NameValue[]>(() => {
return [
{ name: tt('System Default'), value: 'auto' },
@@ -38,6 +42,8 @@ export function useAppSettingPageBase() {
];
});
const hasAnyVisibleAccount = computed<boolean>(() => accountsStore.allVisibleAccountsCount > 0);
const timeZone = computed<string>({
get: () => settingsStore.appSettings.timeZone,
set: (value) => {
@@ -108,7 +114,50 @@ export function useAppSettingPageBase() {
set: (value: number) => settingsStore.setCurrencySortByInExchangeRatesPage(value)
});
const accountsIncludedInTotalDisplayContent = computed<string>(() => {
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
};
}
+13
View File
@@ -80,6 +80,10 @@
<v-list-item :prepend-icon="mdiEyeOffOutline"
:title="tt('Hide Hidden Accounts')"
v-if="showHidden" @click="showHidden = false"></v-list-item>
<v-divider class="my-2" v-if="hasAnyVisibleAccount"/>
<v-list-item :prepend-icon="mdiCalculatorVariantOutline"
:title="tt('Set Accounts Included in Total')"
v-if="hasAnyVisibleAccount" @click="showAccountsIncludedInTotalDialog = true"></v-list-item>
</v-list>
</v-menu>
</v-btn>
@@ -248,6 +252,11 @@
</v-col>
</v-row>
<v-dialog width="800" v-model="showAccountsIncludedInTotalDialog">
<account-filter-settings-card type="accountListTotalAmount" :dialog-mode="true"
@settings:change="showAccountsIncludedInTotalDialog = false" />
</v-dialog>
<edit-dialog ref="editDialog" />
<confirm-dialog ref="confirmDialog"/>
@@ -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<string>('accountPage');
const activeSubAccount = ref<Record<string, string>>({});
const alwaysShowNav = ref<boolean>(display.mdAndUp.value);
const showNav = ref<boolean>(display.mdAndUp.value);
const showAccountsIncludedInTotalDialog = ref<boolean>(false);
const hasAnyVisibleAccount = computed<boolean>(() => accountsStore.allVisibleAccountsCount > 0);
const activeAccountCategory = computed<AccountCategory | undefined>(() => AccountCategory.valueOf(activeAccountCategoryType.value));
const activeAccountCategoryTotalBalance = computed<string>(() => accountCategoryTotalBalance(activeAccountCategory.value));
@@ -192,6 +192,32 @@
</v-card>
</v-col>
<v-col cols="12">
<v-card :title="tt('Account List Page')">
<v-form>
<v-card-text>
<v-row>
<v-col cols="12" md="6">
<v-text-field
class="always-cursor-pointer"
item-title="displayName"
item-value="type"
persistent-placeholder
:loading="loadingAccounts"
:readonly="true"
:disabled="!hasAnyVisibleAccount"
:label="tt('Accounts Included in Total')"
:placeholder="tt('Accounts Included in Total')"
:model-value="accountsIncludedInTotalDisplayContent"
@click="showAccountsIncludedInTotalDialog = true"
/>
</v-col>
</v-row>
</v-card-text>
</v-form>
</v-card>
</v-col>
<v-col cols="12">
<v-card :title="tt('Exchange Rates Data Page')">
<v-form>
@@ -214,30 +240,45 @@
</v-card>
</v-col>
</v-row>
<v-dialog width="800" v-model="showAccountsIncludedInTotalDialog">
<account-filter-settings-card type="accountListTotalAmount" :dialog-mode="true"
@settings:change="showAccountsIncludedInTotalDialog = false" />
</v-dialog>
<snack-bar ref="snackbar" />
</template>
<script setup lang="ts">
import { computed } from 'vue';
import SnackBar from '@/components/desktop/SnackBar.vue';
import AccountFilterSettingsCard from '@/views/desktop/common/cards/AccountFilterSettingsCard.vue';
import { ref, computed, useTemplateRef } from 'vue';
import { useTheme } from 'vuetify';
import { useI18n } from '@/locales/helpers.ts';
import { useAppSettingPageBase } from '@/views/base/settings/AppSettingsPageBase.ts';
import { useSettingsStore } from '@/stores/setting.ts';
import { useAccountsStore } from '@/stores/account.ts';
import type { LocalizedSwitchOption } from '@/core/base.ts';
import { ThemeType } from '@/core/theme.ts';
import { getSystemTheme } from '@/lib/ui/common.ts';
type SnackBarType = InstanceType<typeof SnackBar>;
const theme = useTheme();
const { tt, getAllEnableDisableOptions } = useI18n();
const {
loadingAccounts,
allThemes,
allTimezones,
allTimezoneTypesUsedForStatistics,
allCurrencySortingTypes,
allAutoSaveTransactionDraftTypes,
hasAnyVisibleAccount,
timeZone,
isAutoUpdateExchangeRatesData,
showAccountBalance,
@@ -248,10 +289,16 @@ const {
showTagInTransactionListPage,
autoSaveTransactionDraft,
isAutoGetCurrentGeoLocation,
currencySortByInExchangeRatesPage
currencySortByInExchangeRatesPage,
accountsIncludedInTotalDisplayContent
} = useAppSettingPageBase();
const settingsStore = useSettingsStore();
const accountsStore = useAccountsStore();
const snackbar = useTemplateRef<SnackBarType>('snackbar');
const showAccountsIncludedInTotalDialog = ref<boolean>(false);
const enableDisableOptions = computed<LocalizedSwitchOption[]>(() => getAllEnableDisableOptions());
@@ -274,4 +321,22 @@ const showAddTransactionButtonInDesktopNavbar = computed<boolean>({
get: () => settingsStore.appSettings.showAddTransactionButtonInDesktopNavbar,
set: (value) => settingsStore.setShowAddTransactionButtonInDesktopNavbar(value)
});
function init(): void {
loadingAccounts.value = true;
accountsStore.loadAllAccounts({
force: false
}).then(() => {
loadingAccounts.value = false;
}).catch(error => {
loadingAccounts.value = false;
if (!error.processed) {
snackbar.value?.showError(error);
}
});
}
init();
</script>
@@ -22,13 +22,13 @@
:title="tt('Invert Selection')"
:disabled="!hasAnyVisibleAccount"
@click="selectInvertAccounts"></v-list-item>
<v-divider class="my-2"/>
<v-divider class="my-2" v-if="allowHiddenAccount"/>
<v-list-item :prepend-icon="mdiEyeOutline"
:title="tt('Show Hidden Accounts')"
v-if="!showHidden" @click="showHidden = true"></v-list-item>
v-if="allowHiddenAccount && !showHidden" @click="showHidden = true"></v-list-item>
<v-list-item :prepend-icon="mdiEyeOffOutline"
:title="tt('Hide Hidden Accounts')"
v-if="showHidden" @click="showHidden = false"></v-list-item>
v-if="allowHiddenAccount && showHidden" @click="showHidden = false"></v-list-item>
</v-list>
</v-menu>
</v-btn>
@@ -53,13 +53,13 @@
:title="tt('Invert Selection')"
:disabled="!hasAnyVisibleAccount"
@click="selectInvertAccounts"></v-list-item>
<v-divider class="my-2"/>
<v-divider class="my-2" v-if="allowHiddenAccount"/>
<v-list-item :prepend-icon="mdiEyeOutline"
:title="tt('Show Hidden Accounts')"
v-if="!showHidden" @click="showHidden = true"></v-list-item>
v-if="allowHiddenAccount && !showHidden" @click="showHidden = true"></v-list-item>
<v-list-item :prepend-icon="mdiEyeOffOutline"
:title="tt('Hide Hidden Accounts')"
v-if="showHidden" @click="showHidden = false"></v-list-item>
v-if="allowHiddenAccount && showHidden" @click="showHidden = false"></v-list-item>
</v-list>
</v-menu>
</v-btn>
@@ -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();
+8
View File
@@ -159,6 +159,9 @@
<f7-actions-button v-if="!showHidden" @click="showHidden = true">{{ tt('Show Hidden Accounts') }}</f7-actions-button>
<f7-actions-button v-if="showHidden" @click="showHidden = false">{{ tt('Hide Hidden Accounts') }}</f7-actions-button>
</f7-actions-group>
<f7-actions-group v-if="hasAnyVisibleAccount">
<f7-actions-button @click="setAccountsIncludedInTotal()">{{ tt('Set Accounts Included in Total') }}</f7-actions-button>
</f7-actions-group>
<f7-actions-group>
<f7-actions-button bold close>{{ tt('Cancel') }}</f7-actions-button>
</f7-actions-group>
@@ -223,6 +226,7 @@ const displayOrderSaving = ref<boolean>(false);
const firstShowingIds = computed<AccountShowingIds>(() => accountsStore.getFirstShowingIds(showHidden.value));
const lastShowingIds = computed<AccountShowingIds>(() => accountsStore.getLastShowingIds(showHidden.value));
const hasAnyVisibleAccount = computed<boolean>(() => accountsStore.allVisibleAccountsCount > 0);
const noAvailableAccount = computed<boolean>(() => {
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');
@@ -120,7 +120,7 @@
<f7-actions-button :class="{ 'disabled': !hasAnyVisibleAccount }" @click="selectNoneAccounts">{{ tt('Select None') }}</f7-actions-button>
<f7-actions-button :class="{ 'disabled': !hasAnyVisibleAccount }" @click="selectInvertAccounts">{{ tt('Invert Selection') }}</f7-actions-button>
</f7-actions-group>
<f7-actions-group>
<f7-actions-group v-if="allowHiddenAccount">
<f7-actions-button v-if="!showHidden" @click="showHidden = true">{{ tt('Show Hidden Accounts') }}</f7-actions-button>
<f7-actions-button v-if="showHidden" @click="showHidden = false">{{ tt('Hide Hidden Accounts') }}</f7-actions-button>
</f7-actions-group>
@@ -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 {
+38 -1
View File
@@ -73,6 +73,18 @@
</f7-list-item>
</f7-list>
<f7-block-title>{{ tt('Account List Page') }}</f7-block-title>
<f7-list strong inset dividers>
<f7-list-item :disabled="!hasAnyVisibleAccount"
:title="tt('Accounts Included in Total')"
link="/settings/filter/account?type=accountListTotalAmount">
<template #after>
<f7-preloader v-if="loadingAccounts" />
<span v-else-if="!loadingAccounts">{{ accountsIncludedInTotalDisplayContent }}</span>
</template>
</f7-list-item>
</f7-list>
<f7-block-title>{{ tt('Exchange Rates Data Page') }}</f7-block-title>
<f7-list strong inset dividers>
<f7-list-item
@@ -101,14 +113,19 @@
import { ref, computed } from 'vue';
import { useI18n } from '@/locales/helpers.ts';
import { useI18nUIComponents } from '@/lib/ui/mobile.ts';
import { useAppSettingPageBase } from '@/views/base/settings/AppSettingsPageBase.ts';
import { useSettingsStore } from '@/stores/setting.ts';
import { useAccountsStore } from '@/stores/account.ts';
import { findNameByValue, findDisplayNameByType } from '@/lib/common.ts';
const { tt } = useI18n();
const { showToast } = useI18nUIComponents();
const {
loadingAccounts,
hasAnyVisibleAccount,
allTimezoneTypesUsedForStatistics,
allCurrencySortingTypes,
allAutoSaveTransactionDraftTypes,
@@ -118,10 +135,12 @@ const {
showTagInTransactionListPage,
autoSaveTransactionDraft,
isAutoGetCurrentGeoLocation,
currencySortByInExchangeRatesPage
currencySortByInExchangeRatesPage,
accountsIncludedInTotalDisplayContent
} = useAppSettingPageBase();
const settingsStore = useSettingsStore();
const accountsStore = useAccountsStore();
const showTimezoneUsedForStatisticsInHomePagePopup = ref<boolean>(false);
const showAutoSaveTransactionDraftPopup = ref<boolean>(false);
@@ -131,4 +150,22 @@ const alwaysShowTransactionPicturesInMobileTransactionEditPage = computed<boolea
get: () => 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();
</script>