添加信用额度功能:在账户模型中新增信用额度字段,更新相关请求和响应结构,修改账户创建和修改逻辑,更新界面以支持信用额度的显示和编辑。
This commit is contained in:
@@ -201,6 +201,24 @@
|
||||
</list-item-selection-popup>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
link="#" no-chevron
|
||||
class="list-item-with-header-and-title"
|
||||
:header="tt('Credit Limit')"
|
||||
:title="formatCreditLimitDisplay(account)"
|
||||
v-if="isAccountSupportCreditCardStatementDate"
|
||||
@click="accountContext.showCreditLimitSheet = true"
|
||||
>
|
||||
<number-pad-sheet :min-value="0"
|
||||
:max-value="TRANSACTION_MAX_AMOUNT"
|
||||
:currency="account.currency"
|
||||
:flip-negative="false"
|
||||
v-model:show="accountContext.showCreditLimitSheet"
|
||||
:model-value="account.creditLimit ?? 0"
|
||||
@update:model-value="account.creditLimit = $event > 0 ? $event : undefined"
|
||||
></number-pad-sheet>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
link="#" no-chevron
|
||||
class="list-item-with-header-and-title"
|
||||
@@ -334,6 +352,24 @@
|
||||
</list-item-selection-popup>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
link="#" no-chevron
|
||||
class="list-item-with-header-and-title"
|
||||
:header="tt('Credit Limit')"
|
||||
:title="formatCreditLimitDisplay(account)"
|
||||
v-if="isAccountSupportCreditCardStatementDate"
|
||||
@click="accountContext.showCreditLimitSheet = true"
|
||||
>
|
||||
<number-pad-sheet :min-value="0"
|
||||
:max-value="TRANSACTION_MAX_AMOUNT"
|
||||
:currency="account.currency"
|
||||
:flip-negative="false"
|
||||
v-model:show="accountContext.showCreditLimitSheet"
|
||||
:model-value="account.creditLimit ?? 0"
|
||||
@update:model-value="account.creditLimit = $event > 0 ? $event : undefined"
|
||||
></number-pad-sheet>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item :title="tt('Visible')" v-if="editAccountId">
|
||||
<f7-toggle :checked="account.visible" @toggle:change="account.visible = $event"></f7-toggle>
|
||||
</f7-list-item>
|
||||
@@ -550,6 +586,7 @@ interface AccountContext {
|
||||
showColorSelectionSheet: boolean;
|
||||
showCurrencyPopup: boolean;
|
||||
showCreditCardStatementDatePopup: boolean;
|
||||
showCreditLimitSheet: boolean;
|
||||
showBalanceSheet: boolean;
|
||||
showBalanceDateTimeSheet: boolean;
|
||||
balanceDateTimeSheetMode: string;
|
||||
@@ -600,6 +637,7 @@ const DEFAULT_ACCOUNT_CONTEXT: AccountContext = {
|
||||
showColorSelectionSheet: false,
|
||||
showCurrencyPopup: false,
|
||||
showCreditCardStatementDatePopup: false,
|
||||
showCreditLimitSheet: false,
|
||||
showBalanceSheet: false,
|
||||
showBalanceDateTimeSheet: false,
|
||||
balanceDateTimeSheetMode: 'time'
|
||||
@@ -621,6 +659,13 @@ function formatAccountDisplayBalance(selectedAccount: Account): string {
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(balance, selectedAccount.currency);
|
||||
}
|
||||
|
||||
function formatCreditLimitDisplay(selectedAccount: Account): string {
|
||||
if (!selectedAccount.creditLimit) {
|
||||
return tt('Not set');
|
||||
}
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(selectedAccount.creditLimit, selectedAccount.currency);
|
||||
}
|
||||
|
||||
function formatAccountBalanceDate(account: Account): string {
|
||||
if (!isDefined(account.balanceTime)) {
|
||||
return '';
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<div class="nested-list-item-title">
|
||||
<span>{{ account.name }}</span>
|
||||
<div class="item-footer" v-if="account.comment">{{ account.comment }}</div>
|
||||
<div class="item-footer" v-if="account.creditLimit">{{ tt('Available') }}: {{ getRemainingCredit(account) }}</div>
|
||||
</div>
|
||||
<div class="nested-list-item-after" v-if="account.type === AccountType.MultiSubAccounts.type">
|
||||
<span>{{ accountBalance(account) }}</span>
|
||||
@@ -241,7 +242,7 @@ const props = defineProps<{
|
||||
f7router: Router.Router;
|
||||
}>();
|
||||
|
||||
const { tt, getCurrentLanguageTextDirection } = useI18n();
|
||||
const { tt, getCurrentLanguageTextDirection, formatAmountToLocalizedNumeralsWithCurrency } = useI18n();
|
||||
const { showAlert, showToast, routeBackOnError } = useI18nUIComponents();
|
||||
|
||||
const {
|
||||
@@ -288,6 +289,14 @@ const noAvailableAccount = computed<boolean>(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function getRemainingCredit(account: Account): string {
|
||||
if (!account.creditLimit) {
|
||||
return '';
|
||||
}
|
||||
const remaining = account.creditLimit + account.balance; // balance is negative for credit cards
|
||||
return formatAmountToLocalizedNumeralsWithCurrency(remaining, account.currency);
|
||||
}
|
||||
|
||||
function hasAccount(accountCategory: AccountCategory, visibleOnly: boolean): boolean {
|
||||
return accountsStore.hasAccount(accountCategory, visibleOnly);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user