support changing account category order
This commit is contained in:
@@ -34,6 +34,7 @@ var ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES = map[string]UserApplicationClo
|
||||
"showTagInInsightsExplorerPage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
// Account List Page
|
||||
"totalAmountExcludeAccountIds": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING_BOOLEAN_MAP,
|
||||
"accountCategoryOrders": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING,
|
||||
"hideCategoriesWithoutAccounts": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
// Exchange Rates Data Page
|
||||
"currencySortByInExchangeRatesPage": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
|
||||
+39
-6
@@ -1,4 +1,4 @@
|
||||
import type { TypeAndName, TypeAndDisplayName } from './base.ts';
|
||||
import { type TypeAndName, type TypeAndDisplayName, itemAndIndex } from './base.ts';
|
||||
|
||||
export class AccountType implements TypeAndName {
|
||||
private static readonly allInstances: AccountType[] = [];
|
||||
@@ -38,15 +38,15 @@ export class AccountCategory implements TypeAndName {
|
||||
public static readonly Default = AccountCategory.Cash;
|
||||
|
||||
public readonly type: number;
|
||||
public readonly displayOrder: number;
|
||||
public readonly defaultDisplayOrder: number;
|
||||
public readonly name: string;
|
||||
public readonly isAsset: boolean;
|
||||
public readonly isLiability: boolean
|
||||
public readonly defaultAccountIconId: string;
|
||||
|
||||
private constructor(type: number, displayOrder: number, name: string, isAsset: boolean, isLiability: boolean, defaultAccountIconId: string) {
|
||||
private constructor(type: number, defaultDisplayOrder: number, name: string, isAsset: boolean, isLiability: boolean, defaultAccountIconId: string) {
|
||||
this.type = type;
|
||||
this.displayOrder = displayOrder;
|
||||
this.defaultDisplayOrder = defaultDisplayOrder;
|
||||
this.name = name;
|
||||
this.isAsset = isAsset;
|
||||
this.isLiability = isLiability;
|
||||
@@ -56,8 +56,41 @@ export class AccountCategory implements TypeAndName {
|
||||
AccountCategory.allInstancesByType[type] = this;
|
||||
}
|
||||
|
||||
public static values(): AccountCategory[] {
|
||||
return AccountCategory.allInstances;
|
||||
public static values(customAccountCategoryOrder?: string): AccountCategory[] {
|
||||
if (!customAccountCategoryOrder) {
|
||||
return [...AccountCategory.allInstances];
|
||||
}
|
||||
|
||||
const typeOrders: string[] = customAccountCategoryOrder.split(',');
|
||||
const orderedCategories: AccountCategory[] = [];
|
||||
const addedTypes: Record<string, boolean> = {};
|
||||
|
||||
for (const type of typeOrders) {
|
||||
const category = AccountCategory.valueOf(parseInt(type.trim()));
|
||||
|
||||
if (category) {
|
||||
orderedCategories.push(category);
|
||||
addedTypes[type] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const category of AccountCategory.allInstances) {
|
||||
if (!addedTypes[category.type]) {
|
||||
orderedCategories.push(category);
|
||||
}
|
||||
}
|
||||
|
||||
return orderedCategories;
|
||||
}
|
||||
|
||||
public static allDisplayOrders(customAccountCategoryOrder: string): Record<number, number> {
|
||||
const displayOrders: Record<number, number> = {};
|
||||
|
||||
for (const [category, index] of itemAndIndex(AccountCategory.values(customAccountCategoryOrder))) {
|
||||
displayOrders[category.type] = index + 1;
|
||||
}
|
||||
|
||||
return displayOrders;
|
||||
}
|
||||
|
||||
public static valueOf(type: number): AccountCategory | undefined {
|
||||
|
||||
@@ -55,6 +55,7 @@ export interface ApplicationSettings extends BaseApplicationSetting {
|
||||
showTagInInsightsExplorerPage: boolean;
|
||||
// Account List Page
|
||||
totalAmountExcludeAccountIds: Record<string, boolean>;
|
||||
accountCategoryOrders: string;
|
||||
hideCategoriesWithoutAccounts: boolean;
|
||||
// Exchange Rates Data Page
|
||||
currencySortByInExchangeRatesPage: number;
|
||||
@@ -121,6 +122,7 @@ export const ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES: Record<string, UserAp
|
||||
'showTagInInsightsExplorerPage': UserApplicationCloudSettingType.Boolean,
|
||||
// Account List Page
|
||||
'totalAmountExcludeAccountIds': UserApplicationCloudSettingType.StringBooleanMap,
|
||||
'accountCategoryOrders': UserApplicationCloudSettingType.String,
|
||||
'hideCategoriesWithoutAccounts': UserApplicationCloudSettingType.Boolean,
|
||||
// Exchange Rates Data Page
|
||||
'currencySortByInExchangeRatesPage': UserApplicationCloudSettingType.Number,
|
||||
@@ -172,6 +174,7 @@ export const DEFAULT_APPLICATION_SETTINGS: ApplicationSettings = {
|
||||
showTagInInsightsExplorerPage: true,
|
||||
// Account List Page
|
||||
totalAmountExcludeAccountIds: {},
|
||||
accountCategoryOrders: '',
|
||||
hideCategoriesWithoutAccounts: false,
|
||||
// Exchange Rates Data Page
|
||||
currencySortByInExchangeRatesPage: CurrencySortingType.Default.type,
|
||||
|
||||
+9
-9
@@ -31,9 +31,9 @@ export function getCategorizedAccountsMap(allAccounts: Account[]): Record<number
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function getCategorizedAccounts(allAccounts: Account[]): CategorizedAccount[] {
|
||||
export function getCategorizedAccounts(allAccounts: Account[], customAccountCategoryOrder: string): CategorizedAccount[] {
|
||||
const ret: CategorizedAccount[] = [];
|
||||
const allCategories = AccountCategory.values();
|
||||
const allCategories = AccountCategory.values(customAccountCategoryOrder);
|
||||
const categorizedAccounts = getCategorizedAccountsMap(allAccounts);
|
||||
|
||||
for (const category of allCategories) {
|
||||
@@ -71,9 +71,9 @@ export function getAccountMapByName(allAccounts: Account[]): Record<string, Acco
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function filterCategorizedAccounts(categorizedAccountsMap: Record<number, CategorizedAccount>, allowAccountName?: string, showHidden?: boolean): Record<number, CategorizedAccount> {
|
||||
const ret: Record<number, CategorizedAccount> = {};
|
||||
const allCategories = AccountCategory.values();
|
||||
export function filterCategorizedAccounts(categorizedAccountsMap: Record<number, CategorizedAccount>, customAccountCategoryOrder: string, allowAccountName?: string, showHidden?: boolean): CategorizedAccount[] {
|
||||
const ret: CategorizedAccount[] = [];
|
||||
const allCategories = AccountCategory.values(customAccountCategoryOrder);
|
||||
const lowercaseFilterContent = allowAccountName ? allowAccountName.toLowerCase() : '';
|
||||
|
||||
for (const accountCategory of allCategories) {
|
||||
@@ -122,20 +122,20 @@ export function filterCategorizedAccounts(categorizedAccountsMap: Record<number,
|
||||
}
|
||||
|
||||
if (allFilteredAccounts.length > 0) {
|
||||
ret[accountCategory.type] = {
|
||||
ret.push({
|
||||
category: categorizedAccount.category,
|
||||
name: categorizedAccount.name,
|
||||
icon: categorizedAccount.icon,
|
||||
accounts: allFilteredAccounts
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function getAllFilteredAccountsBalance(categorizedAccounts: Record<number, CategorizedAccount>, accountFilter: (account: Account) => boolean): AccountBalance[] {
|
||||
const allAccountCategories = AccountCategory.values();
|
||||
export function getAllFilteredAccountsBalance(categorizedAccounts: Record<number, CategorizedAccount>, customAccountCategoryOrder: string, accountFilter: (account: Account) => boolean): AccountBalance[] {
|
||||
const allAccountCategories = AccountCategory.values(customAccountCategoryOrder);
|
||||
const ret: AccountBalance[] = [];
|
||||
|
||||
for (const accountCategory of allAccountCategories) {
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Anwenden",
|
||||
"Save": "Speichern",
|
||||
"Save Changes": "Änderungen speichern",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Zurücksetzen",
|
||||
"Update": "Aktualisieren",
|
||||
"Refresh": "Aktualisieren",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Wechselkursdatenseite",
|
||||
"Exchange Rate": "Wechselkurs",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Apply",
|
||||
"Save": "Save",
|
||||
"Save Changes": "Save Changes",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Reset",
|
||||
"Update": "Update",
|
||||
"Refresh": "Refresh",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Exchange Rates Data Page",
|
||||
"Exchange Rate": "Exchange Rate",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Aplicar",
|
||||
"Save": "Guardar",
|
||||
"Save Changes": "Guardar Cambios",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Reiniciar",
|
||||
"Update": "Actualizar",
|
||||
"Refresh": "Refrescar",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Página de Cuentas",
|
||||
"Accounts Included in Total": "Cuentas Incluidas en el Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Página de Tipos de Cambio",
|
||||
"Exchange Rate": "Tipo de Cambio",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Appliquer",
|
||||
"Save": "Enregistrer",
|
||||
"Save Changes": "Enregistrer les modifications",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Réinitialiser",
|
||||
"Update": "Mettre à jour",
|
||||
"Refresh": "Actualiser",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Page de liste des comptes",
|
||||
"Accounts Included in Total": "Comptes inclus dans le total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Page des données de taux de change",
|
||||
"Exchange Rate": "Taux de change",
|
||||
|
||||
@@ -1349,9 +1349,9 @@ export function useI18n() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function getAllAccountCategories(): LocalizedAccountCategory[] {
|
||||
function getAllAccountCategories(customAccountCategoryOrder: string): LocalizedAccountCategory[] {
|
||||
const ret: LocalizedAccountCategory[] = [];
|
||||
const allCategories = AccountCategory.values();
|
||||
const allCategories = AccountCategory.values(customAccountCategoryOrder);
|
||||
|
||||
for (const accountCategory of allCategories) {
|
||||
ret.push({
|
||||
@@ -2094,10 +2094,10 @@ export function useI18n() {
|
||||
return getAmountPrependAndAppendCurrencySymbol(currencyDisplayType, currencyCode, currencyUnit, currencyName, isPlural);
|
||||
}
|
||||
|
||||
function getCategorizedAccountsWithDisplayBalance(allVisibleAccounts: Account[], showAccountBalance: boolean): CategorizedAccountWithDisplayBalance[] {
|
||||
function getCategorizedAccountsWithDisplayBalance(allVisibleAccounts: Account[], showAccountBalance: boolean, customAccountCategoryOrder: string): CategorizedAccountWithDisplayBalance[] {
|
||||
const ret: CategorizedAccountWithDisplayBalance[] = [];
|
||||
const defaultCurrency = userStore.currentUserDefaultCurrency;
|
||||
const allCategories = AccountCategory.values();
|
||||
const allCategories = AccountCategory.values(customAccountCategoryOrder);
|
||||
const categorizedAccounts: Record<number, CategorizedAccount> = getCategorizedAccountsMap(Account.cloneAccounts(allVisibleAccounts));
|
||||
|
||||
for (const category of allCategories) {
|
||||
@@ -2128,7 +2128,8 @@ export function useI18n() {
|
||||
let finalTotalBalance = '';
|
||||
|
||||
if (showAccountBalance) {
|
||||
const accountsBalance = getAllFilteredAccountsBalance(categorizedAccounts, account => account.category === accountCategory.category);
|
||||
const accountsBalance = getAllFilteredAccountsBalance(categorizedAccounts, customAccountCategoryOrder,
|
||||
account => account.category === accountCategory.category);
|
||||
let totalBalance = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Applica",
|
||||
"Save": "Salva",
|
||||
"Save Changes": "Salva modifiche",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Reimposta",
|
||||
"Update": "Aggiorna",
|
||||
"Refresh": "Aggiorna",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Pagina dati tassi di cambio",
|
||||
"Exchange Rate": "Tasso di cambio",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "適用",
|
||||
"Save": "保存",
|
||||
"Save Changes": "変更を保存",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "リセット",
|
||||
"Update": "アップデート",
|
||||
"Refresh": "リフレッシュ",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "為替レートデータページ",
|
||||
"Exchange Rate": "為替レート",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "ಅನ್ವಯಿಸು",
|
||||
"Save": "ಉಳಿಸು",
|
||||
"Save Changes": "ಬದಲಾವಣೆಗಳನ್ನು ಉಳಿಸು",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "ಮರುಹೊಂದಿಸು",
|
||||
"Update": "ನವೀಕರಿಸು",
|
||||
"Refresh": "ರಿಫ್ರೆಶ್",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "ಖಾತೆ ಪಟ್ಟಿ ಪುಟ",
|
||||
"Accounts Included in Total": "ಒಟ್ಟು ಮೊತ್ತದಲ್ಲಿ ಒಳಗೊಂಡ ಖಾತೆಗಳು",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "ವಿನಿಮಯ ದರಗಳ ಪುಟ",
|
||||
"Exchange Rate": "ವಿನಿಮಯ ದರ",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "적용",
|
||||
"Save": "저장",
|
||||
"Save Changes": "변경사항 저장",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "재설정",
|
||||
"Update": "업데이트",
|
||||
"Refresh": "새로고침",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "계좌 목록 페이지",
|
||||
"Accounts Included in Total": "총계에 포함된 계좌",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "환율 데이터 페이지",
|
||||
"Exchange Rate": "환율",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Toepassen",
|
||||
"Save": "Opslaan",
|
||||
"Save Changes": "Wijzigingen opslaan",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Resetten",
|
||||
"Update": "Bijwerken",
|
||||
"Refresh": "Vernieuwen",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Rekeningenpagina",
|
||||
"Accounts Included in Total": "Rekeningen opgenomen in totaal",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Wisselkoersgegevenspagina",
|
||||
"Exchange Rate": "Wisselkoers",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Aplicar",
|
||||
"Save": "Salvar",
|
||||
"Save Changes": "Salvar Alterações",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Redefinir",
|
||||
"Update": "Atualizar",
|
||||
"Refresh": "Atualizar",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Página de Dados de Taxas de Câmbio",
|
||||
"Exchange Rate": "Taxa de Câmbio",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Применить",
|
||||
"Save": "Сохранить",
|
||||
"Save Changes": "Сохранить изменения",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Сбросить",
|
||||
"Update": "Обновить",
|
||||
"Refresh": "Обновить",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Страница данных о курсах валют",
|
||||
"Exchange Rate": "Курс обмена",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Uporabi",
|
||||
"Save": "Shrani",
|
||||
"Save Changes": "Shrani spremembe",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Ponastavi",
|
||||
"Update": "Posodobi",
|
||||
"Refresh": "Osveži",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Stran za vpoglede in raziskovanje",
|
||||
"Account List Page": "Stran s seznamom računov",
|
||||
"Accounts Included in Total": "Računi vključeni v skupno vsoto",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Stran z menjalnimi tečaji",
|
||||
"Exchange Rate": "Menjalni tečaj",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "ใช้",
|
||||
"Save": "บันทึก",
|
||||
"Save Changes": "บันทึกการเปลี่ยนแปลง",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "รีเซ็ต",
|
||||
"Update": "อัปเดต",
|
||||
"Refresh": "รีเฟรช",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "หน้าบัญชี",
|
||||
"Accounts Included in Total": "บัญชีที่รวมในผลรวม",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "หน้าข้อมูลอัตราแลกเปลี่ยน",
|
||||
"Exchange Rate": "อัตราแลกเปลี่ยน",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Uygula",
|
||||
"Save": "Kaydet",
|
||||
"Save Changes": "Değişiklikleri Kaydet",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Sıfırla",
|
||||
"Update": "Güncelle",
|
||||
"Refresh": "Yenile",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Hesap Listesi Sayfası",
|
||||
"Accounts Included in Total": "Toplama Dahil Edilen Hesaplar",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Döviz Kuru Verileri Sayfası",
|
||||
"Exchange Rate": "Döviz Kuru",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Застосувати",
|
||||
"Save": "Зберегти",
|
||||
"Save Changes": "Зберегти зміни",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Скинути",
|
||||
"Update": "Оновити",
|
||||
"Refresh": "Оновити",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Сторінка курсів валют",
|
||||
"Exchange Rate": "Курс обміну",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "Áp dụng",
|
||||
"Save": "Lưu",
|
||||
"Save Changes": "Lưu thay đổi",
|
||||
"Reset to Default": "Reset to Default",
|
||||
"Reset": "Đặt lại",
|
||||
"Update": "Cập nhật",
|
||||
"Refresh": "Làm mới",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "Insights Explorer Page",
|
||||
"Account List Page": "Account List Page",
|
||||
"Accounts Included in Total": "Accounts Included in Total",
|
||||
"Account Category Order": "Account Category Order",
|
||||
"Account category order saved": "Account category order saved",
|
||||
"Unable to move account category": "Unable to move account category",
|
||||
"Hide Categories Without Accounts": "Hide Categories Without Accounts",
|
||||
"Exchange Rates Data Page": "Trang dữ liệu tỷ giá hối đoái",
|
||||
"Exchange Rate": "Tỷ giá hối đoái",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "应用",
|
||||
"Save": "保存",
|
||||
"Save Changes": "保存修改",
|
||||
"Reset to Default": "恢复为默认值",
|
||||
"Reset": "重置",
|
||||
"Update": "更新",
|
||||
"Refresh": "刷新",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "洞察探索页面",
|
||||
"Account List Page": "账户列表页面",
|
||||
"Accounts Included in Total": "计入总金额的账户",
|
||||
"Account Category Order": "账户分类顺序",
|
||||
"Account category order saved": "账户分类顺序已保存",
|
||||
"Unable to move account category": "无法移动账户分类",
|
||||
"Hide Categories Without Accounts": "隐藏没有账户的分类",
|
||||
"Exchange Rates Data Page": "汇率数据页面",
|
||||
"Exchange Rate": "汇率",
|
||||
|
||||
@@ -1435,6 +1435,7 @@
|
||||
"Apply": "套用",
|
||||
"Save": "儲存",
|
||||
"Save Changes": "儲存修改",
|
||||
"Reset to Default": "重設為預設值",
|
||||
"Reset": "重置",
|
||||
"Update": "更新",
|
||||
"Refresh": "重新載入",
|
||||
@@ -2190,6 +2191,9 @@
|
||||
"Insights Explorer Page": "洞察探索頁面",
|
||||
"Account List Page": "帳戶清單頁面",
|
||||
"Accounts Included in Total": "計入總金額的帳戶",
|
||||
"Account Category Order": "帳戶分類順序",
|
||||
"Account category order saved": "帳戶分類順序已儲存",
|
||||
"Unable to move account category": "無法移動帳戶分類",
|
||||
"Hide Categories Without Accounts": "隱藏沒有帳戶的分類",
|
||||
"Exchange Rates Data Page": "匯率資料頁面",
|
||||
"Exchange Rate": "匯率",
|
||||
|
||||
+9
-10
@@ -2,7 +2,6 @@ import type { HiddenAmount, NumberWithSuffix } from '@/core/numeral.ts';
|
||||
import type { ColorValue } from '@/core/color.ts';
|
||||
import { AccountType, AccountCategory } from '@/core/account.ts';
|
||||
import { PARENT_ACCOUNT_CURRENCY_PLACEHOLDER } from '@/consts/currency.ts';
|
||||
import { DEFAULT_ACCOUNT_ICON_ID } from '@/consts/icon.ts';
|
||||
import { DEFAULT_ACCOUNT_COLOR } from '@/consts/color.ts';
|
||||
|
||||
export class Account implements AccountInfoResponse {
|
||||
@@ -410,14 +409,14 @@ export class Account implements AccountInfoResponse {
|
||||
);
|
||||
}
|
||||
|
||||
public static createNewAccount(currency: string, balanceTime: number): Account {
|
||||
public static createNewAccount(accountCategory: AccountCategory, currency: string, balanceTime: number): Account {
|
||||
return new Account(
|
||||
'', // id
|
||||
'', // name
|
||||
'', // parentId
|
||||
AccountCategory.Cash.type, // category
|
||||
accountCategory.type, // category
|
||||
AccountType.SingleAccount.type, // type
|
||||
DEFAULT_ACCOUNT_ICON_ID, // icon
|
||||
accountCategory.defaultAccountIconId, // icon
|
||||
DEFAULT_ACCOUNT_COLOR, // color
|
||||
currency, // currency
|
||||
0, // balance
|
||||
@@ -481,25 +480,25 @@ export class Account implements AccountInfoResponse {
|
||||
return clonedAccounts;
|
||||
}
|
||||
|
||||
public static sortAccounts(accounts: Account[], allAccountsMap?: Record<string, Account>): Account[] {
|
||||
public static sortAccounts(accounts: Account[], accountCategoryDisplayOrders: Record<number, number>, allAccountsMap?: Record<string, Account>): Account[] {
|
||||
if (!accounts || !accounts.length) {
|
||||
return accounts;
|
||||
}
|
||||
|
||||
return accounts.sort(function (account1, account2) {
|
||||
if (account1.category !== account2.category) {
|
||||
const account1Category = AccountCategory.valueOf(account1.category);
|
||||
const account2Category = AccountCategory.valueOf(account2.category);
|
||||
const account1CategoryDisplayOrder = accountCategoryDisplayOrders[account1.category];
|
||||
const account2CategoryDisplayOrder = accountCategoryDisplayOrders[account2.category];
|
||||
|
||||
if (!account1Category) {
|
||||
if (!account1CategoryDisplayOrder) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!account2Category) {
|
||||
if (!account2CategoryDisplayOrder) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return account1Category.displayOrder - account2Category.displayOrder;
|
||||
return account1CategoryDisplayOrder - account2CategoryDisplayOrder;
|
||||
}
|
||||
|
||||
if (account1.parentId === account2.parentId) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import StatisticsSettingsPage from '@/views/mobile/statistics/SettingsPage.vue';
|
||||
|
||||
import TextSizeSettingsPage from '@/views/mobile/settings/TextSizeSettingsPage.vue';
|
||||
import PageSettingsPage from '@/views/mobile/settings/PageSettingsPage.vue';
|
||||
import AccountCategoryDisplayOrderSettingsPage from '@/views/mobile/settings/AccountCategoryDisplayOrderSettingsPage.vue';
|
||||
import ApplicationCloudSyncSettingsPage from '@/views/mobile/settings/ApplicationCloudSyncSettingsPage.vue';
|
||||
import AccountFilterSettingsPage from '@/views/mobile/settings/AccountFilterSettingsPage.vue';
|
||||
import CategoryFilterSettingsPage from '@/views/mobile/settings/CategoryFilterSettingsPage.vue';
|
||||
@@ -238,6 +239,11 @@ const routes: Router.RouteParameters[] = [
|
||||
async: asyncResolve(PageSettingsPage),
|
||||
beforeEnter: [checkLogin]
|
||||
},
|
||||
{
|
||||
path: '/settings/account_category_display_order',
|
||||
async: asyncResolve(AccountCategoryDisplayOrderSettingsPage),
|
||||
beforeEnter: [checkLogin]
|
||||
},
|
||||
{
|
||||
path: '/settings/sync',
|
||||
async: asyncResolve(ApplicationCloudSyncSettingsPage),
|
||||
|
||||
+15
-12
@@ -48,7 +48,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
}
|
||||
|
||||
return Account.sortAccounts(allAccountsList, allAccountsMap.value);
|
||||
return Account.sortAccounts(allAccountsList, settingsStore.accountCategoryDisplayOrders, allAccountsMap.value);
|
||||
});
|
||||
|
||||
const allMixedPlainAccounts = computed<Account[]>(() => {
|
||||
@@ -68,7 +68,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
}
|
||||
|
||||
return Account.sortAccounts(allAccountsList, allAccountsMap.value);
|
||||
return Account.sortAccounts(allAccountsList, settingsStore.accountCategoryDisplayOrders, allAccountsMap.value);
|
||||
});
|
||||
|
||||
const allVisiblePlainAccounts = computed<Account[]>(() => {
|
||||
@@ -95,7 +95,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
}
|
||||
}
|
||||
|
||||
return Account.sortAccounts(allVisibleAccounts, allAccountsMap.value);
|
||||
return Account.sortAccounts(allVisibleAccounts, settingsStore.accountCategoryDisplayOrders, allAccountsMap.value);
|
||||
});
|
||||
|
||||
const allAvailableAccountsCount = computed<number>(() => {
|
||||
@@ -148,8 +148,10 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
if (newAccountCategory) {
|
||||
for (const [account, index] of itemAndIndex(allAccounts.value)) {
|
||||
const accountCategory = AccountCategory.valueOf(account.category);
|
||||
const accountCategoryDisplayOrder = settingsStore.accountCategoryDisplayOrders[accountCategory?.type ?? 0] || Number.MAX_SAFE_INTEGER;
|
||||
const newAccountCategoryDisplayOrder = settingsStore.accountCategoryDisplayOrders[newAccountCategory.type] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
if (accountCategory && accountCategory.displayOrder > newAccountCategory.displayOrder) {
|
||||
if (accountCategory && accountCategoryDisplayOrder > newAccountCategoryDisplayOrder) {
|
||||
insertIndexToAllList = index;
|
||||
break;
|
||||
}
|
||||
@@ -457,8 +459,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
return DISPLAY_HIDDEN_AMOUNT;
|
||||
}
|
||||
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account =>
|
||||
!(account.type === AccountType.SingleAccount.type && settingsStore.appSettings.totalAmountExcludeAccountIds[account.id])
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, settingsStore.appSettings.accountCategoryOrders,
|
||||
account => !(account.type === AccountType.SingleAccount.type && settingsStore.appSettings.totalAmountExcludeAccountIds[account.id])
|
||||
);
|
||||
let netAssets = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
@@ -493,8 +495,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
return DISPLAY_HIDDEN_AMOUNT;
|
||||
}
|
||||
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account =>
|
||||
(account.isAsset || false) && !(account.type === AccountType.SingleAccount.type && settingsStore.appSettings.totalAmountExcludeAccountIds[account.id])
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, settingsStore.appSettings.accountCategoryOrders,
|
||||
account => (account.isAsset || false) && !(account.type === AccountType.SingleAccount.type && settingsStore.appSettings.totalAmountExcludeAccountIds[account.id])
|
||||
);
|
||||
let totalAssets = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
@@ -529,8 +531,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
return DISPLAY_HIDDEN_AMOUNT;
|
||||
}
|
||||
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account =>
|
||||
(account.isLiability || false) && !(account.type === AccountType.SingleAccount.type && settingsStore.appSettings.totalAmountExcludeAccountIds[account.id])
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, settingsStore.appSettings.accountCategoryOrders,
|
||||
account => (account.isLiability || false) && !(account.type === AccountType.SingleAccount.type && settingsStore.appSettings.totalAmountExcludeAccountIds[account.id])
|
||||
);
|
||||
let totalLiabilities = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
@@ -565,7 +567,8 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
return DISPLAY_HIDDEN_AMOUNT;
|
||||
}
|
||||
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, account => account.category === accountCategory.type);
|
||||
const accountsBalance = getAllFilteredAccountsBalance(allCategorizedAccountsMap.value, settingsStore.appSettings.accountCategoryOrders,
|
||||
account => account.category === accountCategory.type);
|
||||
let totalBalance = 0;
|
||||
let hasUnCalculatedAmount = false;
|
||||
|
||||
@@ -775,7 +778,7 @@ export const useAccountsStore = defineStore('accounts', () => {
|
||||
updateAccountListInvalidState(false);
|
||||
}
|
||||
|
||||
const accounts = Account.sortAccounts(Account.ofMulti(data.result));
|
||||
const accounts = Account.sortAccounts(Account.ofMulti(data.result), settingsStore.accountCategoryDisplayOrders);
|
||||
|
||||
if (force && data.result && isEquals(allAccounts.value, accounts)) {
|
||||
reject({ message: 'Account list is up to date', isUpToDate: true });
|
||||
|
||||
@@ -296,23 +296,25 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
};
|
||||
} else if (dimension === TransactionExplorerDataDimension.SourceAccount) {
|
||||
const primaryAccount = accountsStore.allAccountsMap[transaction.sourceAccount.parentId] ?? transaction.sourceAccount;
|
||||
const primaryAccountCategoryDisplayOrder: number = settingsStore.accountCategoryDisplayOrders[primaryAccount.category] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
return {
|
||||
categoryName: transaction.sourceAccountName || 'Unknown',
|
||||
categoryNameNeedI18n: !transaction.sourceAccountName,
|
||||
categoryId: transaction.sourceAccountId || 'unknown',
|
||||
categoryIdType: TransactionExplorerDimensionType.Account,
|
||||
categoryDisplayOrders: [primaryAccount.category, primaryAccount.displayOrder, transaction.sourceAccount.displayOrder]
|
||||
categoryDisplayOrders: [primaryAccountCategoryDisplayOrder, primaryAccount.displayOrder, transaction.sourceAccount.displayOrder]
|
||||
};
|
||||
} else if (dimension === TransactionExplorerDataDimension.SourceAccountCategory) {
|
||||
const accountCategory = AccountCategory.valueOf(transaction.sourceAccount.category);
|
||||
const accountCategoryDisplayOrder: number = settingsStore.accountCategoryDisplayOrders[accountCategory?.type ?? 0] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
return {
|
||||
categoryName: accountCategory?.name || 'Unknown',
|
||||
categoryNameNeedI18n: true,
|
||||
categoryId: accountCategory?.type.toString(10) || 'unknown',
|
||||
categoryIdType: TransactionExplorerDimensionType.Other,
|
||||
categoryDisplayOrders: [accountCategory ? accountCategory.type : 0]
|
||||
categoryDisplayOrders: [accountCategoryDisplayOrder]
|
||||
};
|
||||
} else if (dimension === TransactionExplorerDataDimension.SourceAccountCurrency) {
|
||||
return {
|
||||
@@ -324,23 +326,25 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
};
|
||||
} else if (dimension === TransactionExplorerDataDimension.DestinationAccount) {
|
||||
const primaryAccount = accountsStore.allAccountsMap[transaction.destinationAccount?.parentId ?? ''] ?? transaction.destinationAccount;
|
||||
const primaryAccountCategoryDisplayOrder: number = settingsStore.accountCategoryDisplayOrders[primaryAccount?.category || 0] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
return {
|
||||
categoryName: transaction.type === TransactionType.Transfer ? (transaction.destinationAccountName || 'Unknown') : 'None',
|
||||
categoryNameNeedI18n: transaction.type !== TransactionType.Transfer || !transaction.destinationAccountName,
|
||||
categoryId: transaction.type === TransactionType.Transfer ? (transaction.destinationAccountId || 'unknown') : 'none',
|
||||
categoryIdType: TransactionExplorerDimensionType.Account,
|
||||
categoryDisplayOrders: transaction.type === TransactionType.Transfer && primaryAccount && transaction.destinationAccount ? [primaryAccount.category, primaryAccount.displayOrder, transaction.destinationAccount.displayOrder] : [0]
|
||||
categoryDisplayOrders: transaction.type === TransactionType.Transfer && primaryAccount && transaction.destinationAccount ? [primaryAccountCategoryDisplayOrder, primaryAccount.displayOrder, transaction.destinationAccount.displayOrder] : [0]
|
||||
};
|
||||
} else if (dimension === TransactionExplorerDataDimension.DestinationAccountCategory) {
|
||||
const accountCategory = transaction.type === TransactionType.Transfer && transaction.destinationAccount ? AccountCategory.valueOf(transaction.destinationAccount.category) : undefined;
|
||||
const accountCategoryDisplayOrder: number = settingsStore.accountCategoryDisplayOrders[accountCategory?.type ?? 0] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
return {
|
||||
categoryName: transaction.type === TransactionType.Transfer ? (accountCategory?.name || 'Unknown') : 'None',
|
||||
categoryNameNeedI18n: true,
|
||||
categoryId: transaction.type === TransactionType.Transfer ? (accountCategory?.name || 'unknown') : 'none',
|
||||
categoryIdType: TransactionExplorerDimensionType.Other,
|
||||
categoryDisplayOrders: transaction.type === TransactionType.Transfer ? [accountCategory?.type || 0] : [0]
|
||||
categoryDisplayOrders: transaction.type === TransactionType.Transfer ? [accountCategoryDisplayOrder] : [0]
|
||||
};
|
||||
} else if (dimension === TransactionExplorerDataDimension.DestinationAccountCurrency) {
|
||||
return {
|
||||
|
||||
@@ -15,6 +15,9 @@ import {
|
||||
ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES
|
||||
} from '@/core/setting.ts';
|
||||
|
||||
|
||||
import { AccountCategory } from '@/core/account.ts';
|
||||
|
||||
import {
|
||||
isObject,
|
||||
isString,
|
||||
@@ -41,6 +44,8 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
|
||||
const enableApplicationCloudSync = computed<boolean>(() => getObjectOwnFieldCount(syncedAppSettings.value) > 0);
|
||||
|
||||
const accountCategoryDisplayOrders = computed<Record<number, number>>(() => AccountCategory.allDisplayOrders(appSettings.value.accountCategoryOrders));
|
||||
|
||||
function updateApplicationSettingsValueAndAppSettingsFromCloudSetting(key: string, value: string | number | boolean | Record<string, boolean>): void {
|
||||
const keyItems = key.split('.');
|
||||
const keyFirstPart = keyItems[0] as string;
|
||||
@@ -265,6 +270,12 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
updateUserApplicationCloudSettingValue('totalAmountExcludeAccountIds', value);
|
||||
}
|
||||
|
||||
function setAccountCategoryOrders(value: string): void {
|
||||
updateApplicationSettingsValue('accountCategoryOrders', value);
|
||||
appSettings.value.accountCategoryOrders = value;
|
||||
updateUserApplicationCloudSettingValue('accountCategoryOrders', value);
|
||||
}
|
||||
|
||||
function setHideCategoriesWithoutAccounts(value: boolean): void {
|
||||
updateApplicationSettingsValue('hideCategoriesWithoutAccounts', value);
|
||||
appSettings.value.hideCategoriesWithoutAccounts = value;
|
||||
@@ -459,6 +470,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
localeDefaultSettings,
|
||||
// computed states
|
||||
enableApplicationCloudSync,
|
||||
accountCategoryDisplayOrders,
|
||||
// functions
|
||||
// -- Basic Settings
|
||||
setTheme,
|
||||
@@ -491,6 +503,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
setShowTagInInsightsExplorerPage,
|
||||
// -- Account List Page
|
||||
setTotalAmountExcludeAccountIds,
|
||||
setAccountCategoryOrders,
|
||||
setHideCategoriesWithoutAccounts,
|
||||
// -- Exchange Rates Data Page
|
||||
setCurrencySortByInExchangeRatesPage,
|
||||
|
||||
@@ -284,6 +284,7 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
totalExpense += item.amountInDefaultCurrency;
|
||||
}
|
||||
|
||||
const primaryAccountCategoryDisplayOrder = settingsStore.accountCategoryDisplayOrders[item.primaryAccount.category] || Number.MAX_SAFE_INTEGER;
|
||||
const incomeByAccountKey = `${TransactionCategoricalOverviewAnalysisDataItemType.IncomeByAccount}:${item.account.id}`;
|
||||
const expenseByAccountKey = `${TransactionCategoricalOverviewAnalysisDataItemType.ExpenseByAccount}:${item.account.id}`;
|
||||
let incomeByAccountItem: TransactionCategoricalOverviewAnalysisDataItem | undefined = allDataItemsMap[incomeByAccountKey];
|
||||
@@ -294,7 +295,7 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
item.account.id,
|
||||
item.account.name,
|
||||
TransactionCategoricalOverviewAnalysisDataItemType.IncomeByAccount,
|
||||
[item.primaryAccount.category, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
[primaryAccountCategoryDisplayOrder, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
item.primaryAccount.hidden || item.account.hidden);
|
||||
allDataItemsMap[incomeByAccountKey] = incomeByAccountItem;
|
||||
allIncomeByAccountDataItems.push(incomeByAccountItem);
|
||||
@@ -305,7 +306,7 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
item.account.id,
|
||||
item.account.name,
|
||||
TransactionCategoricalOverviewAnalysisDataItemType.ExpenseByAccount,
|
||||
[item.primaryAccount.category, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
[primaryAccountCategoryDisplayOrder, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
item.primaryAccount.hidden || item.account.hidden);
|
||||
allDataItemsMap[expenseByAccountKey] = expenseByAccountItem;
|
||||
allExpenseByAccountDataItems.push(expenseByAccountItem);
|
||||
@@ -404,11 +405,12 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
let transferToAccountItem: TransactionCategoricalOverviewAnalysisDataItem | undefined = allDataItemsMap[transferToAccountKey];
|
||||
|
||||
if (!transferToAccountItem) {
|
||||
const relatedPrimaryAccountCategoryDisplayOrder = settingsStore.accountCategoryDisplayOrders[item.relatedPrimaryAccount.category] || Number.MAX_SAFE_INTEGER;
|
||||
transferToAccountItem = createNewTransactionCategoricalOverviewAnalysisDataItem(
|
||||
item.relatedAccount.id,
|
||||
item.relatedAccount.name,
|
||||
TransactionCategoricalOverviewAnalysisDataItemType.ExpenseByAccount,
|
||||
[item.relatedPrimaryAccount.category, item.relatedPrimaryAccount.displayOrder, item.relatedAccount.displayOrder],
|
||||
[relatedPrimaryAccountCategoryDisplayOrder, item.relatedPrimaryAccount.displayOrder, item.relatedAccount.displayOrder],
|
||||
item.relatedPrimaryAccount.hidden || item.relatedAccount.hidden);
|
||||
allDataItemsMap[transferToAccountKey] = transferToAccountItem;
|
||||
allExpenseByAccountDataItems.push(transferToAccountItem);
|
||||
@@ -543,6 +545,8 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
primaryAccount = account;
|
||||
}
|
||||
|
||||
const primaryAccountCategoryDisplayOrder = settingsStore.accountCategoryDisplayOrders[primaryAccount.category] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
let amount = account.balance;
|
||||
|
||||
if (account.currency !== userStore.currentUserDefaultCurrency) {
|
||||
@@ -566,7 +570,7 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
icon: account.icon || DEFAULT_ACCOUNT_ICON.icon,
|
||||
color: account.color || DEFAULT_ACCOUNT_COLOR,
|
||||
hidden: primaryAccount.hidden || account.hidden,
|
||||
displayOrders: [primaryAccount.category, primaryAccount.displayOrder, account.displayOrder],
|
||||
displayOrders: [primaryAccountCategoryDisplayOrder, primaryAccount.displayOrder, account.displayOrder],
|
||||
totalAmount: amount
|
||||
};
|
||||
|
||||
@@ -888,6 +892,8 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
if (data) {
|
||||
data.totalAmount += amount;
|
||||
} else {
|
||||
const primaryAccountCategoryDisplayOrder = settingsStore.accountCategoryDisplayOrders[item.primaryAccount.category] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
data = {
|
||||
name: item.account.name,
|
||||
type: 'account',
|
||||
@@ -895,7 +901,7 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
icon: item.account.icon || DEFAULT_ACCOUNT_ICON.icon,
|
||||
color: item.account.color || DEFAULT_ACCOUNT_COLOR,
|
||||
hidden: item.primaryAccount.hidden || item.account.hidden,
|
||||
displayOrders: [item.primaryAccount.category, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
displayOrders: [primaryAccountCategoryDisplayOrder, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
totalAmount: amount,
|
||||
items: []
|
||||
};
|
||||
@@ -1131,6 +1137,8 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
if (data) {
|
||||
data.totalAmount += item.amountInDefaultCurrency;
|
||||
} else {
|
||||
const primaryAccountCategoryDisplayOrder = settingsStore.accountCategoryDisplayOrders[item.primaryAccount.category] || Number.MAX_SAFE_INTEGER;
|
||||
|
||||
data = {
|
||||
name: item.account.name,
|
||||
type: 'account',
|
||||
@@ -1138,7 +1146,7 @@ export const useStatisticsStore = defineStore('statistics', () => {
|
||||
icon: item.account.icon || DEFAULT_ACCOUNT_ICON.icon,
|
||||
color: item.account.color || DEFAULT_ACCOUNT_COLOR,
|
||||
hidden: item.primaryAccount.hidden || item.account.hidden,
|
||||
displayOrders: [item.primaryAccount.category, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
displayOrders: [primaryAccountCategoryDisplayOrder, item.primaryAccount.displayOrder, item.account.displayOrder],
|
||||
totalAmount: item.amountInDefaultCurrency
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ref, computed, watch } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { useSettingsStore } from '@/stores/setting.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
|
||||
import type { TypeAndDisplayName } from '@/core/base.ts';
|
||||
@@ -25,13 +26,16 @@ export interface DayAndDisplayName {
|
||||
export function useAccountEditPageBase() {
|
||||
const { tt, getAllAccountCategories, getAllAccountTypes, getMonthdayShortName } = useI18n();
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const defaultAccountCategory = AccountCategory.values(settingsStore.appSettings.accountCategoryOrders)[0] ?? AccountCategory.Default;
|
||||
|
||||
const editAccountId = ref<string | null>(null);
|
||||
const clientSessionId = ref<string>('');
|
||||
const loading = ref<boolean>(false);
|
||||
const submitting = ref<boolean>(false);
|
||||
const account = ref<Account>(Account.createNewAccount(userStore.currentUserDefaultCurrency, getCurrentUnixTimeForNewAccount()));
|
||||
const account = ref<Account>(Account.createNewAccount(defaultAccountCategory, userStore.currentUserDefaultCurrency, getCurrentUnixTimeForNewAccount()));
|
||||
const subAccounts = ref<Account[]>([]);
|
||||
|
||||
const title = computed<string>(() => {
|
||||
@@ -72,7 +76,8 @@ export function useAccountEditPageBase() {
|
||||
|
||||
const inputIsEmpty = computed<boolean>(() => !!inputEmptyProblemMessage.value);
|
||||
|
||||
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories());
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories(customAccountCategoryOrder.value));
|
||||
const allAccountTypes = computed<TypeAndDisplayName[]>(() => getAllAccountTypes());
|
||||
|
||||
const allAvailableMonthDays = computed<DayAndDisplayName[]>(() => {
|
||||
@@ -181,6 +186,8 @@ export function useAccountEditPageBase() {
|
||||
});
|
||||
|
||||
return {
|
||||
// constants
|
||||
defaultAccountCategory,
|
||||
// states
|
||||
editAccountId,
|
||||
clientSessionId,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useAccountsStore } from '@/stores/account.ts';
|
||||
|
||||
import type { HiddenAmount, NumberWithSuffix } from '@/core/numeral.ts';
|
||||
import type { WeekDayValue } from '@/core/datetime.ts';
|
||||
import { type AccountCategory, AccountType } from '@/core/account.ts';
|
||||
import { AccountCategory, AccountType } from '@/core/account.ts';
|
||||
import type { Account, CategorizedAccount } from '@/models/account.ts';
|
||||
|
||||
import { isObject, isNumber, isString } from '@/lib/common.ts';
|
||||
@@ -29,6 +29,9 @@ export function useAccountListPageBase() {
|
||||
set: (value) => settingsStore.setShowAccountBalance(value)
|
||||
});
|
||||
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const defaultAccountCategory = computed<AccountCategory>(() => AccountCategory.values(customAccountCategoryOrder.value)[0] ?? AccountCategory.Default);
|
||||
|
||||
const firstDayOfWeek = computed<WeekDayValue>(() => userStore.currentUserFirstDayOfWeek);
|
||||
const fiscalYearStart = computed<number>(() => userStore.currentUserFiscalYearStart);
|
||||
const defaultCurrency = computed<string>(() => userStore.currentUserDefaultCurrency);
|
||||
@@ -90,6 +93,8 @@ export function useAccountListPageBase() {
|
||||
displayOrderModified,
|
||||
// computed states
|
||||
showAccountBalance,
|
||||
customAccountCategoryOrder,
|
||||
defaultAccountCategory,
|
||||
firstDayOfWeek,
|
||||
fiscalYearStart,
|
||||
defaultCurrency,
|
||||
|
||||
@@ -19,9 +19,10 @@ export function useMoveAllTransactionsPageBase() {
|
||||
const toAccountName = ref<string>('');
|
||||
|
||||
const showAccountBalance = computed<boolean>(() => settingsStore.appSettings.showAccountBalance);
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value));
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value, customAccountCategoryOrder.value));
|
||||
|
||||
const displayToAccountName = computed<string>(() => {
|
||||
if (!toAccountId.value) {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { AccountCategory } from '@/core/account.ts';
|
||||
|
||||
import { useSettingsStore } from '@/stores/setting.ts';
|
||||
|
||||
export function useAccountCategoryDisplayOrderSettingsPageBase() {
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
const accountCategories = ref<AccountCategory[]>(AccountCategory.values(settingsStore.appSettings.accountCategoryOrders));
|
||||
|
||||
function isDisplayOrderModified(): boolean {
|
||||
const currentOrders = AccountCategory.values(settingsStore.appSettings.accountCategoryOrders);
|
||||
|
||||
if (currentOrders.length !== accountCategories.value.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (let i = 0; i < currentOrders.length; i++) {
|
||||
const accountCategory = accountCategories.value[i];
|
||||
const currentCategory = currentOrders[i];
|
||||
|
||||
if (!accountCategory || !currentCategory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (accountCategory.type !== currentCategory.type) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadDisplayOrderFromSettings(): void {
|
||||
accountCategories.value = AccountCategory.values(settingsStore.appSettings.accountCategoryOrders);
|
||||
}
|
||||
|
||||
function saveDisplayOrderToSettings(): void {
|
||||
const displayOrders = accountCategories.value.map(category => category.type).join(',');
|
||||
const defaultOrders = AccountCategory.values('').map(category => category.type).join(',');
|
||||
|
||||
if (displayOrders === defaultOrders) {
|
||||
settingsStore.setAccountCategoryOrders('');
|
||||
} else {
|
||||
settingsStore.setAccountCategoryOrders(displayOrders);
|
||||
}
|
||||
}
|
||||
|
||||
function resetDisplayOrderToDefault(): void {
|
||||
accountCategories.value = AccountCategory.values('');
|
||||
}
|
||||
|
||||
return {
|
||||
// states
|
||||
accountCategories,
|
||||
// functions
|
||||
isDisplayOrderModified,
|
||||
loadDisplayOrderFromSettings,
|
||||
saveDisplayOrderToSettings,
|
||||
resetDisplayOrderToDefault
|
||||
};
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { useStatisticsStore } from '@/stores/statistics.ts';
|
||||
import { useOverviewStore } from '@/stores/overview.ts';
|
||||
|
||||
import { keys, keysIfValueEquals, values } from '@/core/base.ts';
|
||||
import type {Account, CategorizedAccount} from '@/models/account.ts';
|
||||
import type { Account, CategorizedAccount } from '@/models/account.ts';
|
||||
|
||||
import {
|
||||
filterCategorizedAccounts,
|
||||
@@ -49,11 +49,12 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType, select
|
||||
return type === 'statisticsDefault' || type === 'statisticsCurrent' || type === 'homePageOverview' || type === 'transactionListCurrent' || type === 'custom';
|
||||
});
|
||||
|
||||
const allCategorizedAccounts = computed<Record<number, CategorizedAccount>>(() => filterCategorizedAccounts(accountsStore.allCategorizedAccountsMap, filterContent.value, showHidden.value));
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const allCategorizedAccounts = computed<CategorizedAccount[]>(() => filterCategorizedAccounts(accountsStore.allCategorizedAccountsMap, customAccountCategoryOrder.value, filterContent.value, showHidden.value));
|
||||
const allVisibleAccountMap = computed<Record<string, Account>>(() => {
|
||||
const accountMap: Record<string, Account> = {};
|
||||
|
||||
for (const accountCategory of values(allCategorizedAccounts.value)) {
|
||||
for (const accountCategory of allCategorizedAccounts.value) {
|
||||
for (const account of accountCategory.accounts) {
|
||||
accountMap[account.id] = account;
|
||||
|
||||
@@ -69,7 +70,7 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType, select
|
||||
});
|
||||
const hasAnyAvailableAccount = computed<boolean>(() => accountsStore.allAvailableAccountsCount > 0);
|
||||
const hasAnyVisibleAccount = computed<boolean>(() => {
|
||||
for (const accountCategory of values(allCategorizedAccounts.value)) {
|
||||
for (const accountCategory of allCategorizedAccounts.value) {
|
||||
if (accountCategory.accounts.length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -204,6 +205,7 @@ export function useAccountFilterSettingPageBase(type?: AccountFilterType, select
|
||||
title,
|
||||
applyText,
|
||||
allowHiddenAccount,
|
||||
customAccountCategoryOrder,
|
||||
allCategorizedAccounts,
|
||||
allVisibleAccountMap,
|
||||
hasAnyAvailableAccount,
|
||||
|
||||
@@ -61,6 +61,7 @@ export const ALL_APPLICATION_CLOUD_SETTINGS: CategorizedApplicationCloudSettingI
|
||||
categoryName: 'Account List Page',
|
||||
items: [
|
||||
{ settingKey: 'totalAmountExcludeAccountIds', settingName: 'Accounts Included in Total', mobile: true, desktop: true },
|
||||
{ settingKey: 'accountCategoryOrders', settingName: 'Account Category Order', mobile: true, desktop: true },
|
||||
{ settingKey: 'hideCategoriesWithoutAccounts', settingName: 'Hide Categories Without Accounts', mobile: false, desktop: true }
|
||||
]
|
||||
},
|
||||
|
||||
@@ -134,6 +134,14 @@ export function useAppSettingPageBase() {
|
||||
return getIncludedAccountsDisplayContent(excludeAccountIds, accountsStore.allVisiblePlainAccounts);
|
||||
});
|
||||
|
||||
const accountCategorysDisplayOrderContent = computed<string>(() => {
|
||||
if (!settingsStore.appSettings.accountCategoryOrders) {
|
||||
return tt('Default');
|
||||
}
|
||||
|
||||
return tt('Custom');
|
||||
});
|
||||
|
||||
const transactionCategoriesIncludedInHomePageOverviewDisplayContent = computed<string>(() => {
|
||||
const excludeAccountIds = settingsStore.appSettings.overviewTransactionCategoryFilterInHomePage;
|
||||
return getIncludedTransactionCategoriesDisplayContent(excludeAccountIds);
|
||||
@@ -237,6 +245,7 @@ export function useAppSettingPageBase() {
|
||||
currencySortByInExchangeRatesPage,
|
||||
accountsIncludedInHomePageOverviewDisplayContent,
|
||||
accountsIncludedInTotalDisplayContent,
|
||||
accountCategorysDisplayOrderContent,
|
||||
transactionCategoriesIncludedInHomePageOverviewDisplayContent
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ export function useTransactionEditPageBase(type: TransactionEditPageType, initMo
|
||||
const numeralSystem = computed<NumeralSystem>(() => getCurrentNumeralSystemType());
|
||||
const currentTimezoneOffsetMinutes = computed<number>(() => getTimezoneOffsetMinutes(transaction.value.time));
|
||||
const showAccountBalance = computed<boolean>(() => settingsStore.appSettings.showAccountBalance);
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const defaultCurrency = computed<string>(() => userStore.currentUserDefaultCurrency);
|
||||
const defaultAccountId = computed<string>(() => userStore.currentUserDefaultAccountId);
|
||||
const firstDayOfWeek = computed<WeekDayValue>(() => userStore.currentUserFirstDayOfWeek);
|
||||
@@ -105,7 +106,7 @@ export function useTransactionEditPageBase(type: TransactionEditPageType, initMo
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||
const allAccountsMap = computed<Record<string, Account>>(() => accountsStore.allAccountsMap);
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value));
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value, customAccountCategoryOrder.value));
|
||||
const allCategories = computed<Record<number, TransactionCategory[]>>(() => transactionCategoriesStore.allTransactionCategories);
|
||||
const allCategoriesMap = computed<Record<string, TransactionCategory>>(() => transactionCategoriesStore.allTransactionCategoriesMap);
|
||||
const allTags = computed<TransactionTag[]>(() => transactionTagsStore.allTransactionTags);
|
||||
|
||||
@@ -68,7 +68,7 @@ export function useUserProfilePageBase() {
|
||||
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccount[]>(() => getCategorizedAccounts(allVisibleAccounts.value));
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccount[]>(() => getCategorizedAccounts(allVisibleAccounts.value, settingsStore.appSettings.accountCategoryOrders));
|
||||
const allWeekDays = computed<TypeAndDisplayName[]>(() => getAllWeekDays());
|
||||
const allCalendarDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllCalendarDisplayTypes());
|
||||
const allDateDisplayTypes = computed<TypeAndDisplayName[]>(() => getAllDateDisplayTypes());
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<v-tabs show-arrows class="account-category-tabs my-4" direction="vertical"
|
||||
:disabled="loading" v-model="activeAccountCategoryType">
|
||||
<v-tab class="tab-text-truncate" :key="accountCategory.type" :value="accountCategory.type"
|
||||
v-for="accountCategory in AccountCategory.values()"
|
||||
v-for="accountCategory in AccountCategory.values(customAccountCategoryOrder)"
|
||||
v-show="!hideAccountCategoriesWithoutAccounts || (allCategorizedAccountsMap[accountCategory.type] && allCategorizedAccountsMap[accountCategory.type]!.accounts.length > 0)">
|
||||
<ItemIcon icon-type="account" :icon-id="accountCategory.defaultAccountIconId" />
|
||||
<div class="d-flex flex-column text-truncate ms-2">
|
||||
@@ -372,6 +372,8 @@ const {
|
||||
showHidden,
|
||||
displayOrderModified,
|
||||
showAccountBalance,
|
||||
customAccountCategoryOrder,
|
||||
defaultAccountCategory,
|
||||
firstDayOfWeek,
|
||||
fiscalYearStart,
|
||||
allAccounts,
|
||||
@@ -394,7 +396,7 @@ const reconciliationStatementDialog = useTemplateRef<ReconciliationStatementDial
|
||||
const moveAllTransactionsDialog = useTemplateRef<MoveAllTransactionsDialogType>('moveAllTransactionsDialog');
|
||||
const clearAllTransactionsDialog = useTemplateRef<ClearAllTransactionsDialogType>('clearAllTransactionsDialog');
|
||||
|
||||
const activeAccountCategoryType = ref<number>(AccountCategory.Default.type);
|
||||
const activeAccountCategoryType = ref<number>(defaultAccountCategory.value.type);
|
||||
const activeTab = ref<string>('accountPage');
|
||||
const activeSubAccount = ref<Record<string, string>>({});
|
||||
const accountToShowReconciliationStatement = ref<Account | null>(null);
|
||||
|
||||
@@ -229,6 +229,7 @@ type SnackBarType = InstanceType<typeof SnackBar>;
|
||||
|
||||
const { tt } = useI18n();
|
||||
const {
|
||||
defaultAccountCategory,
|
||||
editAccountId,
|
||||
clientSessionId,
|
||||
loading,
|
||||
@@ -279,7 +280,7 @@ const accountAmountTitle = computed<string>(() => {
|
||||
|
||||
const isAccountModified = computed<boolean>(() => {
|
||||
if (!editAccountId.value) {
|
||||
return !account.value.equals(Account.createNewAccount(userStore.currentUserDefaultCurrency, account.value.balanceTime ?? getCurrentUnixTimeForNewAccount()));
|
||||
return !account.value.equals(Account.createNewAccount(defaultAccountCategory, userStore.currentUserDefaultCurrency, account.value.balanceTime ?? getCurrentUnixTimeForNewAccount()));
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@@ -293,7 +294,7 @@ function open(options?: { id?: string, currentAccount?: Account, category?: numb
|
||||
loading.value = true;
|
||||
submitting.value = false;
|
||||
|
||||
const newAccount = Account.createNewAccount(userStore.currentUserDefaultCurrency, getCurrentUnixTimeForNewAccount());
|
||||
const newAccount = Account.createNewAccount(defaultAccountCategory, userStore.currentUserDefaultCurrency, getCurrentUnixTimeForNewAccount());
|
||||
account.value.fillFrom(newAccount);
|
||||
subAccounts.value = [];
|
||||
currentAccountIndex.value = -1;
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<v-dialog width="600" :persistent="isDisplayOrderModified()" v-model="showState">
|
||||
<v-card class="pa-sm-1 pa-md-2">
|
||||
<template #title>
|
||||
<div class="d-flex align-center justify-center">
|
||||
<div class="d-flex align-center">
|
||||
<h4 class="text-h4">{{ tt('Account Category Order') }}</h4>
|
||||
</div>
|
||||
<v-spacer/>
|
||||
<v-btn density="comfortable" color="default" variant="text" class="ms-2" :icon="true">
|
||||
<v-icon :icon="mdiDotsVertical" />
|
||||
<v-menu activator="parent">
|
||||
<v-list>
|
||||
<v-list-item :prepend-icon="mdiRestore"
|
||||
:title="tt('Reset to Default')"
|
||||
@click="resetDisplayOrderToDefault"></v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</v-btn>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<v-card-text class="d-flex flex-column flex-md-row flex-grow-1 overflow-y-auto">
|
||||
<v-table hover density="comfortable" class="w-100 table-striped">
|
||||
<draggable-list tag="tbody"
|
||||
item-key="id"
|
||||
handle=".drag-handle"
|
||||
ghost-class="dragging-item"
|
||||
v-model="accountCategories">
|
||||
<template #item="{ element }">
|
||||
<tr class="text-sm">
|
||||
<td>
|
||||
<div class="d-flex align-center">
|
||||
<div class="d-flex align-center">
|
||||
<span>{{ tt(element.name) }}</span>
|
||||
</div>
|
||||
|
||||
<v-spacer/>
|
||||
|
||||
<span class="ms-2">
|
||||
<v-icon class="drag-handle" :icon="mdiDrag"/>
|
||||
<v-tooltip activator="parent">{{ tt('Drag to Reorder') }}</v-tooltip>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</draggable-list>
|
||||
</v-table>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-text class="overflow-y-visible">
|
||||
<div class="w-100 d-flex justify-center flex-wrap mt-sm-1 mt-md-2 gap-4">
|
||||
<v-btn :disabled="!isDisplayOrderModified()" @click="saveDisplayOrder">{{ tt('Save') }}</v-btn>
|
||||
<v-btn color="secondary" variant="tonal" @click="cancel">{{ tt('Cancel') }}</v-btn>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
import { useAccountCategoryDisplayOrderSettingsPageBase } from '@/views/base/settings/AccountCategoryDisplayOrderSettingsPageBase.ts';
|
||||
|
||||
import {
|
||||
mdiDotsVertical,
|
||||
mdiRestore,
|
||||
mdiDrag
|
||||
} from '@mdi/js';
|
||||
|
||||
const { tt } = useI18n();
|
||||
|
||||
const {
|
||||
accountCategories,
|
||||
isDisplayOrderModified,
|
||||
loadDisplayOrderFromSettings,
|
||||
saveDisplayOrderToSettings,
|
||||
resetDisplayOrderToDefault
|
||||
} = useAccountCategoryDisplayOrderSettingsPageBase();
|
||||
|
||||
let resolveFunc: (() => void) | null = null;
|
||||
let rejectFunc: (() => void) | null = null;
|
||||
|
||||
const showState = ref<boolean>(false);
|
||||
|
||||
function open(): Promise<void> {
|
||||
loadDisplayOrderFromSettings();
|
||||
showState.value = true;
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
resolveFunc = resolve;
|
||||
rejectFunc = reject;
|
||||
});
|
||||
}
|
||||
|
||||
function saveDisplayOrder(): void {
|
||||
saveDisplayOrderToSettings();
|
||||
resolveFunc?.();
|
||||
showState.value = false;
|
||||
}
|
||||
|
||||
function cancel(): void {
|
||||
rejectFunc?.();
|
||||
showState.value = false;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
});
|
||||
</script>
|
||||
@@ -277,6 +277,19 @@
|
||||
@click="showAccountsIncludedInTotalDialog = true"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" md="6">
|
||||
<v-text-field
|
||||
class="always-cursor-pointer"
|
||||
item-title="displayName"
|
||||
item-value="type"
|
||||
persistent-placeholder
|
||||
:readonly="true"
|
||||
:label="tt('Account Category Order')"
|
||||
:placeholder="tt('Account Category Order')"
|
||||
:model-value="accountCategorysDisplayOrderContent"
|
||||
@click="accountCategorysDisplayOrderDialog?.open()"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" md="6">
|
||||
<v-select
|
||||
item-title="displayName"
|
||||
@@ -332,6 +345,8 @@
|
||||
@settings:change="showAccountsIncludedInTotalDialog = false" />
|
||||
</v-dialog>
|
||||
|
||||
<account-category-display-order-dialog ref="accountCategorysDisplayOrderDialog" />
|
||||
|
||||
<snack-bar ref="snackbar" />
|
||||
</template>
|
||||
|
||||
@@ -339,6 +354,7 @@
|
||||
import SnackBar from '@/components/desktop/SnackBar.vue';
|
||||
import AccountFilterSettingsCard from '@/views/desktop/common/cards/AccountFilterSettingsCard.vue';
|
||||
import CategoryFilterSettingsCard from '@/views/desktop/common/cards/CategoryFilterSettingsCard.vue';
|
||||
import AccountCategoryDisplayOrderDialog from '@/views/desktop/app/settings/dialogs/AccountCategoryDisplayOrderDialog.vue';
|
||||
|
||||
import { ref, computed, useTemplateRef } from 'vue';
|
||||
import { useTheme } from 'vuetify';
|
||||
@@ -358,6 +374,7 @@ import { CategoryType } from '@/core/category.ts';
|
||||
import { getSystemTheme } from '@/lib/ui/common.ts';
|
||||
|
||||
type SnackBarType = InstanceType<typeof SnackBar>;
|
||||
type AccountCategoryDisplayOrderDialogType = InstanceType<typeof AccountCategoryDisplayOrderDialog>;
|
||||
|
||||
const theme = useTheme();
|
||||
|
||||
@@ -386,6 +403,7 @@ const {
|
||||
currencySortByInExchangeRatesPage,
|
||||
accountsIncludedInHomePageOverviewDisplayContent,
|
||||
accountsIncludedInTotalDisplayContent,
|
||||
accountCategorysDisplayOrderContent,
|
||||
transactionCategoriesIncludedInHomePageOverviewDisplayContent
|
||||
} = useAppSettingPageBase();
|
||||
|
||||
@@ -394,6 +412,7 @@ const accountsStore = useAccountsStore();
|
||||
const transactionCategoriesStore = useTransactionCategoriesStore();
|
||||
|
||||
const snackbar = useTemplateRef<SnackBarType>('snackbar');
|
||||
const accountCategorysDisplayOrderDialog = useTemplateRef<AccountCategoryDisplayOrderDialogType>('accountCategorysDisplayOrderDialog');
|
||||
|
||||
const showAccountsIncludedInHomePageOverviewDialog = ref<boolean>(false);
|
||||
const showTransactionCategoriesIncludedInHomePageOverviewDialog = ref<boolean>(false);
|
||||
|
||||
@@ -181,6 +181,7 @@ const {
|
||||
title,
|
||||
applyText,
|
||||
allowHiddenAccount,
|
||||
customAccountCategoryOrder,
|
||||
allCategorizedAccounts,
|
||||
allVisibleAccountMap,
|
||||
hasAnyAvailableAccount,
|
||||
@@ -194,7 +195,7 @@ const accountsStore = useAccountsStore();
|
||||
|
||||
const snackbar = useTemplateRef<SnackBarType>('snackbar');
|
||||
|
||||
const expandAccountCategories = ref<number[]>(AccountCategory.values().map(category => category.type));
|
||||
const expandAccountCategories = ref<number[]>(AccountCategory.values(customAccountCategoryOrder.value).map(category => category.type));
|
||||
|
||||
function init(): void {
|
||||
accountsStore.loadAllAccounts({
|
||||
|
||||
@@ -279,9 +279,10 @@ let resolveFunc: ((response: BatchReplaceAllTypesDialogResponse) => void) | null
|
||||
let rejectFunc: ((reason?: unknown) => void) | null = null;
|
||||
|
||||
const showAccountBalance = computed<boolean>(() => settingsStore.appSettings.showAccountBalance);
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value));
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value, customAccountCategoryOrder.value));
|
||||
const allCategories = computed<Record<number, TransactionCategory[]>>(() => transactionCategoriesStore.allTransactionCategories);
|
||||
const allTags = computed<TransactionTag[]>(() => transactionTagsStore.allTransactionTags);
|
||||
|
||||
|
||||
@@ -269,9 +269,10 @@ let resolveFunc: ((response: BatchReplaceDialogResponse) => void) | null = null;
|
||||
let rejectFunc: ((reason?: unknown) => void) | null = null;
|
||||
|
||||
const showAccountBalance = computed<boolean>(() => settingsStore.appSettings.showAccountBalance);
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value));
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value, customAccountCategoryOrder.value));
|
||||
const allCategories = computed<Record<number, TransactionCategory[]>>(() => transactionCategoriesStore.allTransactionCategories);
|
||||
const allTags = computed<TransactionTag[]>(() => transactionTagsStore.allTransactionTags);
|
||||
|
||||
|
||||
@@ -539,13 +539,14 @@ const currentDescriptionFilterValue = ref<string | null>(null);
|
||||
|
||||
const numeralSystem = computed<NumeralSystem>(() => getCurrentNumeralSystemType());
|
||||
const showAccountBalance = computed<boolean>(() => settingsStore.appSettings.showAccountBalance);
|
||||
const customAccountCategoryOrder = computed<string>(() => settingsStore.appSettings.accountCategoryOrders);
|
||||
|
||||
const defaultCurrency = computed<string>(() => userStore.currentUserDefaultCurrency);
|
||||
const coordinateDisplayType = computed<number>(() => userStore.currentUserCoordinateDisplayType);
|
||||
|
||||
const allAccounts = computed<Account[]>(() => accountsStore.allPlainAccounts);
|
||||
const allVisibleAccounts = computed<Account[]>(() => accountsStore.allVisiblePlainAccounts);
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value));
|
||||
const allVisibleCategorizedAccounts = computed<CategorizedAccountWithDisplayBalance[]>(() => getCategorizedAccountsWithDisplayBalance(allVisibleAccounts.value, showAccountBalance.value, customAccountCategoryOrder.value));
|
||||
const allAccountsMap = computed<Record<string, Account>>(() => accountsStore.allAccountsMap);
|
||||
const allAccountsMapByName = computed<Record<string, Account>>(() => getAccountMapByName(accountsStore.allAccounts));
|
||||
const allCategories = computed<Record<number, TransactionCategory[]>>(() => transactionCategoriesStore.allTransactionCategories);
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
</f7-list>
|
||||
|
||||
<div :key="accountCategory.type"
|
||||
v-for="accountCategory in AccountCategory.values()"
|
||||
v-for="accountCategory in AccountCategory.values(customAccountCategoryOrder)"
|
||||
v-show="!loading && ((showHidden && hasAccount(accountCategory, false)) || hasAccount(accountCategory, true))">
|
||||
<f7-list strong inset dividers sortable class="list-has-group-title account-list margin-vertical"
|
||||
:sortable-enabled="sortable"
|
||||
@@ -246,6 +246,7 @@ const {
|
||||
showHidden,
|
||||
displayOrderModified,
|
||||
showAccountBalance,
|
||||
customAccountCategoryOrder,
|
||||
allCategorizedAccountsMap,
|
||||
allAccountCount,
|
||||
netAssets,
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<f7-page>
|
||||
<f7-navbar>
|
||||
<f7-nav-left :back-link="tt('Back')"></f7-nav-left>
|
||||
<f7-nav-title :title="tt('Account Category Order')"></f7-nav-title>
|
||||
<f7-nav-right class="navbar-compact-icons">
|
||||
<f7-link icon-f7="ellipsis" @click="showMoreActionSheet = true"></f7-link>
|
||||
<f7-link icon-f7="checkmark_alt" :class="{ 'disabled': !isDisplayOrderModified() }" @click="saveDisplayOrder"></f7-link>
|
||||
</f7-nav-right>
|
||||
</f7-navbar>
|
||||
|
||||
<f7-list strong inset dividers sortable sortable-enabled class="margin-top"
|
||||
@sortable:sort="onSort">
|
||||
<f7-list-item :id="getAccountCategoryDomId(accountCategory)"
|
||||
:key="accountCategory.type"
|
||||
:title="tt(accountCategory.name)"
|
||||
v-for="accountCategory in accountCategories">
|
||||
</f7-list-item>
|
||||
</f7-list>
|
||||
|
||||
<f7-actions close-by-outside-click close-on-escape :opened="showMoreActionSheet" @actions:closed="showMoreActionSheet = false">
|
||||
<f7-actions-group>
|
||||
<f7-actions-button @click="resetToDefault()">{{ tt('Reset to Default') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
<f7-actions-group>
|
||||
<f7-actions-button bold close>{{ tt('Cancel') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
</f7-actions>
|
||||
</f7-page>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import type { Router } from 'framework7/types';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
import { useI18nUIComponents } from '@/lib/ui/mobile.ts';
|
||||
import { useAccountCategoryDisplayOrderSettingsPageBase } from '@/views/base/settings/AccountCategoryDisplayOrderSettingsPageBase.ts';
|
||||
|
||||
import { AccountCategory } from '@/core/account.ts';
|
||||
|
||||
const props = defineProps<{
|
||||
f7router: Router.Router;
|
||||
}>();
|
||||
|
||||
const { tt } = useI18n();
|
||||
const { showToast } = useI18nUIComponents();
|
||||
|
||||
const {
|
||||
accountCategories,
|
||||
isDisplayOrderModified,
|
||||
loadDisplayOrderFromSettings,
|
||||
saveDisplayOrderToSettings,
|
||||
resetDisplayOrderToDefault
|
||||
} = useAccountCategoryDisplayOrderSettingsPageBase();
|
||||
|
||||
const showMoreActionSheet = ref<boolean>(false);
|
||||
|
||||
function getAccountCategoryDomId(accountCategory: AccountCategory): string {
|
||||
return 'account_category_' + accountCategory.type;
|
||||
}
|
||||
|
||||
function parseAccountCategoryTypeFromDomId(domId: string): string | null {
|
||||
if (!domId || domId.indexOf('account_category_') !== 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return domId.substring(17); // account_category_
|
||||
}
|
||||
|
||||
function init(): void {
|
||||
loadDisplayOrderFromSettings();
|
||||
}
|
||||
|
||||
function saveDisplayOrder(): void {
|
||||
saveDisplayOrderToSettings();
|
||||
showToast('Account category order saved');
|
||||
props.f7router.back();
|
||||
}
|
||||
|
||||
function resetToDefault() {
|
||||
resetDisplayOrderToDefault();
|
||||
showMoreActionSheet.value = false;
|
||||
}
|
||||
|
||||
function onSort(event: { el: { id: string }, from: number, to: number }): void {
|
||||
if (!event || !event.el || !event.el.id) {
|
||||
showToast('Unable to move account category');
|
||||
return;
|
||||
}
|
||||
|
||||
const type = parseAccountCategoryTypeFromDomId(event.el.id);
|
||||
|
||||
if (!type) {
|
||||
showToast('Unable to move account category');
|
||||
return;
|
||||
}
|
||||
|
||||
let currentAccountCategory: AccountCategory | null = null;
|
||||
|
||||
for (const accountCategory of accountCategories.value) {
|
||||
if (accountCategory.type.toString() === type) {
|
||||
currentAccountCategory = accountCategory;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentAccountCategory || !accountCategories.value[event.to]) {
|
||||
showToast('Unable to move account category');
|
||||
return;
|
||||
}
|
||||
|
||||
accountCategories.value.splice(event.to, 0, accountCategories.value.splice(event.from, 1)[0] as AccountCategory);
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
@@ -178,6 +178,7 @@ const {
|
||||
filterAccountIds,
|
||||
title,
|
||||
allowHiddenAccount,
|
||||
customAccountCategoryOrder,
|
||||
allCategorizedAccounts,
|
||||
allVisibleAccountMap,
|
||||
hasAnyAvailableAccount,
|
||||
@@ -195,7 +196,7 @@ const showMoreActionSheet = ref<boolean>(false);
|
||||
|
||||
function getCollapseStates(): Record<number, CollapseState> {
|
||||
const collapseStates: Record<number, CollapseState> = {};
|
||||
const allCategories = AccountCategory.values();
|
||||
const allCategories = AccountCategory.values(customAccountCategoryOrder.value);
|
||||
|
||||
for (const accountCategory of allCategories) {
|
||||
collapseStates[accountCategory.type] = {
|
||||
|
||||
@@ -153,6 +153,18 @@
|
||||
<div v-else-if="!loadingAccounts">{{ accountsIncludedInTotalDisplayContent }}</div>
|
||||
</template>
|
||||
</f7-list-item>
|
||||
<f7-list-item
|
||||
class="item-truncate-after-text"
|
||||
link="/settings/account_category_display_order">
|
||||
<template #after-title>
|
||||
<div class="item-actual-title">
|
||||
<span>{{ tt('Account Category Order') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #after>
|
||||
<div>{{ accountCategorysDisplayOrderContent }}</div>
|
||||
</template>
|
||||
</f7-list-item>
|
||||
</f7-list>
|
||||
|
||||
<f7-block-title>{{ tt('Exchange Rates Data Page') }}</f7-block-title>
|
||||
@@ -221,6 +233,7 @@ const {
|
||||
currencySortByInExchangeRatesPage,
|
||||
accountsIncludedInHomePageOverviewDisplayContent,
|
||||
accountsIncludedInTotalDisplayContent,
|
||||
accountCategorysDisplayOrderContent,
|
||||
transactionCategoriesIncludedInHomePageOverviewDisplayContent
|
||||
} = useAppSettingPageBase();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user