更新个人需求清单,新增信用额度和可用额度的标注;在账户列表和交易列表中显示可用额度;修改记账页面的时间选择为默认日期选择器;优化账户余额显示逻辑

This commit is contained in:
2026-04-06 01:16:38 +08:00
parent ba85852543
commit 4ff73b475a
6 changed files with 93 additions and 59 deletions
+10 -1
View File
@@ -276,6 +276,10 @@
</v-btn>
<v-spacer/>
<span class="account-balance ms-2">{{ accountBalance(element, activeSubAccount[element.id]) }}</span>
<small class="text-medium-emphasis ms-2"
v-if="!activeSubAccount[element.id] && element.creditLimit">
{{ tt('Available') }}: {{ getRemainingCredit(element) }}
</small>
</div>
</v-card-text>
</v-card>
@@ -365,7 +369,7 @@ type ClearAllTransactionsDialogType = InstanceType<typeof ClearAllTransactionsDi
const display = useDisplay();
const { tt, getAllDateRanges, getCurrencyName, joinMultiText } = useI18n();
const { tt, getAllDateRanges, getCurrencyName, joinMultiText, formatAmountToLocalizedNumeralsWithCurrency } = useI18n();
const {
loading,
@@ -473,6 +477,11 @@ function hasAccount(accountCategory: AccountCategory): boolean {
return accountsStore.hasAccount(accountCategory, !showHidden.value);
}
function getRemainingCredit(account: Account): string {
const available = (account.creditLimit ?? 0) + account.balance;
return formatAmountToLocalizedNumeralsWithCurrency(available, account.currency);
}
function accountCurrency(account: Account): string | null {
if (account.type === AccountType.SingleAccount.type) {
return getCurrencyName(account.currency);
@@ -698,6 +698,7 @@ import { type NumeralSystem, AmountFilterType } from '@/core/numeral.ts';
import { ThemeType } from '@/core/theme.ts';
import { TransactionType } from '@/core/transaction.ts';
import { TemplateType } from '@/core/template.ts';
import { AccountType } from '@/core/account.ts';
import type { TransactionCategory } from '@/models/transaction_category.ts';
import { type Transaction, TransactionTagFilter } from '@/models/transaction.ts';
import type { TransactionTemplate } from '@/models/transaction_template.ts';
@@ -894,6 +895,11 @@ const filteredSingleAccount = computed(() => {
const filteredAccountBalanceText = computed<string>(() => {
const account = filteredSingleAccount.value;
if (!account) return '';
if (account.type === AccountType.MultiSubAccounts.type) {
const result = accountsStore.getAccountSubAccountBalance(true, true, account);
if (!result) return '';
return formatAmountToLocalizedNumeralsWithCurrency(result.balance, result.currency);
}
if (account.creditLimit) {
const outstanding = -account.balance;
const available = account.creditLimit + account.balance;