From ee0f5f7e90d7a34cdf1b98611cf1b747200b041b Mon Sep 17 00:00:00 2001 From: MaysWind Date: Tue, 22 Dec 2020 01:20:43 +0800 Subject: [PATCH] show account balance in account selection sheet in transaction edit page --- src/views/mobile/transactions/Edit.vue | 75 +++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/src/views/mobile/transactions/Edit.vue b/src/views/mobile/transactions/Edit.vue index 32a26187..20499b64 100644 --- a/src/views/mobile/transactions/Edit.vue +++ b/src/views/mobile/transactions/Edit.vue @@ -149,10 +149,13 @@ :title="transaction.sourceAccountId | accountName(allAccounts)" @click="showSourceAccountSheet = true" > - - account.category === accountCategory.category); + let totalBalance = 0; + let hasUnCalculatedAmount = false; + + for (let i = 0; i < accountsBalance.length; i++) { + if (accountsBalance[i].currency === this.defaultCurrency) { + totalBalance += accountsBalance[i].balance; + } else { + const balance = this.$exchangeRates.getOtherCurrencyAmount(accountsBalance[i].balance, accountsBalance[i].currency, this.defaultCurrency); + + if (!this.$utilities.isNumber(balance)) { + hasUnCalculatedAmount = true; + continue; + } + + totalBalance += Math.floor(balance); + } + } + + if (hasUnCalculatedAmount) { + totalBalance = totalBalance + '+'; + } + + accountCategory.displayBalance = this.$options.filters.currency(totalBalance, this.defaultCurrency); + } else { + accountCategory.displayBalance = '***'; + } + } + }, getFontSizeByAmount(amount) { if (amount >= 100000000 || amount <= -100000000) { return 32;