mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
show exchange rate in transaction edit page when the currencies of source account and destination account are different
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
:disabled="loading || submitting"
|
||||
:persistent-placeholder="true"
|
||||
:hide="transaction.hideAmount"
|
||||
:label="$t('Transfer In Amount')"
|
||||
:label="transferInAmountTitle"
|
||||
:placeholder="$t('Transfer In Amount')"
|
||||
v-model="transaction.destinationAmount"/>
|
||||
</v-col>
|
||||
@@ -325,6 +325,9 @@ import {
|
||||
getTimezoneOffsetMinutes,
|
||||
getCurrentUnixTime
|
||||
} from '@/lib/datetime.js';
|
||||
import {
|
||||
getAdaptiveDisplayAmountRate
|
||||
} from '@/lib/currency.js';
|
||||
import {
|
||||
getFirstAvailableCategoryId
|
||||
} from '@/lib/category.js';
|
||||
@@ -417,6 +420,24 @@ export default {
|
||||
return 'Account';
|
||||
}
|
||||
},
|
||||
transferInAmountTitle() {
|
||||
const sourceAccount = this.allAccountsMap[this.transaction.sourceAccountId];
|
||||
const destinationAccount = this.allAccountsMap[this.transaction.destinationAccountId];
|
||||
|
||||
if (!sourceAccount || !destinationAccount || sourceAccount.currency === destinationAccount.currency) {
|
||||
return this.$t('Transfer In Amount');
|
||||
}
|
||||
|
||||
const fromExchangeRate = this.exchangeRatesStore.latestExchangeRateMap[sourceAccount.currency];
|
||||
const toExchangeRate = this.exchangeRatesStore.latestExchangeRateMap[destinationAccount.currency];
|
||||
const amountRate = getAdaptiveDisplayAmountRate(this.transaction.sourceAmount, this.transaction.destinationAmount, fromExchangeRate, toExchangeRate, this.settingsStore.appSettings.thousandsSeparator);
|
||||
|
||||
if (!amountRate) {
|
||||
return this.$t('Transfer In Amount');
|
||||
}
|
||||
|
||||
return this.$t('Transfer In Amount') + ` (${amountRate})`;
|
||||
},
|
||||
defaultCurrency() {
|
||||
return this.userStore.currentUserDefaultCurrency;
|
||||
},
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
class="transaction-edit-amount text-color-primary"
|
||||
link="#" no-chevron
|
||||
:class="destinationAmountClass"
|
||||
:header="$t('Transfer In Amount')"
|
||||
:header="transferInAmountTitle"
|
||||
:title="getDisplayAmount(transaction.destinationAmount, transaction.hideAmount)"
|
||||
@click="showDestinationAmountSheet = true"
|
||||
v-if="transaction.type === allTransactionTypes.Transfer"
|
||||
@@ -358,6 +358,9 @@ import {
|
||||
getUtcOffsetByUtcOffsetMinutes,
|
||||
getActualUnixTimeForStore
|
||||
} from '@/lib/datetime.js';
|
||||
import {
|
||||
getAdaptiveDisplayAmountRate
|
||||
} from '@/lib/currency.js';
|
||||
import {
|
||||
getTransactionPrimaryCategoryName,
|
||||
getTransactionSecondaryCategoryName,
|
||||
@@ -435,6 +438,24 @@ export default {
|
||||
return 'Account';
|
||||
}
|
||||
},
|
||||
transferInAmountTitle() {
|
||||
const sourceAccount = this.allAccountsMap[this.transaction.sourceAccountId];
|
||||
const destinationAccount = this.allAccountsMap[this.transaction.destinationAccountId];
|
||||
|
||||
if (!sourceAccount || !destinationAccount || sourceAccount.currency === destinationAccount.currency) {
|
||||
return this.$t('Transfer In Amount');
|
||||
}
|
||||
|
||||
const fromExchangeRate = this.exchangeRatesStore.latestExchangeRateMap[sourceAccount.currency];
|
||||
const toExchangeRate = this.exchangeRatesStore.latestExchangeRateMap[destinationAccount.currency];
|
||||
const amountRate = getAdaptiveDisplayAmountRate(this.transaction.sourceAmount, this.transaction.destinationAmount, fromExchangeRate, toExchangeRate, this.settingsStore.appSettings.thousandsSeparator);
|
||||
|
||||
if (!amountRate) {
|
||||
return this.$t('Transfer In Amount');
|
||||
}
|
||||
|
||||
return this.$t('Transfer In Amount') + ` (${amountRate})`;
|
||||
},
|
||||
defaultCurrency() {
|
||||
return this.userStore.currentUserDefaultCurrency;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user