diff --git a/src/lib/transaction.js b/src/lib/transaction.js index b4907ba9..22a8761e 100644 --- a/src/lib/transaction.js +++ b/src/lib/transaction.js @@ -14,6 +14,14 @@ import { getFirstAvaiableSubCategoryId } from './category.js'; +function getDisplayAmount(amount, currency, hideAmount, formatAmountWithCurrencyFunc) { + if (hideAmount) { + return formatAmountWithCurrencyFunc('***', currency); + } + + return formatAmountWithCurrencyFunc(amount, currency); +} + export function setTransactionModelByTransaction(transaction, transaction2, allCategories, allCategoriesMap, allVisibleAccounts, allAccountsMap, defaultAccountId, options, setContextData, convertContextTime) { if ((!options.type || options.type === '0') && options.categoryId && options.categoryId !== '0' && allCategoriesMap[options.categoryId]) { const category = allCategoriesMap[options.categoryId]; @@ -148,3 +156,33 @@ export function setTransactionModelByTransaction(transaction, transaction2, allC } } } + +export function getTransactionDisplayAmount(transaction, allFilterAccountIdsCount, allFilterAccountIds, formatAmountWithCurrencyFunc) { + if (allFilterAccountIdsCount < 1) { + if (transaction.sourceAccount) { + return getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount, formatAmountWithCurrencyFunc); + } + } else if (allFilterAccountIdsCount === 1) { + if (transaction.sourceAccount && (allFilterAccountIds[transaction.sourceAccount.id] || allFilterAccountIds[transaction.sourceAccount.parentId])) { + return getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount , formatAmountWithCurrencyFunc); + } else if (transaction.destinationAccount && (allFilterAccountIds[transaction.destinationAccount.id] || allFilterAccountIds[transaction.destinationAccount.parentId])) { + return getDisplayAmount(transaction.destinationAmount, transaction.destinationAccount.currency, transaction.hideAmount , formatAmountWithCurrencyFunc); + } + } else { // allFilterAccountIdsCount > 1 + if (transaction.sourceAccount && transaction.destinationAccount) { + if ((allFilterAccountIds[transaction.sourceAccount.id] || allFilterAccountIds[transaction.sourceAccount.parentId]) + && !allFilterAccountIds[transaction.destinationAccount.id] && !allFilterAccountIds[transaction.destinationAccount.parentId]) { + return getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount , formatAmountWithCurrencyFunc); + } else if ((allFilterAccountIds[transaction.destinationAccount.id] || allFilterAccountIds[transaction.destinationAccount.parentId]) + && !allFilterAccountIds[transaction.sourceAccount.id] && !allFilterAccountIds[transaction.sourceAccount.parentId]) { + return getDisplayAmount(transaction.destinationAmount, transaction.destinationAccount.currency, transaction.hideAmount , formatAmountWithCurrencyFunc); + } + } + } + + if (transaction.sourceAccount) { + return getDisplayAmount(transaction.sourceAmount, transaction.sourceAccount.currency, transaction.hideAmount, formatAmountWithCurrencyFunc); + } + + return ''; +} diff --git a/src/views/desktop/transactions/ListPage.vue b/src/views/desktop/transactions/ListPage.vue index 90449466..204febad 100644 --- a/src/views/desktop/transactions/ListPage.vue +++ b/src/views/desktop/transactions/ListPage.vue @@ -133,6 +133,17 @@ + + +
+ + {{ $t('Multiple Categories') }} +
+
+
@@ -461,6 +475,7 @@ import { } from '@/lib/datetime.js'; import { categoryTypeToTransactionType, transactionTypeToCategoryType } from '@/lib/category.js'; import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js'; +import { getTransactionDisplayAmount } from '@/lib/transaction.js'; import { onSwipeoutDeleted, scrollToSelectedItem } from '@/lib/ui.mobile.js'; export default { @@ -490,11 +505,7 @@ export default { return getUnifiedSelectedAccountsCurrencyOrDefaultCurrency(this.allAccounts, this.queryAllFilterAccountIds, this.userStore.currentUserDefaultCurrency); }, canAddTransaction() { - if (this.queryAllFilterCategoryIdsCount > 1 || this.queryAllFilterAccountIdsCount > 1) { - return false; - } - - if (this.query.accountIds) { + if (this.query.accountIds && this.queryAllFilterAccountIdsCount === 1) { const account = this.allAccounts[this.query.accountIds]; if (account && account.type === accountConstants.allAccountTypes.MultiSubAccounts) { @@ -868,6 +879,12 @@ export default { }); this.reload(null); + }, + showMultipleCategoriesPopup() { + + }, + showMultipleAccountsPopup() { + }, duplicate(transaction) { this.f7router.navigate(`/transaction/add?id=${transaction.id}&type=${transaction.type}`); @@ -936,13 +953,6 @@ export default { getDisplayTimezone(transaction) { return `UTC${getUtcOffsetByUtcOffsetMinutes(transaction.utcOffset)}`; }, - getDisplayAmount(amount, currency, hideAmount) { - if (hideAmount) { - return this.getDisplayCurrency('***', currency); - } - - return this.getDisplayCurrency(amount, currency); - }, getDisplayMonthTotalAmount(amount, currency, symbol, incomplete) { const displayAmount = this.getDisplayCurrency(amount, currency); return symbol + displayAmount + (incomplete ? '+' : ''); @@ -970,6 +980,9 @@ export default { getTransactionTypeFromCategoryType(categoryType) { return categoryTypeToTransactionType(parseInt(categoryType)); }, + getTransactionDisplayAmount(transaction) { + return getTransactionDisplayAmount(transaction, this.queryAllFilterAccountIdsCount, this.queryAllFilterAccountIds, this.getDisplayCurrency); + }, getTransactionDomId(transaction) { return 'transaction_' + transaction.id; },