mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 01:34:24 +08:00
code refactor
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import currencyConstants from '@/consts/currency.js';
|
||||||
import accountConstants from '@/consts/account.js';
|
import accountConstants from '@/consts/account.js';
|
||||||
|
|
||||||
export function setAccountModelByAnotherAccount(account, account2) {
|
export function setAccountModelByAnotherAccount(account, account2) {
|
||||||
@@ -227,6 +228,37 @@ export function getAllFilteredAccountsBalance(categorizedAccounts, accountFilter
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
export function getUnifiedSelectedAccountsCurrencyOrDefaultCurrency(allAccounts, selectedAccountIds, defaultCurrency) {
|
||||||
|
if (!selectedAccountIds) {
|
||||||
|
return defaultCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
let accountCurrency = '';
|
||||||
|
|
||||||
|
for (let accountId in selectedAccountIds) {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(selectedAccountIds, accountId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const account = allAccounts[accountId];
|
||||||
|
|
||||||
|
if (account.currency === currencyConstants.parentAccountCurrencyPlaceholder) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accountCurrency === '') {
|
||||||
|
accountCurrency = account.currency;
|
||||||
|
} else if (accountCurrency !== account.currency) {
|
||||||
|
return defaultCurrency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accountCurrency) {
|
||||||
|
return accountCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
export function selectAccountOrSubAccounts(filterAccountIds, account, value) {
|
export function selectAccountOrSubAccounts(filterAccountIds, account, value) {
|
||||||
if (account.type === accountConstants.allAccountTypes.SingleAccount) {
|
if (account.type === accountConstants.allAccountTypes.SingleAccount) {
|
||||||
|
|||||||
@@ -1009,7 +1009,9 @@ export default {
|
|||||||
'Swap Amount': 'Swap Amount',
|
'Swap Amount': 'Swap Amount',
|
||||||
'Swap Account and Amount': 'Swap Account and Amount',
|
'Swap Account and Amount': 'Swap Account and Amount',
|
||||||
'Category': 'Category',
|
'Category': 'Category',
|
||||||
|
'Multiple Categories': 'Multiple Categories',
|
||||||
'Account': 'Account',
|
'Account': 'Account',
|
||||||
|
'Multiple Accounts': 'Multiple Accounts',
|
||||||
'Source Account': 'Source Account',
|
'Source Account': 'Source Account',
|
||||||
'Destination Account': 'Destination Account',
|
'Destination Account': 'Destination Account',
|
||||||
'Transaction Time': 'Transaction Time',
|
'Transaction Time': 'Transaction Time',
|
||||||
|
|||||||
@@ -1009,7 +1009,9 @@ export default {
|
|||||||
'Swap Amount': '交换金额',
|
'Swap Amount': '交换金额',
|
||||||
'Swap Account and Amount': '交换账户和金额',
|
'Swap Account and Amount': '交换账户和金额',
|
||||||
'Category': '分类',
|
'Category': '分类',
|
||||||
|
'Multiple Categories': '多个分类',
|
||||||
'Account': '账户',
|
'Account': '账户',
|
||||||
|
'Multiple Accounts': '多个账户',
|
||||||
'Source Account': '来源账户',
|
'Source Account': '来源账户',
|
||||||
'Destination Account': '目标账户',
|
'Destination Account': '目标账户',
|
||||||
'Transaction Time': '交易时间',
|
'Transaction Time': '交易时间',
|
||||||
|
|||||||
+104
-42
@@ -64,7 +64,7 @@ function loadTransactionList(state, settingsStore, exchangeRatesStore, { transac
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!currentMonthList || currentMonthList.year !== transactionYear || currentMonthList.month !== transactionMonth) {
|
if (!currentMonthList || currentMonthList.year !== transactionYear || currentMonthList.month !== transactionMonth) {
|
||||||
calculateMonthTotalAmount(state, exchangeRatesStore, currentMonthList, defaultCurrency, state.transactionsFilter.accountId, false);
|
calculateMonthTotalAmount(state, exchangeRatesStore, currentMonthList, defaultCurrency, state.transactionsFilter.accountIds, false);
|
||||||
|
|
||||||
state.transactions.push({
|
state.transactions.push({
|
||||||
year: transactionYear,
|
year: transactionYear,
|
||||||
@@ -79,14 +79,14 @@ function loadTransactionList(state, settingsStore, exchangeRatesStore, { transac
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentMonthList.items.push(Object.freeze(item));
|
currentMonthList.items.push(Object.freeze(item));
|
||||||
calculateMonthTotalAmount(state, exchangeRatesStore, currentMonthList, defaultCurrency, state.transactionsFilter.accountId, true);
|
calculateMonthTotalAmount(state, exchangeRatesStore, currentMonthList, defaultCurrency, state.transactionsFilter.accountIds, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactions.nextTimeSequenceId) {
|
if (transactions.nextTimeSequenceId) {
|
||||||
state.transactionsNextTimeId = transactions.nextTimeSequenceId;
|
state.transactionsNextTimeId = transactions.nextTimeSequenceId;
|
||||||
} else {
|
} else {
|
||||||
calculateMonthTotalAmount(state, exchangeRatesStore, state.transactions[state.transactions.length - 1], defaultCurrency, state.transactionsFilter.accountId, false);
|
calculateMonthTotalAmount(state, exchangeRatesStore, state.transactions[state.transactions.length - 1], defaultCurrency, state.transactionsFilter.accountIds, false);
|
||||||
state.transactionsNextTimeId = -1;
|
state.transactionsNextTimeId = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,12 +115,10 @@ function updateTransactionInTransactionList(state, settingsStore, exchangeRatesS
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((state.transactionsFilter.categoryId && state.transactionsFilter.categoryId !== '0' && state.transactionsFilter.categoryId !== transaction.categoryId) ||
|
if ((state.transactionsFilter.categoryIds && !state.allFilterCategoryIds[transaction.categoryId]) ||
|
||||||
(state.transactionsFilter.accountId && state.transactionsFilter.accountId !== '0' &&
|
(state.transactionsFilter.accountIds && !state.allFilterAccountIds[transaction.sourceAccountId] && !state.allFilterAccountIds[transaction.destinationAccountId] &&
|
||||||
state.transactionsFilter.accountId !== transaction.sourceAccountId &&
|
(!transaction.sourceAccount || !state.allFilterAccountIds[transaction.sourceAccount.parentId]) &&
|
||||||
state.transactionsFilter.accountId !== transaction.destinationAccountId &&
|
(!transaction.destinationAccount || !state.allFilterAccountIds[transaction.destinationAccount.parentId])
|
||||||
(!transaction.sourceAccount || state.transactionsFilter.accountId !== transaction.sourceAccount.parentId) &&
|
|
||||||
(!transaction.destinationAccount || state.transactionsFilter.accountId !== transaction.destinationAccount.parentId)
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
transactionMonthList.items.splice(j, 1);
|
transactionMonthList.items.splice(j, 1);
|
||||||
@@ -131,7 +129,7 @@ function updateTransactionInTransactionList(state, settingsStore, exchangeRatesS
|
|||||||
if (transactionMonthList.items.length < 1) {
|
if (transactionMonthList.items.length < 1) {
|
||||||
state.transactions.splice(i, 1);
|
state.transactions.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthList, defaultCurrency, state.transactionsFilter.accountId, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthList, defaultCurrency, state.transactionsFilter.accountIds, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -159,12 +157,12 @@ function removeTransactionFromTransactionList(state, exchangeRatesStore, { trans
|
|||||||
if (transactionMonthList.items.length < 1) {
|
if (transactionMonthList.items.length < 1) {
|
||||||
state.transactions.splice(i, 1);
|
state.transactions.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthList, defaultCurrency, state.transactionsFilter.accountId, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthList, defaultCurrency, state.transactionsFilter.accountIds, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthList, defaultCurrency, accountId, incomplete) {
|
function calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthList, defaultCurrency, accountIds, incomplete) {
|
||||||
if (!transactionMonthList) {
|
if (!transactionMonthList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -180,7 +178,7 @@ function calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthLi
|
|||||||
let amount = transaction.sourceAmount;
|
let amount = transaction.sourceAmount;
|
||||||
let account = transaction.sourceAccount;
|
let account = transaction.sourceAccount;
|
||||||
|
|
||||||
if (accountId && transaction.destinationAccount && (transaction.destinationAccount.id === accountId || transaction.destinationAccount.parentId === accountId)) {
|
if (accountIds && transaction.destinationAccount && (transaction.destinationAccount.id === accountIds || transaction.destinationAccount.parentId === accountIds)) {
|
||||||
amount = transaction.destinationAmount;
|
amount = transaction.destinationAmount;
|
||||||
account = transaction.destinationAccount;
|
account = transaction.destinationAccount;
|
||||||
}
|
}
|
||||||
@@ -209,17 +207,17 @@ function calculateMonthTotalAmount(state, exchangeRatesStore, transactionMonthLi
|
|||||||
totalExpense += amount;
|
totalExpense += amount;
|
||||||
} else if (transaction.type === transactionConstants.allTransactionTypes.Income) {
|
} else if (transaction.type === transactionConstants.allTransactionTypes.Income) {
|
||||||
totalIncome += amount;
|
totalIncome += amount;
|
||||||
} else if (transaction.type === transactionConstants.allTransactionTypes.Transfer && accountId && accountId !== '0') {
|
} else if (transaction.type === transactionConstants.allTransactionTypes.Transfer && accountIds && accountIds !== '0') {
|
||||||
if (accountId === transaction.sourceAccountId) {
|
if (accountIds === transaction.sourceAccountId) {
|
||||||
totalExpense += amount;
|
totalExpense += amount;
|
||||||
} else if (accountId === transaction.destinationAccountId) {
|
} else if (accountIds === transaction.destinationAccountId) {
|
||||||
totalIncome += amount;
|
totalIncome += amount;
|
||||||
} else if (transaction.sourceAccount && accountId === transaction.sourceAccount.parentId &&
|
} else if (transaction.sourceAccount && accountIds === transaction.sourceAccount.parentId &&
|
||||||
transaction.destinationAccount && accountId === transaction.destinationAccount.parentId) {
|
transaction.destinationAccount && accountIds === transaction.destinationAccount.parentId) {
|
||||||
// Do Nothing
|
// Do Nothing
|
||||||
} else if (transaction.sourceAccount && accountId === transaction.sourceAccount.parentId) {
|
} else if (transaction.sourceAccount && accountIds === transaction.sourceAccount.parentId) {
|
||||||
totalExpense += amount;
|
totalExpense += amount;
|
||||||
} else if (transaction.destinationAccount && accountId === transaction.destinationAccount.parentId) {
|
} else if (transaction.destinationAccount && accountIds === transaction.destinationAccount.parentId) {
|
||||||
totalIncome += amount;
|
totalIncome += amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,8 +266,8 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
maxTime: 0,
|
maxTime: 0,
|
||||||
minTime: 0,
|
minTime: 0,
|
||||||
type: 0,
|
type: 0,
|
||||||
categoryId: '0',
|
categoryIds: '',
|
||||||
accountId: '0',
|
accountIds: '',
|
||||||
amountFilter: '',
|
amountFilter: '',
|
||||||
keyword: ''
|
keyword: ''
|
||||||
},
|
},
|
||||||
@@ -278,6 +276,70 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
transactionListStateInvalid: true,
|
transactionListStateInvalid: true,
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
|
allFilterCategoryIds(state) {
|
||||||
|
if (!state.transactionsFilter.categoryIds) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const allCategoryIds = state.transactionsFilter.categoryIds.split(',');
|
||||||
|
const ret = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < allCategoryIds.length; i++) {
|
||||||
|
if (allCategoryIds[i]) {
|
||||||
|
ret[allCategoryIds[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
allFilterAccountIds(state) {
|
||||||
|
if (!state.transactionsFilter.accountIds) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const allAccountIds = state.transactionsFilter.accountIds.split(',');
|
||||||
|
const ret = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < allAccountIds.length; i++) {
|
||||||
|
if (allAccountIds[i]) {
|
||||||
|
ret[allAccountIds[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
allFilterCategoryIdsCount(state) {
|
||||||
|
if (!state.transactionsFilter.categoryIds) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const allCategoryIds = state.transactionsFilter.categoryIds.split(',');
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < allCategoryIds.length; i++) {
|
||||||
|
if (allCategoryIds[i]) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
},
|
||||||
|
allFilterAccountIdsCount(state) {
|
||||||
|
if (!state.transactionsFilter.accountIds) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const allAccountIds = state.transactionsFilter.accountIds.split(',');
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < allAccountIds.length; i++) {
|
||||||
|
if (allAccountIds[i]) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
},
|
||||||
noTransaction(state) {
|
noTransaction(state) {
|
||||||
for (let i = 0; i < state.transactions.length; i++) {
|
for (let i = 0; i < state.transactions.length; i++) {
|
||||||
const transactionMonthList = state.transactions[i];
|
const transactionMonthList = state.transactions[i];
|
||||||
@@ -364,8 +426,8 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
this.transactionsFilter.maxTime = 0;
|
this.transactionsFilter.maxTime = 0;
|
||||||
this.transactionsFilter.minTime = 0;
|
this.transactionsFilter.minTime = 0;
|
||||||
this.transactionsFilter.type = 0;
|
this.transactionsFilter.type = 0;
|
||||||
this.transactionsFilter.categoryId = '0';
|
this.transactionsFilter.categoryIds = '';
|
||||||
this.transactionsFilter.accountId = '0';
|
this.transactionsFilter.accountIds = '';
|
||||||
this.transactionsFilter.amountFilter = '';
|
this.transactionsFilter.amountFilter = '';
|
||||||
this.transactionsFilter.keyword = '';
|
this.transactionsFilter.keyword = '';
|
||||||
this.transactions = [];
|
this.transactions = [];
|
||||||
@@ -402,16 +464,16 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
this.transactionsFilter.type = 0;
|
this.transactionsFilter.type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isString(filter.categoryId)) {
|
if (filter && isString(filter.categoryIds)) {
|
||||||
this.transactionsFilter.categoryId = filter.categoryId;
|
this.transactionsFilter.categoryIds = filter.categoryIds;
|
||||||
} else {
|
} else {
|
||||||
this.transactionsFilter.categoryId = '0';
|
this.transactionsFilter.categoryIds = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isString(filter.accountId)) {
|
if (filter && isString(filter.accountIds)) {
|
||||||
this.transactionsFilter.accountId = filter.accountId;
|
this.transactionsFilter.accountIds = filter.accountIds;
|
||||||
} else {
|
} else {
|
||||||
this.transactionsFilter.accountId = '0';
|
this.transactionsFilter.accountIds = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isString(filter.amountFilter)) {
|
if (filter && isString(filter.amountFilter)) {
|
||||||
@@ -443,12 +505,12 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
this.transactionsFilter.type = filter.type;
|
this.transactionsFilter.type = filter.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isString(filter.categoryId)) {
|
if (filter && isString(filter.categoryIds)) {
|
||||||
this.transactionsFilter.categoryId = filter.categoryId;
|
this.transactionsFilter.categoryIds = filter.categoryIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isString(filter.accountId)) {
|
if (filter && isString(filter.accountIds)) {
|
||||||
this.transactionsFilter.accountId = filter.accountId;
|
this.transactionsFilter.accountIds = filter.accountIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && isString(filter.amountFilter)) {
|
if (filter && isString(filter.amountFilter)) {
|
||||||
@@ -466,12 +528,12 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
querys.push('type=' + this.transactionsFilter.type);
|
querys.push('type=' + this.transactionsFilter.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.transactionsFilter.accountId && this.transactionsFilter.accountId !== '0') {
|
if (this.transactionsFilter.accountIds) {
|
||||||
querys.push('accountIds=' + this.transactionsFilter.accountId);
|
querys.push('accountIds=' + this.transactionsFilter.accountIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.transactionsFilter.categoryId && this.transactionsFilter.categoryId !== '0') {
|
if (this.transactionsFilter.categoryIds) {
|
||||||
querys.push('categoryIds=' + this.transactionsFilter.categoryId);
|
querys.push('categoryIds=' + this.transactionsFilter.categoryIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
querys.push('dateType=' + this.transactionsFilter.dateType);
|
querys.push('dateType=' + this.transactionsFilter.dateType);
|
||||||
@@ -511,8 +573,8 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
page: page || 1,
|
page: page || 1,
|
||||||
withCount: (!!withCount) || false,
|
withCount: (!!withCount) || false,
|
||||||
type: self.transactionsFilter.type,
|
type: self.transactionsFilter.type,
|
||||||
categoryIds: self.transactionsFilter.categoryId,
|
categoryIds: self.transactionsFilter.categoryIds,
|
||||||
accountIds: self.transactionsFilter.accountId,
|
accountIds: self.transactionsFilter.accountIds,
|
||||||
amountFilter: self.transactionsFilter.amountFilter,
|
amountFilter: self.transactionsFilter.amountFilter,
|
||||||
keyword: self.transactionsFilter.keyword
|
keyword: self.transactionsFilter.keyword
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
@@ -586,8 +648,8 @@ export const useTransactionsStore = defineStore('transactions', {
|
|||||||
year: year,
|
year: year,
|
||||||
month: month,
|
month: month,
|
||||||
type: self.transactionsFilter.type,
|
type: self.transactionsFilter.type,
|
||||||
categoryIds: self.transactionsFilter.categoryId,
|
categoryIds: self.transactionsFilter.categoryIds,
|
||||||
accountIds: self.transactionsFilter.accountId,
|
accountIds: self.transactionsFilter.accountIds,
|
||||||
amountFilter: self.transactionsFilter.amountFilter,
|
amountFilter: self.transactionsFilter.amountFilter,
|
||||||
keyword: self.transactionsFilter.keyword
|
keyword: self.transactionsFilter.keyword
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
|
|||||||
@@ -116,17 +116,17 @@
|
|||||||
@update:model-value="scrollCategoryMenuToSelectedItem">
|
@update:model-value="scrollCategoryMenuToSelectedItem">
|
||||||
<template #activator="{ props }">
|
<template #activator="{ props }">
|
||||||
<div class="d-flex align-center"
|
<div class="d-flex align-center"
|
||||||
:class="{ 'readonly': loading, 'cursor-pointer': query.type !== 1, 'text-primary': query.categoryId > 0 }" v-bind="props">
|
:class="{ 'readonly': loading, 'cursor-pointer': query.type !== 1, 'text-primary': query.categoryIds }" v-bind="props">
|
||||||
<span>{{ queryCategoryName }}</span>
|
<span>{{ queryCategoryName }}</span>
|
||||||
<v-icon :icon="icons.dropdownMenu" v-show="query.type !== 1" />
|
<v-icon :icon="icons.dropdownMenu" v-show="query.type !== 1" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<v-list :selected="[query.categoryId]">
|
<v-list :selected="[query.categoryIds]">
|
||||||
<v-list-item key="0" value="0" class="text-sm" density="compact"
|
<v-list-item key="" value="" class="text-sm" density="compact"
|
||||||
:class="{ 'list-item-selected': query.categoryId === '0' }"
|
:class="{ 'list-item-selected': !query.categoryIds }"
|
||||||
:append-icon="(query.categoryId === '0' ? icons.check : null)">
|
:append-icon="(!query.categoryIds ? icons.check : null)">
|
||||||
<v-list-item-title class="cursor-pointer"
|
<v-list-item-title class="cursor-pointer"
|
||||||
@click="changeCategoryFilter('0')">
|
@click="changeCategoryFilter('')">
|
||||||
<div class="d-flex align-center">
|
<div class="d-flex align-center">
|
||||||
<v-icon :icon="icons.all" />
|
<v-icon :icon="icons.all" />
|
||||||
<span class="text-sm ml-3">{{ $t('All') }}</span>
|
<span class="text-sm ml-3">{{ $t('All') }}</span>
|
||||||
@@ -146,7 +146,7 @@
|
|||||||
<template #activator="{ props }" v-if="!category.hidden">
|
<template #activator="{ props }" v-if="!category.hidden">
|
||||||
<v-divider />
|
<v-divider />
|
||||||
<v-list-item class="text-sm" density="compact"
|
<v-list-item class="text-sm" density="compact"
|
||||||
:class="getCategoryListItemCheckedClass(category, query.categoryId)"
|
:class="getCategoryListItemCheckedClass(category, queryAllFilterCategoryIds)"
|
||||||
v-bind="props">
|
v-bind="props">
|
||||||
<v-list-item-title>
|
<v-list-item-title>
|
||||||
<div class="d-flex align-center">
|
<div class="d-flex align-center">
|
||||||
@@ -160,7 +160,7 @@
|
|||||||
<v-divider />
|
<v-divider />
|
||||||
<v-list-item class="text-sm" density="compact"
|
<v-list-item class="text-sm" density="compact"
|
||||||
:value="category.id"
|
:value="category.id"
|
||||||
:append-icon="(query.categoryId === category.id ? icons.check : null)">
|
:append-icon="(query.categoryIds === category.id ? icons.check : null)">
|
||||||
<v-list-item-title class="cursor-pointer"
|
<v-list-item-title class="cursor-pointer"
|
||||||
@click="changeCategoryFilter(category.id)">
|
@click="changeCategoryFilter(category.id)">
|
||||||
<div class="d-flex align-center">
|
<div class="d-flex align-center">
|
||||||
@@ -175,8 +175,8 @@
|
|||||||
<v-divider v-if="!subCategory.hidden" />
|
<v-divider v-if="!subCategory.hidden" />
|
||||||
<v-list-item class="text-sm" density="compact"
|
<v-list-item class="text-sm" density="compact"
|
||||||
:value="subCategory.id"
|
:value="subCategory.id"
|
||||||
:class="{ 'list-item-selected': query.categoryId === subCategory.id }"
|
:class="{ 'list-item-selected': query.categoryIds === subCategory.id }"
|
||||||
:append-icon="(query.categoryId === subCategory.id ? icons.check : null)"
|
:append-icon="(query.categoryIds === subCategory.id ? icons.check : null)"
|
||||||
v-if="!subCategory.hidden">
|
v-if="!subCategory.hidden">
|
||||||
<v-list-item-title class="cursor-pointer"
|
<v-list-item-title class="cursor-pointer"
|
||||||
@click="changeCategoryFilter(subCategory.id)">
|
@click="changeCategoryFilter(subCategory.id)">
|
||||||
@@ -248,17 +248,17 @@
|
|||||||
@update:model-value="scrollAccountMenuToSelectedItem">
|
@update:model-value="scrollAccountMenuToSelectedItem">
|
||||||
<template #activator="{ props }">
|
<template #activator="{ props }">
|
||||||
<div class="d-flex align-center cursor-pointer"
|
<div class="d-flex align-center cursor-pointer"
|
||||||
:class="{ 'readonly': loading, 'text-primary': query.accountId > 0 }" v-bind="props">
|
:class="{ 'readonly': loading, 'text-primary': query.accountIds }" v-bind="props">
|
||||||
<span>{{ queryAccountName }}</span>
|
<span>{{ queryAccountName }}</span>
|
||||||
<v-icon :icon="icons.dropdownMenu" />
|
<v-icon :icon="icons.dropdownMenu" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<v-list :selected="[query.accountId]">
|
<v-list :selected="[query.accountIds]">
|
||||||
<v-list-item key="0" value="0" class="text-sm" density="compact"
|
<v-list-item key="" value="" class="text-sm" density="compact"
|
||||||
:class="{ 'list-item-selected': query.accountId === '0' }"
|
:class="{ 'list-item-selected': !query.accountIds }"
|
||||||
:append-icon="(query.accountId === '0' ? icons.check : null)">
|
:append-icon="(!query.accountIds ? icons.check : null)">
|
||||||
<v-list-item-title class="cursor-pointer"
|
<v-list-item-title class="cursor-pointer"
|
||||||
@click="changeAccountFilter('0')">
|
@click="changeAccountFilter('')">
|
||||||
<div class="d-flex align-center">
|
<div class="d-flex align-center">
|
||||||
<v-icon :icon="icons.all" />
|
<v-icon :icon="icons.all" />
|
||||||
<span class="text-sm ml-3">{{ $t('All') }}</span>
|
<span class="text-sm ml-3">{{ $t('All') }}</span>
|
||||||
@@ -270,8 +270,8 @@
|
|||||||
<v-divider v-if="!account.hidden" />
|
<v-divider v-if="!account.hidden" />
|
||||||
<v-list-item class="text-sm" density="compact"
|
<v-list-item class="text-sm" density="compact"
|
||||||
:value="account.id"
|
:value="account.id"
|
||||||
:class="{ 'list-item-selected': query.accountId === account.id }"
|
:class="{ 'list-item-selected': query.accountIds === account.id }"
|
||||||
:append-icon="(query.accountId === account.id ? icons.check : null)"
|
:append-icon="(query.accountIds === account.id ? icons.check : null)"
|
||||||
v-if="!account.hidden">
|
v-if="!account.hidden">
|
||||||
<v-list-item-title class="cursor-pointer"
|
<v-list-item-title class="cursor-pointer"
|
||||||
@click="changeAccountFilter(account.id)">
|
@click="changeAccountFilter(account.id)">
|
||||||
@@ -347,8 +347,8 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="transaction-table-column-amount" :class="{ 'text-expense': transaction.type === allTransactionTypes.Expense, 'text-income': transaction.type === allTransactionTypes.Income }">
|
<td class="transaction-table-column-amount" :class="{ 'text-expense': transaction.type === allTransactionTypes.Expense, 'text-income': transaction.type === allTransactionTypes.Income }">
|
||||||
<div v-if="transaction.sourceAccount">
|
<div v-if="transaction.sourceAccount">
|
||||||
<span v-if="!query.accountId || query.accountId === '0' || (transaction.sourceAccount && (transaction.sourceAccount.id === query.accountId || transaction.sourceAccount.parentId === query.accountId))">{{ getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount) }}</span>
|
<span v-if="!query.accountIds || (transaction.sourceAccount && (transaction.sourceAccount.id === query.accountIds || transaction.sourceAccount.parentId === query.accountIds))">{{ getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount) }}</span>
|
||||||
<span v-else-if="query.accountId && query.accountId !== '0' && transaction.destinationAccount && (transaction.destinationAccount.id === query.accountId || transaction.destinationAccount.parentId === query.accountId)">{{ getDisplayAmount(transaction.destinationAmount, transaction.destinationAccount.currency, transaction.hideAmount) }}</span>
|
<span v-else-if="query.accountIds && transaction.destinationAccount && (transaction.destinationAccount.id === query.accountIds || transaction.destinationAccount.parentId === query.accountIds)">{{ getDisplayAmount(transaction.destinationAmount, transaction.destinationAccount.currency, transaction.hideAmount) }}</span>
|
||||||
<span v-else></span>
|
<span v-else></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -404,7 +404,6 @@ import { useTransactionsStore } from '@/stores/transaction.js';
|
|||||||
|
|
||||||
import numeralConstants from '@/consts/numeral.js';
|
import numeralConstants from '@/consts/numeral.js';
|
||||||
import datetimeConstants from '@/consts/datetime.js';
|
import datetimeConstants from '@/consts/datetime.js';
|
||||||
import currencyConstants from '@/consts/currency.js';
|
|
||||||
import accountConstants from '@/consts/account.js';
|
import accountConstants from '@/consts/account.js';
|
||||||
import transactionConstants from '@/consts/transaction.js';
|
import transactionConstants from '@/consts/transaction.js';
|
||||||
import { isString, getNameByKeyValue } from '@/lib/common.js';
|
import { isString, getNameByKeyValue } from '@/lib/common.js';
|
||||||
@@ -431,6 +430,7 @@ import {
|
|||||||
categoryTypeToTransactionType,
|
categoryTypeToTransactionType,
|
||||||
transactionTypeToCategoryType
|
transactionTypeToCategoryType
|
||||||
} from '@/lib/category.js';
|
} from '@/lib/category.js';
|
||||||
|
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js';
|
||||||
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
|
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -499,19 +499,15 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionsStore),
|
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionsStore),
|
||||||
defaultCurrency() {
|
defaultCurrency() {
|
||||||
if (this.query.accountId && this.query.accountId !== '0') {
|
return getUnifiedSelectedAccountsCurrencyOrDefaultCurrency(this.allAccounts, this.queryAllFilterAccountIds, this.userStore.currentUserDefaultCurrency);
|
||||||
const account = this.allAccounts[this.query.accountId];
|
|
||||||
|
|
||||||
if (account && account.currency && account.currency !== currencyConstants.parentAccountCurrencyPlaceholder) {
|
|
||||||
return account.currency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.userStore.currentUserDefaultCurrency;
|
|
||||||
},
|
},
|
||||||
canAddTransaction() {
|
canAddTransaction() {
|
||||||
if (this.query.accountId && this.query.accountId !== '0') {
|
if (this.queryAllFilterCategoryIdsCount > 1 || this.queryAllFilterAccountIdsCount > 1) {
|
||||||
const account = this.allAccounts[this.query.accountId];
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.query.accountIds) {
|
||||||
|
const account = this.allAccounts[this.query.accountIds];
|
||||||
|
|
||||||
if (account && account.type === accountConstants.allAccountTypes.MultiSubAccounts) {
|
if (account && account.type === accountConstants.allAccountTypes.MultiSubAccounts) {
|
||||||
return false;
|
return false;
|
||||||
@@ -547,11 +543,31 @@ export default {
|
|||||||
queryMaxTime() {
|
queryMaxTime() {
|
||||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.maxTime);
|
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.maxTime);
|
||||||
},
|
},
|
||||||
|
queryAllFilterCategoryIds() {
|
||||||
|
return this.transactionsStore.allFilterCategoryIds;
|
||||||
|
},
|
||||||
|
queryAllFilterAccountIds() {
|
||||||
|
return this.transactionsStore.allFilterAccountIds;
|
||||||
|
},
|
||||||
|
queryAllFilterCategoryIdsCount() {
|
||||||
|
return this.transactionsStore.allFilterCategoryIdsCount;
|
||||||
|
},
|
||||||
|
queryAllFilterAccountIdsCount() {
|
||||||
|
return this.transactionsStore.allFilterAccountIdsCount;
|
||||||
|
},
|
||||||
queryCategoryName() {
|
queryCategoryName() {
|
||||||
return getNameByKeyValue(this.allCategories, this.query.categoryId, null, 'name', this.$t('Category'));
|
if (this.queryAllFilterCategoryIdsCount > 1) {
|
||||||
|
return this.$t('Multiple Categories');
|
||||||
|
}
|
||||||
|
|
||||||
|
return getNameByKeyValue(this.allCategories, this.query.categoryIds, null, 'name', this.$t('Category'));
|
||||||
},
|
},
|
||||||
queryAccountName() {
|
queryAccountName() {
|
||||||
return getNameByKeyValue(this.allAccounts, this.query.accountId, null, 'name', this.$t('Account'));
|
if (this.queryAllFilterAccountIdsCount > 1) {
|
||||||
|
return this.$t('Multiple Accounts');
|
||||||
|
}
|
||||||
|
|
||||||
|
return getNameByKeyValue(this.allAccounts, this.query.accountIds, null, 'name', this.$t('Account'));
|
||||||
},
|
},
|
||||||
queryAmount() {
|
queryAmount() {
|
||||||
if (!this.query.amountFilter) {
|
if (!this.query.amountFilter) {
|
||||||
@@ -769,8 +785,8 @@ export default {
|
|||||||
maxTime: dateRange ? dateRange.maxTime : undefined,
|
maxTime: dateRange ? dateRange.maxTime : undefined,
|
||||||
minTime: dateRange ? dateRange.minTime : undefined,
|
minTime: dateRange ? dateRange.minTime : undefined,
|
||||||
type: parseInt(query.type) > 0 ? parseInt(query.type) : undefined,
|
type: parseInt(query.type) > 0 ? parseInt(query.type) : undefined,
|
||||||
categoryId: query.categoryIds,
|
categoryIds: query.categoryIds,
|
||||||
accountId: query.accountIds,
|
accountIds: query.accountIds,
|
||||||
amountFilter: query.amountFilter || '',
|
amountFilter: query.amountFilter || '',
|
||||||
keyword: query.keyword || ''
|
keyword: query.keyword || ''
|
||||||
});
|
});
|
||||||
@@ -912,17 +928,24 @@ export default {
|
|||||||
changeTypeFilter(type) {
|
changeTypeFilter(type) {
|
||||||
let removeCategoryFilter = false;
|
let removeCategoryFilter = false;
|
||||||
|
|
||||||
if (type && this.query.categoryId) {
|
if (type && this.query.categoryIds) {
|
||||||
const category = this.allCategories[this.query.categoryId];
|
for (let categoryId in this.queryAllFilterCategoryIds) {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(this.queryAllFilterCategoryIds, categoryId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (category && category.type !== transactionTypeToCategoryType(type)) {
|
const category = this.allCategories[categoryId];
|
||||||
removeCategoryFilter = true;
|
|
||||||
|
if (category && category.type !== transactionTypeToCategoryType(type)) {
|
||||||
|
removeCategoryFilter = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactionsStore.updateTransactionListFilter({
|
this.transactionsStore.updateTransactionListFilter({
|
||||||
type: type,
|
type: type,
|
||||||
categoryId: removeCategoryFilter ? '0' : undefined
|
categoryIds: removeCategoryFilter ? '' : undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -930,15 +953,15 @@ export default {
|
|||||||
this.transactionsStore.clearTransactions();
|
this.transactionsStore.clearTransactions();
|
||||||
this.$router.push(this.getFilterLinkUrl());
|
this.$router.push(this.getFilterLinkUrl());
|
||||||
},
|
},
|
||||||
changeCategoryFilter(categoryId) {
|
changeCategoryFilter(categoryIds) {
|
||||||
this.categoryMenuState = false;
|
this.categoryMenuState = false;
|
||||||
|
|
||||||
if (this.query.categoryId === categoryId) {
|
if (this.query.categoryIds === categoryIds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactionsStore.updateTransactionListFilter({
|
this.transactionsStore.updateTransactionListFilter({
|
||||||
categoryId: categoryId
|
categoryIds: categoryIds
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -990,13 +1013,13 @@ export default {
|
|||||||
this.transactionsStore.clearTransactions();
|
this.transactionsStore.clearTransactions();
|
||||||
this.$router.push(this.getFilterLinkUrl());
|
this.$router.push(this.getFilterLinkUrl());
|
||||||
},
|
},
|
||||||
changeAccountFilter(accountId) {
|
changeAccountFilter(accountIds) {
|
||||||
if (this.query.accountId === accountId) {
|
if (this.query.accountIds === accountIds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactionsStore.updateTransactionListFilter({
|
this.transactionsStore.updateTransactionListFilter({
|
||||||
accountId: accountId
|
accountIds: accountIds
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -1023,8 +1046,8 @@ export default {
|
|||||||
|
|
||||||
self.$refs.editDialog.open({
|
self.$refs.editDialog.open({
|
||||||
type: self.query.type,
|
type: self.query.type,
|
||||||
categoryId: self.query.categoryId,
|
categoryId: self.query.categoryIds,
|
||||||
accountId: self.query.accountId
|
accountId: self.query.accountIds
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
if (result && result.message) {
|
if (result && result.message) {
|
||||||
self.$refs.snackbar.showMessage(result.message);
|
self.$refs.snackbar.showMessage(result.message);
|
||||||
@@ -1149,8 +1172,8 @@ export default {
|
|||||||
getTransactionTypeFromCategoryType(categoryType) {
|
getTransactionTypeFromCategoryType(categoryType) {
|
||||||
return categoryTypeToTransactionType(parseInt(categoryType));
|
return categoryTypeToTransactionType(parseInt(categoryType));
|
||||||
},
|
},
|
||||||
getCategoryListItemCheckedClass(category, queryCategoryId) {
|
getCategoryListItemCheckedClass(category, queryCategoryIds) {
|
||||||
if (category.id === queryCategoryId) {
|
if (queryCategoryIds && queryCategoryIds[category.id]) {
|
||||||
return {
|
return {
|
||||||
'list-item-selected': true,
|
'list-item-selected': true,
|
||||||
'has-children-item-selected': true
|
'has-children-item-selected': true
|
||||||
@@ -1158,7 +1181,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < category.subCategories.length; i++) {
|
for (let i = 0; i < category.subCategories.length; i++) {
|
||||||
if (category.subCategories[i].id === queryCategoryId) {
|
if (queryCategoryIds && queryCategoryIds[category.subCategories[i].id]) {
|
||||||
return {
|
return {
|
||||||
'list-item-selected': true,
|
'list-item-selected': true,
|
||||||
'has-children-item-selected': true
|
'has-children-item-selected': true
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
||||||
<f7-nav-title :title="$t('Transaction List')"></f7-nav-title>
|
<f7-nav-title :title="$t('Transaction List')"></f7-nav-title>
|
||||||
<f7-nav-right class="navbar-compact-icons">
|
<f7-nav-right class="navbar-compact-icons">
|
||||||
<f7-link icon-f7="plus" :class="{ 'disabled': !canAddTransaction }" :href="`/transaction/add?type=${query.type}&categoryId=${query.categoryId}&accountId=${query.accountId}`"></f7-link>
|
<f7-link icon-f7="plus" :class="{ 'disabled': !canAddTransaction }" :href="`/transaction/add?type=${query.type}&categoryId=${query.categoryIds}&accountId=${query.accountIds}`"></f7-link>
|
||||||
</f7-nav-right>
|
</f7-nav-right>
|
||||||
|
|
||||||
<f7-subnavbar :inner="false">
|
<f7-subnavbar :inner="false">
|
||||||
@@ -36,10 +36,10 @@
|
|||||||
<f7-icon f7="arrow_right_square"></f7-icon>
|
<f7-icon f7="arrow_right_square"></f7-icon>
|
||||||
</f7-link>
|
</f7-link>
|
||||||
<f7-link class="tabbar-text-with-ellipsis" popover-open=".category-popover-menu" :class="{ 'disabled': query.type === 1 }">
|
<f7-link class="tabbar-text-with-ellipsis" popover-open=".category-popover-menu" :class="{ 'disabled': query.type === 1 }">
|
||||||
<span :class="{ 'tabbar-item-changed': query.categoryId > 0 }">{{ queryCategoryName }}</span>
|
<span :class="{ 'tabbar-item-changed': query.categoryIds }">{{ queryCategoryName }}</span>
|
||||||
</f7-link>
|
</f7-link>
|
||||||
<f7-link class="tabbar-text-with-ellipsis" popover-open=".account-popover-menu">
|
<f7-link class="tabbar-text-with-ellipsis" popover-open=".account-popover-menu">
|
||||||
<span :class="{ 'tabbar-item-changed': query.accountId > 0 }">{{ queryAccountName }}</span>
|
<span :class="{ 'tabbar-item-changed': query.accountIds }">{{ queryAccountName }}</span>
|
||||||
</f7-link>
|
</f7-link>
|
||||||
<f7-link popover-open=".more-popover-menu">
|
<f7-link popover-open=".more-popover-menu">
|
||||||
<f7-icon f7="ellipsis_vertical" :class="{ 'tabbar-item-changed': query.type > 0 || query.amountFilter }"></f7-icon>
|
<f7-icon f7="ellipsis_vertical" :class="{ 'tabbar-item-changed': query.type > 0 || query.amountFilter }"></f7-icon>
|
||||||
@@ -200,8 +200,8 @@
|
|||||||
<div class="item-after">
|
<div class="item-after">
|
||||||
<div class="transaction-amount" v-if="transaction.sourceAccount"
|
<div class="transaction-amount" v-if="transaction.sourceAccount"
|
||||||
:class="{ 'text-color-teal': transaction.type === allTransactionTypes.Expense, 'text-color-red': transaction.type === allTransactionTypes.Income }">
|
:class="{ 'text-color-teal': transaction.type === allTransactionTypes.Expense, 'text-color-red': transaction.type === allTransactionTypes.Income }">
|
||||||
<span v-if="!query.accountId || query.accountId === '0' || (transaction.sourceAccount && (transaction.sourceAccount.id === query.accountId || transaction.sourceAccount.parentId === query.accountId))">{{ getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount) }}</span>
|
<span v-if="!query.accountIds || (transaction.sourceAccount && (transaction.sourceAccount.id === query.accountIds || transaction.sourceAccount.parentId === query.accountIds))">{{ getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount) }}</span>
|
||||||
<span v-else-if="query.accountId && query.accountId !== '0' && transaction.destinationAccount && (transaction.destinationAccount.id === query.accountId || transaction.destinationAccount.parentId === query.accountId)">{{ getDisplayAmount(transaction.destinationAmount, transaction.destinationAccount.currency, transaction.hideAmount) }}</span>
|
<span v-else-if="query.accountIds && transaction.destinationAccount && (transaction.destinationAccount.id === query.accountIds || transaction.destinationAccount.parentId === query.accountIds)">{{ getDisplayAmount(transaction.destinationAmount, transaction.destinationAccount.currency, transaction.hideAmount) }}</span>
|
||||||
<span v-else></span>
|
<span v-else></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -284,12 +284,12 @@
|
|||||||
v-model:opened="showCategoryPopover"
|
v-model:opened="showCategoryPopover"
|
||||||
@popover:open="scrollPopoverToSelectedItem">
|
@popover:open="scrollPopoverToSelectedItem">
|
||||||
<f7-list dividers accordion-list>
|
<f7-list dividers accordion-list>
|
||||||
<f7-list-item :class="{ 'list-item-selected': query.categoryId === '0' }" :title="$t('All')" @click="changeCategoryFilter('0')">
|
<f7-list-item :class="{ 'list-item-selected': !query.categoryIds }" :title="$t('All')" @click="changeCategoryFilter('')">
|
||||||
<template #media>
|
<template #media>
|
||||||
<f7-icon f7="rectangle_badge_checkmark"></f7-icon>
|
<f7-icon f7="rectangle_badge_checkmark"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="query.categoryId === '0'"></f7-icon>
|
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="!query.categoryIds"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
</f7-list-item>
|
</f7-list-item>
|
||||||
</f7-list>
|
</f7-list>
|
||||||
@@ -301,7 +301,7 @@
|
|||||||
<f7-list-item divider :title="getTransactionTypeName(getTransactionTypeFromCategoryType(categoryType), 'Type')"></f7-list-item>
|
<f7-list-item divider :title="getTransactionTypeName(getTransactionTypeFromCategoryType(categoryType), 'Type')"></f7-list-item>
|
||||||
<f7-list-item accordion-item
|
<f7-list-item accordion-item
|
||||||
:title="category.name"
|
:title="category.name"
|
||||||
:class="getCategoryListItemCheckedClass(category, query.categoryId)"
|
:class="getCategoryListItemCheckedClass(category, queryAllFilterCategoryIds)"
|
||||||
:key="category.id"
|
:key="category.id"
|
||||||
v-for="category in categories"
|
v-for="category in categories"
|
||||||
v-show="!category.hidden"
|
v-show="!category.hidden"
|
||||||
@@ -311,16 +311,16 @@
|
|||||||
</template>
|
</template>
|
||||||
<f7-accordion-content>
|
<f7-accordion-content>
|
||||||
<f7-list dividers class="padding-left">
|
<f7-list dividers class="padding-left">
|
||||||
<f7-list-item :class="{ 'list-item-selected': query.categoryId === category.id }" :title="$t('All')" @click="changeCategoryFilter(category.id)">
|
<f7-list-item :class="{ 'list-item-selected': query.categoryIds === category.id }" :title="$t('All')" @click="changeCategoryFilter(category.id)">
|
||||||
<template #media>
|
<template #media>
|
||||||
<f7-icon f7="rectangle_badge_checkmark"></f7-icon>
|
<f7-icon f7="rectangle_badge_checkmark"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="query.categoryId === category.id"></f7-icon>
|
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="query.categoryIds === category.id"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
</f7-list-item>
|
</f7-list-item>
|
||||||
<f7-list-item :title="subCategory.name"
|
<f7-list-item :title="subCategory.name"
|
||||||
:class="{ 'list-item-selected': query.categoryId === subCategory.id }"
|
:class="{ 'list-item-selected': query.categoryIds === subCategory.id }"
|
||||||
:key="subCategory.id"
|
:key="subCategory.id"
|
||||||
v-for="subCategory in category.subCategories"
|
v-for="subCategory in category.subCategories"
|
||||||
v-show="!subCategory.hidden"
|
v-show="!subCategory.hidden"
|
||||||
@@ -332,7 +332,7 @@
|
|||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon"
|
<f7-icon class="list-item-checked-icon"
|
||||||
f7="checkmark_alt"
|
f7="checkmark_alt"
|
||||||
v-if="query.categoryId === subCategory.id">
|
v-if="query.categoryIds === subCategory.id">
|
||||||
</f7-icon>
|
</f7-icon>
|
||||||
</template>
|
</template>
|
||||||
</f7-list-item>
|
</f7-list-item>
|
||||||
@@ -346,16 +346,16 @@
|
|||||||
v-model:opened="showAccountPopover"
|
v-model:opened="showAccountPopover"
|
||||||
@popover:open="scrollPopoverToSelectedItem">
|
@popover:open="scrollPopoverToSelectedItem">
|
||||||
<f7-list dividers>
|
<f7-list dividers>
|
||||||
<f7-list-item :class="{ 'list-item-selected': query.accountId === '0' }" :title="$t('All')" @click="changeAccountFilter('0')">
|
<f7-list-item :class="{ 'list-item-selected': !query.accountIds }" :title="$t('All')" @click="changeAccountFilter('')">
|
||||||
<template #media>
|
<template #media>
|
||||||
<f7-icon f7="rectangle_badge_checkmark"></f7-icon>
|
<f7-icon f7="rectangle_badge_checkmark"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="query.accountId === '0'"></f7-icon>
|
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="!query.accountIds"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
</f7-list-item>
|
</f7-list-item>
|
||||||
<f7-list-item :title="account.name"
|
<f7-list-item :title="account.name"
|
||||||
:class="{ 'list-item-selected': query.accountId === account.id }"
|
:class="{ 'list-item-selected': query.accountIds === account.id }"
|
||||||
:key="account.id"
|
:key="account.id"
|
||||||
v-for="account in allAccounts"
|
v-for="account in allAccounts"
|
||||||
v-show="!account.hidden"
|
v-show="!account.hidden"
|
||||||
@@ -367,7 +367,7 @@
|
|||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon"
|
<f7-icon class="list-item-checked-icon"
|
||||||
f7="checkmark_alt"
|
f7="checkmark_alt"
|
||||||
v-if="query.accountId === account.id">
|
v-if="query.accountIds === account.id">
|
||||||
</f7-icon>
|
</f7-icon>
|
||||||
</template>
|
</template>
|
||||||
</f7-list-item>
|
</f7-list-item>
|
||||||
@@ -445,7 +445,6 @@ import { useTransactionsStore } from '@/stores/transaction.js';
|
|||||||
|
|
||||||
import numeralConstants from '@/consts/numeral.js';
|
import numeralConstants from '@/consts/numeral.js';
|
||||||
import datetimeConstants from '@/consts/datetime.js';
|
import datetimeConstants from '@/consts/datetime.js';
|
||||||
import currencyConstants from '@/consts/currency.js';
|
|
||||||
import accountConstants from '@/consts/account.js';
|
import accountConstants from '@/consts/account.js';
|
||||||
import transactionConstants from '@/consts/transaction.js';
|
import transactionConstants from '@/consts/transaction.js';
|
||||||
import { getNameByKeyValue } from '@/lib/common.js';
|
import { getNameByKeyValue } from '@/lib/common.js';
|
||||||
@@ -461,6 +460,7 @@ import {
|
|||||||
getDateRangeByDateType
|
getDateRangeByDateType
|
||||||
} from '@/lib/datetime.js';
|
} from '@/lib/datetime.js';
|
||||||
import { categoryTypeToTransactionType, transactionTypeToCategoryType } from '@/lib/category.js';
|
import { categoryTypeToTransactionType, transactionTypeToCategoryType } from '@/lib/category.js';
|
||||||
|
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js';
|
||||||
import { onSwipeoutDeleted, scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
import { onSwipeoutDeleted, scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -487,19 +487,15 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionsStore),
|
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionsStore),
|
||||||
defaultCurrency() {
|
defaultCurrency() {
|
||||||
if (this.query.accountId && this.query.accountId !== '0') {
|
return getUnifiedSelectedAccountsCurrencyOrDefaultCurrency(this.allAccounts, this.queryAllFilterAccountIds, this.userStore.currentUserDefaultCurrency);
|
||||||
const account = this.allAccounts[this.query.accountId];
|
|
||||||
|
|
||||||
if (account && account.currency && account.currency !== currencyConstants.parentAccountCurrencyPlaceholder) {
|
|
||||||
return account.currency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.userStore.currentUserDefaultCurrency;
|
|
||||||
},
|
},
|
||||||
canAddTransaction() {
|
canAddTransaction() {
|
||||||
if (this.query.accountId && this.query.accountId !== '0') {
|
if (this.queryAllFilterCategoryIdsCount > 1 || this.queryAllFilterAccountIdsCount > 1) {
|
||||||
const account = this.allAccounts[this.query.accountId];
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.query.accountIds) {
|
||||||
|
const account = this.allAccounts[this.query.accountIds];
|
||||||
|
|
||||||
if (account && account.type === accountConstants.allAccountTypes.MultiSubAccounts) {
|
if (account && account.type === accountConstants.allAccountTypes.MultiSubAccounts) {
|
||||||
return false;
|
return false;
|
||||||
@@ -530,11 +526,31 @@ export default {
|
|||||||
queryMaxTime() {
|
queryMaxTime() {
|
||||||
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.maxTime);
|
return this.$locale.formatUnixTimeToLongDateTime(this.userStore, this.query.maxTime);
|
||||||
},
|
},
|
||||||
|
queryAllFilterCategoryIds() {
|
||||||
|
return this.transactionsStore.allFilterCategoryIds;
|
||||||
|
},
|
||||||
|
queryAllFilterAccountIds() {
|
||||||
|
return this.transactionsStore.allFilterAccountIds;
|
||||||
|
},
|
||||||
|
queryAllFilterCategoryIdsCount() {
|
||||||
|
return this.transactionsStore.allFilterCategoryIdsCount;
|
||||||
|
},
|
||||||
|
queryAllFilterAccountIdsCount() {
|
||||||
|
return this.transactionsStore.allFilterAccountIdsCount;
|
||||||
|
},
|
||||||
queryCategoryName() {
|
queryCategoryName() {
|
||||||
return getNameByKeyValue(this.allCategories, this.query.categoryId, null, 'name', this.$t('Category'));
|
if (this.queryAllFilterCategoryIdsCount > 1) {
|
||||||
|
return this.$t('Multiple Categories');
|
||||||
|
}
|
||||||
|
|
||||||
|
return getNameByKeyValue(this.allCategories, this.query.categoryIds, null, 'name', this.$t('Category'));
|
||||||
},
|
},
|
||||||
queryAccountName() {
|
queryAccountName() {
|
||||||
return getNameByKeyValue(this.allAccounts, this.query.accountId, null, 'name', this.$t('Account'));
|
if (this.queryAllFilterAccountIdsCount > 1) {
|
||||||
|
return this.$t('Multiple Accounts');
|
||||||
|
}
|
||||||
|
|
||||||
|
return getNameByKeyValue(this.allAccounts, this.query.accountIds, null, 'name', this.$t('Account'));
|
||||||
},
|
},
|
||||||
queryAmount() {
|
queryAmount() {
|
||||||
if (!this.query.amountFilter) {
|
if (!this.query.amountFilter) {
|
||||||
@@ -628,8 +644,8 @@ export default {
|
|||||||
maxTime: dateRange ? dateRange.maxTime : undefined,
|
maxTime: dateRange ? dateRange.maxTime : undefined,
|
||||||
minTime: dateRange ? dateRange.minTime : undefined,
|
minTime: dateRange ? dateRange.minTime : undefined,
|
||||||
type: parseInt(query.type) > 0 ? parseInt(query.type) : undefined,
|
type: parseInt(query.type) > 0 ? parseInt(query.type) : undefined,
|
||||||
categoryId: query.categoryId,
|
categoryIds: query.categoryIds,
|
||||||
accountId: query.accountId
|
accountIds: query.accountIds
|
||||||
});
|
});
|
||||||
|
|
||||||
this.reload(null);
|
this.reload(null);
|
||||||
@@ -777,41 +793,48 @@ export default {
|
|||||||
|
|
||||||
let removeCategoryFilter = false;
|
let removeCategoryFilter = false;
|
||||||
|
|
||||||
if (type && this.query.categoryId) {
|
if (type && this.query.categoryIds) {
|
||||||
const category = this.allCategories[this.query.categoryId];
|
for (let categoryId in this.queryAllFilterCategoryIds) {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(this.queryAllFilterCategoryIds, categoryId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (category && category.type !== transactionTypeToCategoryType(type)) {
|
const category = this.allCategories[categoryId];
|
||||||
removeCategoryFilter = true;
|
|
||||||
|
if (category && category.type !== transactionTypeToCategoryType(type)) {
|
||||||
|
removeCategoryFilter = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactionsStore.updateTransactionListFilter({
|
this.transactionsStore.updateTransactionListFilter({
|
||||||
type: type,
|
type: type,
|
||||||
categoryId: removeCategoryFilter ? '0' : undefined
|
categoryIds: removeCategoryFilter ? '' : undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
this.showMorePopover = false;
|
this.showMorePopover = false;
|
||||||
this.reload(null);
|
this.reload(null);
|
||||||
},
|
},
|
||||||
changeCategoryFilter(categoryId) {
|
changeCategoryFilter(categoryIds) {
|
||||||
if (this.query.categoryId === categoryId) {
|
if (this.query.categoryIds === categoryIds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactionsStore.updateTransactionListFilter({
|
this.transactionsStore.updateTransactionListFilter({
|
||||||
categoryId: categoryId
|
categoryIds: categoryIds
|
||||||
});
|
});
|
||||||
|
|
||||||
this.showCategoryPopover = false;
|
this.showCategoryPopover = false;
|
||||||
this.reload(null);
|
this.reload(null);
|
||||||
},
|
},
|
||||||
changeAccountFilter(accountId) {
|
changeAccountFilter(accountIds) {
|
||||||
if (this.query.accountId === accountId) {
|
if (this.query.accountIds === accountIds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactionsStore.updateTransactionListFilter({
|
this.transactionsStore.updateTransactionListFilter({
|
||||||
accountId: accountId
|
accountIds: accountIds
|
||||||
});
|
});
|
||||||
|
|
||||||
this.showAccountPopover = false;
|
this.showAccountPopover = false;
|
||||||
@@ -959,15 +982,15 @@ export default {
|
|||||||
color: 'transparent'
|
color: 'transparent'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getCategoryListItemCheckedClass(category, queryCategoryId) {
|
getCategoryListItemCheckedClass(category, queryCategoryIds) {
|
||||||
if (category.id === queryCategoryId) {
|
if (queryCategoryIds && queryCategoryIds[category.id]) {
|
||||||
return {
|
return {
|
||||||
'list-item-checked': true
|
'list-item-checked': true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < category.subCategories.length; i++) {
|
for (let i = 0; i < category.subCategories.length; i++) {
|
||||||
if (category.subCategories[i].id === queryCategoryId) {
|
if (queryCategoryIds && queryCategoryIds[category.subCategories[i].id]) {
|
||||||
return {
|
return {
|
||||||
'list-item-checked': true
|
'list-item-checked': true
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user