mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
total amount on the account list page supports excluding specified accounts (#161)
This commit is contained in:
@@ -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: [
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user