mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
show amount in default currency in transaction edit page / dialog when account currency is not default currency
This commit is contained in:
@@ -26,6 +26,10 @@ import {
|
|||||||
isArray
|
isArray
|
||||||
} from '@/lib/common.ts';
|
} from '@/lib/common.ts';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getExchangedAmountByRate
|
||||||
|
} from '@/lib/numeral.ts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getUtcOffsetByUtcOffsetMinutes,
|
getUtcOffsetByUtcOffsetMinutes,
|
||||||
getTimezoneOffsetMinutes,
|
getTimezoneOffsetMinutes,
|
||||||
@@ -165,6 +169,33 @@ export function useTransactionEditPageBase(type: TransactionEditPageType, initMo
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const sourceAmountTitle = computed<string>(() => {
|
||||||
|
const sourceAccount = allAccountsMap.value[transaction.value.sourceAccountId];
|
||||||
|
const amountName = tt(sourceAmountName.value);
|
||||||
|
|
||||||
|
if (!sourceAccount || sourceAccount.currency === defaultCurrency.value || !transaction.value.sourceAmount || transaction.value.hideAmount) {
|
||||||
|
return amountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fromExchangeRate = exchangeRatesStore.latestExchangeRateMap[sourceAccount.currency];
|
||||||
|
const toExchangeRate = exchangeRatesStore.latestExchangeRateMap[defaultCurrency.value];
|
||||||
|
|
||||||
|
if (!fromExchangeRate || !fromExchangeRate.rate || !toExchangeRate || !toExchangeRate.rate) {
|
||||||
|
return amountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
let amountInDefaultCurrency = getExchangedAmountByRate(transaction.value.sourceAmount, fromExchangeRate.rate, toExchangeRate.rate);
|
||||||
|
|
||||||
|
if (!amountInDefaultCurrency) {
|
||||||
|
return amountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
amountInDefaultCurrency = Math.floor(amountInDefaultCurrency);
|
||||||
|
|
||||||
|
const displayAmountInDefaultCurrency = getDisplayAmount(amountInDefaultCurrency, transaction.value.hideAmount, defaultCurrency.value);
|
||||||
|
return amountName + ` (${displayAmountInDefaultCurrency})`;
|
||||||
|
});
|
||||||
|
|
||||||
const sourceAccountTitle = computed<string>(() => {
|
const sourceAccountTitle = computed<string>(() => {
|
||||||
if (transaction.value.type === TransactionType.Expense || transaction.value.type === TransactionType.Income) {
|
if (transaction.value.type === TransactionType.Expense || transaction.value.type === TransactionType.Income) {
|
||||||
return 'Account';
|
return 'Account';
|
||||||
@@ -404,6 +435,7 @@ export function useTransactionEditPageBase(type: TransactionEditPageType, initMo
|
|||||||
saveButtonTitle,
|
saveButtonTitle,
|
||||||
cancelButtonTitle,
|
cancelButtonTitle,
|
||||||
sourceAmountName,
|
sourceAmountName,
|
||||||
|
sourceAmountTitle,
|
||||||
sourceAccountTitle,
|
sourceAccountTitle,
|
||||||
transferInAmountTitle,
|
transferInAmountTitle,
|
||||||
sourceAccountName,
|
sourceAccountName,
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
:disabled="loading || submitting"
|
:disabled="loading || submitting"
|
||||||
:persistent-placeholder="true"
|
:persistent-placeholder="true"
|
||||||
:hide="transaction.hideAmount"
|
:hide="transaction.hideAmount"
|
||||||
:label="tt(sourceAmountName)"
|
:label="sourceAmountTitle"
|
||||||
:placeholder="tt(sourceAmountName)"
|
:placeholder="tt(sourceAmountName)"
|
||||||
:enable-formula="mode !== TransactionEditPageMode.View"
|
:enable-formula="mode !== TransactionEditPageMode.View"
|
||||||
v-model="transaction.sourceAmount"/>
|
v-model="transaction.sourceAmount"/>
|
||||||
@@ -583,6 +583,7 @@ const {
|
|||||||
saveButtonTitle,
|
saveButtonTitle,
|
||||||
cancelButtonTitle,
|
cancelButtonTitle,
|
||||||
sourceAmountName,
|
sourceAmountName,
|
||||||
|
sourceAmountTitle,
|
||||||
sourceAccountTitle,
|
sourceAccountTitle,
|
||||||
transferInAmountTitle,
|
transferInAmountTitle,
|
||||||
sourceAccountName,
|
sourceAccountName,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
class="transaction-edit-amount"
|
class="transaction-edit-amount"
|
||||||
link="#" no-chevron
|
link="#" no-chevron
|
||||||
:class="sourceAmountClass"
|
:class="sourceAmountClass"
|
||||||
:header="tt(sourceAmountName)"
|
:header="sourceAmountTitle"
|
||||||
:title="getDisplayAmount(transaction.sourceAmount, transaction.hideAmount, sourceAccountCurrency)"
|
:title="getDisplayAmount(transaction.sourceAmount, transaction.hideAmount, sourceAccountCurrency)"
|
||||||
@click="showSourceAmountSheet = true"
|
@click="showSourceAmountSheet = true"
|
||||||
>
|
>
|
||||||
@@ -570,7 +570,7 @@ const {
|
|||||||
canAddTransactionPicture,
|
canAddTransactionPicture,
|
||||||
title,
|
title,
|
||||||
saveButtonTitle,
|
saveButtonTitle,
|
||||||
sourceAmountName,
|
sourceAmountTitle,
|
||||||
sourceAccountTitle,
|
sourceAccountTitle,
|
||||||
transferInAmountTitle,
|
transferInAmountTitle,
|
||||||
sourceAccountName,
|
sourceAccountName,
|
||||||
|
|||||||
Reference in New Issue
Block a user