support adding / deleting sub account after account created (#77)

This commit is contained in:
MaysWind
2025-04-26 23:36:23 +08:00
parent e7e2cc8081
commit 78ba43480b
20 changed files with 520 additions and 76 deletions
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "Übergeordnetes Konto kann keinen Saldo festlegen",
"sub-account category not equals to parent": "Teilkonto-Kategorie entspricht nicht der übergeordneten Kategorie",
"sub-account type invalid": "Teilkontotyp ist ungültig",
"cannot add or delete sub-accounts when modify account": "Unterkonten können beim Ändern des Kontos nicht hinzugefügt oder gelöscht werden",
"source account not found": "Quellkonto nicht gefunden",
"destination account not found": "Zielkonto nicht gefunden",
"account is in use and cannot be deleted": "Konto wird verwendet und kann nicht gelöscht werden",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "Abrechnungsdatum kann für Teilkonto nicht festgelegt werden",
"sub-account not found": "Sub-account is not found",
"sub-account is in use and cannot be deleted": "Sub-account is in use and it cannot be deleted",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "Transaktions-ID ist ungültig",
"transaction not found": "Transaktion nicht gefunden",
"transaction type is invalid": "Transaktionstyp ist ungültig",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "Parent account cannot set balance",
"sub-account category not equals to parent": "Sub-account category does not equal to parent",
"sub-account type invalid": "Sub-account type is invalid",
"cannot add or delete sub-accounts when modify account": "You cannot add or delete sub-accounts when modify account",
"source account not found": "Source account is not found",
"destination account not found": "Destination account is not found",
"account is in use and cannot be deleted": "Account is in use and it cannot be deleted",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "Cannot set statement date for sub-account",
"sub-account not found": "Sub-account is not found",
"sub-account is in use and cannot be deleted": "Sub-account is in use and it cannot be deleted",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "Transaction ID is invalid",
"transaction not found": "Transaction is not found",
"transaction type is invalid": "Transaction type is invalid",
+3 -1
View File
@@ -1062,7 +1062,6 @@
"parent account cannot set balance": "La cuenta principal no puede establecer el saldo",
"sub-account category not equals to parent": "La categoría de subcuenta no es igual a la principal",
"sub-account type invalid": "El tipo de subcuenta no es válido",
"cannot add or delete sub-accounts when modify account": "No puede agregar ni eliminar subcuentas cuando modifica la cuenta",
"source account not found": "No se encuentra la cuenta de origen",
"destination account not found": "No se encuentra la cuenta de destino",
"account is in use and cannot be deleted": "La cuenta está en uso y no se puede eliminar",
@@ -1072,6 +1071,9 @@
"cannot set statement date for sub account": "No se puede establecer la fecha del estado de cuenta para la subcuenta",
"sub-account not found": "Sub-account is not found",
"sub-account is in use and cannot be deleted": "Sub-account is in use and it cannot be deleted",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "El ID de transacción no es válido",
"transaction not found": "La transacción no se encuentra",
"transaction type is invalid": "El tipo de transacción no es válido",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "Il conto principale non può impostare il saldo",
"sub-account category not equals to parent": "La categoria del sotto-conto non corrisponde a quella principale",
"sub-account type invalid": "Tipo di sotto-conto non valido",
"cannot add or delete sub-accounts when modify account": "Non è possibile aggiungere o eliminare sotto-conti durante la modifica del conto",
"source account not found": "Conto di origine non trovato",
"destination account not found": "Conto di destinazione non trovato",
"account is in use and cannot be deleted": "Il conto è in uso e non può essere eliminato",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "Impossibile impostare la data dell'estratto conto per un sotto-conto",
"sub-account not found": "Sotto-conto non trovato",
"sub-account is in use and cannot be deleted": "Il sotto-conto è in uso e non può essere eliminato",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "ID transazione non valido",
"transaction not found": "Transazione non trovata",
"transaction type is invalid": "Tipo di transazione non valido",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "親口座は残高を設定できません",
"sub-account category not equals to parent": "子口座のカテゴリが親と一致しません",
"sub-account type invalid": "子口座タイプは無効です",
"cannot add or delete sub-accounts when modify account": "口座を変更するときに子口座を追加または削除できません",
"source account not found": "元口座が見つかりません",
"destination account not found": "宛先口座が見つかりません",
"account is in use and cannot be deleted": "支払い方法は使用されており削除できません",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "子口座の明細日を設定できません",
"sub-account not found": "Sub-account is not found",
"sub-account is in use and cannot be deleted": "Sub-account is in use and it cannot be deleted",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "取引IDは無効です",
"transaction not found": "取引が見つかりません",
"transaction type is invalid": "取引タイプは無効です",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "Родительский счет не может устанавливать баланс",
"sub-account category not equals to parent": "Категория субсчета не совпадает с родительской",
"sub-account type invalid": "Тип субсчета недействителен",
"cannot add or delete sub-accounts when modify account": "Нельзя добавлять или удалять субсчета при изменении счета",
"source account not found": "Исходный счет не найден",
"destination account not found": "Счет назначения не найден",
"account is in use and cannot be deleted": "Счет используется и не может быть удален",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "Нельзя установить дату выписки для субсчета",
"sub-account not found": "Sub-account is not found",
"sub-account is in use and cannot be deleted": "Sub-account is in use and it cannot be deleted",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "ID транзакции недействителен",
"transaction not found": "Транзакция не найдена",
"transaction type is invalid": "Тип транзакции недействителен",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "Батьківський рахунок не може встановити баланс",
"sub-account category not equals to parent": "Категорія субрахунку не збігається з батьківською",
"sub-account type invalid": "Тип субрахунку недійсний",
"cannot add or delete sub-accounts when modify account": "Неможливо додати або видалити субрахунки при зміні рахунку",
"source account not found": "Вихідний рахунок не знайдено",
"destination account not found": "Рахунок призначення не знайдено",
"account is in use and cannot be deleted": "Рахунок використовується і не може бути видалений",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "Неможливо встановити дату виписки для субрахунку",
"sub-account not found": "Субрахунок не знайдено",
"sub-account is in use and cannot be deleted": "Субрахунок використовується і не може бути видалений",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "ID транзакції недійсний",
"transaction not found": "Транзакцію не знайдено",
"transaction type is invalid": "Тип транзакції недійсний",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "Tài khoản cha không thể đặt số dư",
"sub-account category not equals to parent": "Danh mục tài khoản phụ không bằng tài khoản cha",
"sub-account type invalid": "Loại tài khoản phụ không hợp lệ",
"cannot add or delete sub-accounts when modify account": "Bạn không thể thêm hoặc xóa tài khoản phụ khi sửa đổi tài khoản",
"source account not found": "Không tìm thấy tài khoản nguồn",
"destination account not found": "Không tìm thấy tài khoản đích",
"account is in use and cannot be deleted": "Tài khoản đang được sử dụng và không thể xóa",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "Cannot set statement date for sub-account",
"sub-account not found": "Sub-account is not found",
"sub-account is in use and cannot be deleted": "Sub-account is in use and it cannot be deleted",
"not supported to modify account currency": "Not supported to modify account currency",
"not supported to modify account balance": "Not supported to modify account balance",
"not supported to modify account balance time": "Not supported to modify account balance time",
"transaction id is invalid": "ID giao dịch không hợp lệ",
"transaction not found": "Không tìm thấy giao dịch",
"transaction type is invalid": "Loại giao dịch không hợp lệ",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "父账户不能设置余额",
"sub-account category not equals to parent": "子账户类别与父账户不同",
"sub-account type invalid": "子账户类型无效",
"cannot add or delete sub-accounts when modify account": "您不能在修改账户时添加或删除子账户",
"source account not found": "来源账户不存在",
"destination account not found": "目标账户不存在",
"account is in use and cannot be deleted": "账户正在被使用,无法删除",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "子账户不能设置账单日期",
"sub-account not found": "子账户不存在",
"sub-account is in use and cannot be deleted": "子账户正在被使用,无法删除",
"not supported to modify account currency": "不支持修改账户货币",
"not supported to modify account balance": "不支持修改账户余额",
"not supported to modify account balance time": "不支持修改账户余额时间",
"transaction id is invalid": "交易ID无效",
"transaction not found": "交易不存在",
"transaction type is invalid": "交易类型无效",
+3 -1
View File
@@ -1063,7 +1063,6 @@
"parent account cannot set balance": "父帳戶不能設定餘額",
"sub-account category not equals to parent": "子帳戶類別與父帳戶不同",
"sub-account type invalid": "子帳戶類型無效",
"cannot add or delete sub-accounts when modify account": "您不能在修改帳戶時新增或刪除子帳戶",
"source account not found": "來源帳戶不存在",
"destination account not found": "目標帳戶不存在",
"account is in use and cannot be deleted": "帳戶正在被使用,無法刪除",
@@ -1073,6 +1072,9 @@
"cannot set statement date for sub account": "子帳戶不能設定帳單日期",
"sub-account not found": "子帳戶不存在",
"sub-account is in use and cannot be deleted": "子帳戶正在被使用,無法刪除",
"not supported to modify account currency": "不支援修改帳戶貨幣",
"not supported to modify account balance": "不支援修改帳戶餘額",
"not supported to modify account balance time": "不支援修改帳戶餘額時間",
"transaction id is invalid": "交易ID無效",
"transaction not found": "交易不存在",
"transaction type is invalid": "交易類型無效",
+11 -3
View File
@@ -186,7 +186,7 @@ export class Account implements AccountInfoResponse {
};
}
public toModifyRequest(subAccounts?: Account[], parentAccount?: Account): AccountModifyRequest {
public toModifyRequest(clientSessionId: string, subAccounts?: Account[], parentAccount?: Account): AccountModifyRequest {
let subAccountModifyRequests: AccountModifyRequest[] | undefined = undefined;
if (this.type === AccountType.MultiSubAccounts.type) {
@@ -198,21 +198,25 @@ export class Account implements AccountInfoResponse {
if (subAccounts) {
for (const subAccount of subAccounts) {
subAccountModifyRequests.push(subAccount.toModifyRequest(undefined, this));
subAccountModifyRequests.push(subAccount.toModifyRequest(clientSessionId, undefined, this));
}
}
}
return {
id: this.id,
id: this.id || '0',
name: this.name,
category: parentAccount ? parentAccount.category : this.category,
icon: this.icon,
color: this.color,
currency: parentAccount && (!this.id || this.id === '0') ? this.currency : undefined,
balance: parentAccount && (!this.id || this.id === '0') ? this.balance : undefined,
balanceTime: parentAccount && (!this.id || this.id === '0') ? this.balanceTime : undefined,
comment: this.comment,
creditCardStatementDate: !parentAccount && this.category === AccountCategory.CreditCard.type ? this.creditCardStatementDate : undefined,
hidden: !this.visible,
subAccounts: !parentAccount ? subAccountModifyRequests : undefined,
clientSessionId: !parentAccount ? clientSessionId : undefined
};
}
@@ -579,10 +583,14 @@ export interface AccountModifyRequest {
readonly category: number;
readonly icon: string;
readonly color: string;
readonly currency?: string;
readonly balance?: number;
readonly balanceTime?: number;
readonly comment: string;
readonly creditCardStatementDate?: number;
readonly hidden: boolean;
readonly subAccounts?: AccountModifyRequest[];
readonly clientSessionId?: string;
}
export interface AccountInfoResponse {
+22 -13
View File
@@ -185,29 +185,38 @@ export const useAccountsStore = defineStore('accounts', () => {
}
}
function updateAccountToAccountList(account: Account): void {
function updateAccountToAccountList(oldAccount: Account, newAccount: Account): void {
for (let i = 0; i < allAccounts.value.length; i++) {
if (allAccounts.value[i].id === account.id) {
allAccounts.value.splice(i, 1, account);
if (allAccounts.value[i].id === newAccount.id) {
allAccounts.value.splice(i, 1, newAccount);
break;
}
}
allAccountsMap.value[account.id] = account;
if (oldAccount.subAccounts) {
for (let i = 0; i < oldAccount.subAccounts.length; i++) {
const subAccount = oldAccount.subAccounts[i];
if (allAccountsMap.value[subAccount.id]) {
delete allAccountsMap.value[subAccount.id];
}
}
}
if (account.subAccounts) {
for (let i = 0; i < account.subAccounts.length; i++) {
const subAccount = account.subAccounts[i];
allAccountsMap.value[newAccount.id] = newAccount;
if (newAccount.subAccounts) {
for (let i = 0; i < newAccount.subAccounts.length; i++) {
const subAccount = newAccount.subAccounts[i];
allAccountsMap.value[subAccount.id] = subAccount;
}
}
if (allCategorizedAccountsMap.value[account.category]) {
const accountList = allCategorizedAccountsMap.value[account.category].accounts;
if (allCategorizedAccountsMap.value[newAccount.category]) {
const accountList = allCategorizedAccountsMap.value[newAccount.category].accounts;
for (let i = 0; i < accountList.length; i++) {
if (accountList[i].id === account.id) {
accountList.splice(i, 1, account);
if (accountList[i].id === newAccount.id) {
accountList.splice(i, 1, newAccount);
break;
}
}
@@ -847,7 +856,7 @@ export const useAccountsStore = defineStore('accounts', () => {
if (!isEdit) {
promise = services.addAccount(account.toCreateRequest(clientSessionId, subAccounts));
} else {
promise = services.modifyAccount(account.toModifyRequest(subAccounts));
promise = services.modifyAccount(account.toModifyRequest(clientSessionId, subAccounts));
}
promise.then(response => {
@@ -868,7 +877,7 @@ export const useAccountsStore = defineStore('accounts', () => {
addAccountToAccountList(newAccount);
} else {
if (oldAccount && oldAccount.category === newAccount.category) {
updateAccountToAccountList(newAccount);
updateAccountToAccountList(oldAccount, newAccount);
} else {
updateAccountListInvalidState(true);
}
@@ -91,6 +91,10 @@ export function useAccountEditPageBaseBase() {
}
}
function isNewAccount(account: Account): boolean {
return account.id === '' || account.id === '0';
}
function isInputEmpty(): boolean {
const isAccountEmpty = !!getInputEmptyProblemMessage(account.value, false);
@@ -172,6 +176,7 @@ export function useAccountEditPageBaseBase() {
isAccountSupportCreditCardStatementDate,
// functions
getAccountCreditCardStatementDate,
isNewAccount,
isInputEmpty,
getAccountOrSubAccountProblemMessage,
addSubAccount,
@@ -8,7 +8,7 @@
<v-progress-circular indeterminate size="22" class="ml-2" v-if="loading"></v-progress-circular>
</div>
<v-btn density="comfortable" color="default" variant="text" class="ml-2" :icon="true"
:disabled="loading || submitting || !!editAccountId || account.type !== AccountType.MultiSubAccounts.type">
:disabled="loading || submitting || account.type !== AccountType.MultiSubAccounts.type">
<v-icon :icon="mdiDotsVertical" />
<v-menu activator="parent">
<v-list>
@@ -30,7 +30,7 @@
<v-tab :key="idx" :value="idx" v-for="(subAccount, idx) in subAccounts">
<span>{{ tt('Sub Account') + ' #' + (idx + 1) }}</span>
<v-btn class="ml-2" color="error" size="24" variant="text"
:icon="mdiDeleteOutline" v-if="!editAccountId"
:icon="mdiDeleteOutline"
@click="removeSubAccount(subAccount)"></v-btn>
</v-tab>
</template>
@@ -109,7 +109,7 @@
v-model="selectedAccount.color" />
</v-col>
<v-col cols="12" :md="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate ? 6 : 12" v-if="account.type === AccountType.SingleAccount.type || currentAccountIndex >= 0">
<currency-select :disabled="loading || submitting || !!editAccountId"
<currency-select :disabled="loading || submitting || (!!editAccountId && !isNewAccount(selectedAccount))"
:label="tt('Currency')"
:placeholder="tt('Currency')"
v-model="selectedAccount.currency" />
@@ -128,9 +128,9 @@
v-model="account.creditCardStatementDate"
></v-autocomplete>
</v-col>
<v-col cols="12" :md="!editAccountId && selectedAccount.balance ? 6 : 12"
<v-col cols="12" :md="(!editAccountId || isNewAccount(selectedAccount)) && selectedAccount.balance ? 6 : 12"
v-if="account.type === AccountType.SingleAccount.type || currentAccountIndex >= 0">
<amount-input :disabled="loading || submitting || !!editAccountId"
<amount-input :disabled="loading || submitting || (!!editAccountId && !isNewAccount(selectedAccount))"
:persistent-placeholder="true"
:currency="selectedAccount.currency"
:show-currency="true"
@@ -140,7 +140,7 @@
v-model="selectedAccount.balance"/>
</v-col>
<v-col cols="12" md="6" v-show="selectedAccount.balance"
v-if="!editAccountId && (account.type === AccountType.SingleAccount.type || currentAccountIndex >= 0)">
v-if="(!editAccountId || isNewAccount(selectedAccount)) && (account.type === AccountType.SingleAccount.type || currentAccountIndex >= 0)">
<date-time-select
:disabled="loading || submitting"
:label="tt('Balance Time')"
@@ -158,7 +158,7 @@
v-model="selectedAccount.comment"
/>
</v-col>
<v-col class="py-0" cols="12" md="12" v-if="editAccountId">
<v-col class="py-0" cols="12" md="12" v-if="editAccountId && !isNewAccount(selectedAccount)">
<v-switch :disabled="loading || submitting"
:label="tt('Visible')" v-model="selectedAccount.visible"/>
</v-col>
@@ -236,6 +236,7 @@ const {
allAccountTypes,
allAvailableMonthDays,
isAccountSupportCreditCardStatementDate,
isNewAccount,
isInputEmpty,
getAccountOrSubAccountProblemMessage,
addSubAccount,
@@ -288,6 +289,7 @@ function open(options?: { id?: string, currentAccount?: Account, category?: numb
account.value.fillFrom(newAccount);
subAccounts.value = [];
currentAccountIndex.value = -1;
clientSessionId.value = generateRandomUUID();
if (options && options.id) {
if (options.currentAccount) {
@@ -317,7 +319,6 @@ function open(options?: { id?: string, currentAccount?: Account, category?: numb
}
editAccountId.value = null;
clientSessionId.value = generateRandomUUID();
loading.value = false;
}
+8 -8
View File
@@ -4,7 +4,7 @@
<f7-nav-left :back-link="tt('Back')"></f7-nav-left>
<f7-nav-title :title="tt(title)"></f7-nav-title>
<f7-nav-right>
<f7-link icon-f7="ellipsis" :class="{ 'disabled': editAccountId || account.type !== AccountType.MultiSubAccounts.type }" @click="showMoreActionSheet = true"></f7-link>
<f7-link icon-f7="ellipsis" :class="{ 'disabled': account.type !== AccountType.MultiSubAccounts.type }" @click="showMoreActionSheet = true"></f7-link>
<f7-link :class="{ 'disabled': isInputEmpty() || submitting }" :text="tt(saveButtonTitle)" @click="save"></f7-link>
</f7-nav-right>
</f7-navbar>
@@ -354,7 +354,6 @@
<small>{{ tt('Sub Account') + ' #' + (idx + 1) }}</small>
<f7-button rasied fill class="subaccount-delete-button" color="red" icon-f7="trash" icon-size="16px"
:tooltip="tt('Remove Sub-account')"
v-if="!editAccountId"
@click="removeSubAccount(subAccount, false)">
</f7-button>
</f7-list-item>
@@ -420,9 +419,9 @@
<f7-list-item
class="list-item-with-header-and-title list-item-no-item-after"
link="#"
:class="{ 'disabled': editAccountId }"
:class="{ 'disabled': editAccountId && !isNewAccount(subAccount) }"
:header="tt('Currency')"
:no-chevron="!!editAccountId"
:no-chevron="!!editAccountId && !isNewAccount(subAccount)"
@click="subAccountContexts[idx].showCurrencyPopup = true"
>
<template #title>
@@ -447,7 +446,7 @@
<f7-list-item
link="#" no-chevron
class="list-item-with-header-and-title"
:class="{ 'disabled': editAccountId }"
:class="{ 'disabled': editAccountId && !isNewAccount(subAccount) }"
:header="account.isLiability ? tt('Sub-account Outstanding Balance') : tt('Sub-account Balance')"
:title="formatAccountDisplayBalance(subAccount)"
@click="subAccountContexts[idx].showBalanceSheet = true"
@@ -465,7 +464,7 @@
class="account-edit-balancetime list-item-with-header-and-title"
link="#" no-chevron
v-show="subAccount.balance"
v-if="!editAccountId"
v-if="!editAccountId || isNewAccount(subAccount)"
>
<template #header>
<div class="account-edit-balancetime-header" @click="showDateTimeDialog(subAccountContexts[idx], 'time')">{{ tt('Sub-account Balance Time') }}</div>
@@ -481,7 +480,7 @@
</date-time-selection-sheet>
</f7-list-item>
<f7-list-item :title="tt('Visible')" v-if="editAccountId">
<f7-list-item :title="tt('Visible')" v-if="editAccountId && !isNewAccount(subAccount)">
<f7-toggle :checked="subAccount.visible" @toggle:change="subAccount.visible = $event"></f7-toggle>
</f7-list-item>
@@ -573,6 +572,7 @@ const {
allAvailableMonthDays,
isAccountSupportCreditCardStatementDate,
getAccountCreditCardStatementDate,
isNewAccount,
isInputEmpty,
getAccountOrSubAccountProblemMessage,
addSubAccount,
@@ -625,6 +625,7 @@ function formatAccountBalanceTime(account: Account): string {
function init(): void {
const query = props.f7route.query;
clientSessionId.value = generateRandomUUID();
if (query['id']) {
loading.value = true;
@@ -651,7 +652,6 @@ function init(): void {
}
});
} else {
clientSessionId.value = generateRandomUUID();
loading.value = false;
}
}