display amounts according to currency decimals number count

This commit is contained in:
MaysWind
2024-12-06 23:55:19 +08:00
parent e2f2b325a6
commit e549779164
15 changed files with 313 additions and 23 deletions
+2 -1
View File
@@ -36,6 +36,7 @@
>
<number-pad-sheet :min-value="allowedMinAmount"
:max-value="allowedMaxAmount"
:currency="baseCurrency"
v-model:show="showBaseAmountSheet"
v-model="baseAmount"
></number-pad-sheet>
@@ -123,7 +124,7 @@ export default {
return this.$locale.getAllDisplayExchangeRates(this.settingsStore, this.exchangeRatesData);
},
displayBaseAmount() {
return this.$locale.formatAmount(this.userStore, this.baseAmount);
return this.$locale.formatAmount(this.userStore, this.baseAmount, this.baseCurrency);
},
baseAmountFontSizeClass() {
if (this.baseAmount >= 100000000 || this.baseAmount <= -100000000) {
+2
View File
@@ -183,6 +183,7 @@
>
<number-pad-sheet :min-value="allowedMinAmount"
:max-value="allowedMaxAmount"
:currency="account.currency"
v-model:show="account.showBalanceSheet"
v-model="account.balance"
></number-pad-sheet>
@@ -396,6 +397,7 @@
>
<number-pad-sheet :min-value="allowedMinAmount"
:max-value="allowedMaxAmount"
:currency="subAccount.currency"
v-model:show="subAccount.showBalanceSheet"
v-model="subAccount.balance"
></number-pad-sheet>
+28 -8
View File
@@ -65,11 +65,12 @@
link="#" no-chevron
:class="sourceAmountClass"
:header="$t(sourceAmountName)"
:title="getDisplayAmount(transaction.sourceAmount, transaction.hideAmount)"
:title="getDisplayAmount(transaction.sourceAmount, transaction.hideAmount, sourceAccountCurrency)"
@click="showSourceAmountSheet = true"
>
<number-pad-sheet :min-value="allowedMinAmount"
:max-value="allowedMaxAmount"
:currency="sourceAccountCurrency"
v-model:show="showSourceAmountSheet"
v-model="transaction.sourceAmount"
></number-pad-sheet>
@@ -80,12 +81,13 @@
link="#" no-chevron
:class="destinationAmountClass"
:header="transferInAmountTitle"
:title="getDisplayAmount(transaction.destinationAmount, transaction.hideAmount)"
:title="getDisplayAmount(transaction.destinationAmount, transaction.hideAmount, destinationAccountCurrency)"
@click="showDestinationAmountSheet = true"
v-if="transaction.type === allTransactionTypes.Transfer"
>
<number-pad-sheet :min-value="allowedMinAmount"
:max-value="allowedMaxAmount"
:currency="destinationAccountCurrency"
v-model:show="showDestinationAmountSheet"
v-model="transaction.destinationAmount"
></number-pad-sheet>
@@ -672,6 +674,24 @@ export default {
return this.$t('None');
}
},
sourceAccountCurrency() {
const sourceAccount = this.allAccountsMap[this.transaction.sourceAccountId];
if (sourceAccount) {
return sourceAccount.currency;
}
return this.defaultCurrency;
},
destinationAccountCurrency() {
const destinationAccount = this.allAccountsMap[this.transaction.destinationAccountId];
if (destinationAccount) {
return destinationAccount.currency;
}
return this.defaultCurrency;
},
transactionDisplayDate() {
if (this.mode !== 'view' || !this.showTimeInDefaultTimezone) {
return this.$locale.formatUnixTimeToLongDate(this.userStore, getActualUnixTimeForStore(this.transaction.time, getTimezoneOffsetMinutes(), getBrowserTimezoneOffsetMinutes()));
@@ -862,7 +882,7 @@ export default {
return;
}
this.transactionsStore.setTransactionSuitableDestinationAmount(this.transaction, oldValue, newValue);
this.transactionsStore.setTransactionSuitableDestinationAmount(this.transaction, oldValue, newValue, this.destinationAccountCurrency);
},
'transaction.destinationAmount': function (newValue) {
if (this.mode === 'view' || this.loading) {
@@ -1333,15 +1353,15 @@ export default {
return 'ebk-large-amount';
}
},
getDisplayAmount(amount, hideAmount) {
getDisplayAmount(amount, hideAmount, currencyCode) {
if (hideAmount) {
return this.getDisplayCurrency('***');
return this.getDisplayCurrency('***', currencyCode);
}
return this.getDisplayCurrency(amount);
return this.getDisplayCurrency(amount, currencyCode);
},
getDisplayCurrency(value) {
return this.$locale.formatAmountWithCurrency(this.settingsStore, this.userStore, value, false);
getDisplayCurrency(value, currencyCode) {
return this.$locale.formatAmountWithCurrency(this.settingsStore, this.userStore, value, currencyCode);
},
getPrimaryCategoryName(categoryId, allCategories) {
return getTransactionPrimaryCategoryName(categoryId, allCategories);