diff --git a/cmd/webserver.go b/cmd/webserver.go
index 73c889a1..3b71c298 100644
--- a/cmd/webserver.go
+++ b/cmd/webserver.go
@@ -325,6 +325,7 @@ func startWebServer(c *core.CliContext) error {
apiV1Route.GET("/data/statistics.json", bindApi(api.DataManagements.DataStatisticsHandler))
apiV1Route.POST("/data/clear/all.json", bindApi(api.DataManagements.ClearAllDataHandler))
apiV1Route.POST("/data/clear/transactions.json", bindApi(api.DataManagements.ClearAllTransactionsHandler))
+ apiV1Route.POST("/data/clear/transactions/by_account.json", bindApi(api.DataManagements.ClearAllTransactionsByAccountHandler))
if config.EnableDataExport {
apiV1Route.GET("/data/export.csv", bindCsv(api.DataManagements.ExportDataToEzbookkeepingCSVHandler))
diff --git a/pkg/api/data_managements.go b/pkg/api/data_managements.go
index e14aca94..37ef87da 100644
--- a/pkg/api/data_managements.go
+++ b/pkg/api/data_managements.go
@@ -15,6 +15,7 @@ import (
"github.com/mayswind/ezbookkeeping/pkg/utils"
)
+const pageCountForClearTransactions = 1000
const pageCountForDataExport = 1000
// DataManagementsApi represents data management api
@@ -232,6 +233,61 @@ func (a *DataManagementsApi) ClearAllTransactionsHandler(c *core.WebContext) (an
return true, nil
}
+// ClearAllTransactionsByAccountHandler deletes all transactions of specified account
+func (a *DataManagementsApi) ClearAllTransactionsByAccountHandler(c *core.WebContext) (any, *errs.Error) {
+ var clearDataReq models.ClearAccountTransactionsRequest
+ err := c.ShouldBindJSON(&clearDataReq)
+
+ if err != nil {
+ log.Warnf(c, "[data_managements.ClearAllTransactionsByAccountHandler] parse request failed, because %s", err.Error())
+ return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
+ }
+
+ uid := c.GetCurrentUid()
+ user, err := a.users.GetUserById(c, uid)
+
+ if err != nil {
+ if !errs.IsCustomError(err) {
+ log.Warnf(c, "[data_managements.ClearAllTransactionsByAccountHandler] failed to get user for user \"uid:%d\", because %s", uid, err.Error())
+ }
+
+ return nil, errs.ErrUserNotFound
+ }
+
+ if !a.users.IsPasswordEqualsUserPassword(clearDataReq.Password, user) {
+ return nil, errs.ErrUserPasswordWrong
+ }
+
+ if user.FeatureRestriction.Contains(core.USER_FEATURE_RESTRICTION_TYPE_CLEAR_ALL_DATA) {
+ return nil, errs.ErrNotPermittedToPerformThisAction
+ }
+
+ account, err := a.accounts.GetAccountByAccountId(c, uid, clearDataReq.AccountId)
+
+ if err != nil {
+ log.Errorf(c, "[data_managements.ClearAllTransactionsByAccountHandler] failed to get account \"id:%d\" for user \"uid:%d\", because %s", uid, clearDataReq.AccountId, err.Error())
+ return nil, errs.Or(err, errs.ErrOperationFailed)
+ }
+
+ if account.Hidden {
+ return nil, errs.ErrCannotDeleteTransactionInHiddenAccount
+ }
+
+ if account.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS {
+ return nil, errs.ErrCannotDeleteTransactionInParentAccount
+ }
+
+ err = a.transactions.DeleteAllTransactionsOfAccount(c, uid, account.AccountId, pageCountForClearTransactions)
+
+ if err != nil {
+ log.Errorf(c, "[data_managements.ClearAllTransactionsByAccountHandler] failed to delete all transactions in account \"id:%d\", because %s", account.AccountId, err.Error())
+ return nil, errs.Or(err, errs.ErrOperationFailed)
+ }
+
+ log.Infof(c, "[data_managements.ClearAllTransactionsByAccountHandler] user \"uid:%d\" has cleared all transactions in account \"id:%d\"", uid, account.AccountId)
+ return true, nil
+}
+
func (a *DataManagementsApi) getExportedFileContent(c *core.WebContext, fileType string) ([]byte, string, *errs.Error) {
if !a.CurrentConfig().EnableDataExport {
return nil, "", errs.ErrDataExportNotAllowed
diff --git a/pkg/models/data_management.go b/pkg/models/data_management.go
index 8bd1be2a..f55ddb5f 100644
--- a/pkg/models/data_management.go
+++ b/pkg/models/data_management.go
@@ -5,6 +5,12 @@ type ClearDataRequest struct {
Password string `json:"password" binding:"omitempty,min=6,max=128"`
}
+// ClearAccountTransactionsRequest represents all parameters of clear transaction data of a specific account request
+type ClearAccountTransactionsRequest struct {
+ AccountId int64 `json:"accountId,string" binding:"required,min=1"`
+ Password string `json:"password" binding:"omitempty,min=6,max=128"`
+}
+
// DataStatisticsResponse represents a view-object of user data statistic
type DataStatisticsResponse struct {
TotalAccountCount int64 `json:"totalAccountCount,string"`
diff --git a/pkg/services/transactions.go b/pkg/services/transactions.go
index d802f5dd..1ed7f36d 100644
--- a/pkg/services/transactions.go
+++ b/pkg/services/transactions.go
@@ -1381,6 +1381,43 @@ func (s *TransactionService) DeleteAllTransactions(c core.Context, uid int64, de
})
}
+// DeleteAllTransactionsOfAccount deletes all existed transactions of specific account from database
+func (s *TransactionService) DeleteAllTransactionsOfAccount(c core.Context, uid int64, accountId int64, pageCount int32) error {
+ if uid <= 0 {
+ return errs.ErrUserIdInvalid
+ }
+
+ if accountId <= 0 {
+ return errs.ErrAccountIdInvalid
+ }
+
+ transactions, err := s.GetAllSpecifiedTransactions(c, uid, 0, 0, 0, nil, []int64{accountId}, nil, false, models.TRANSACTION_TAG_FILTER_HAS_ANY, "", "", pageCount, true)
+
+ if err != nil {
+ return err
+ }
+
+ if len(transactions) < 1 {
+ return nil
+ }
+
+ for i := 0; i < len(transactions); i++ {
+ transaction := transactions[i]
+
+ if transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN {
+ err = s.DeleteTransaction(c, uid, transaction.RelatedId)
+ } else {
+ err = s.DeleteTransaction(c, uid, transaction.TransactionId)
+ }
+
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
// GetRelatedTransferTransaction returns the related transaction for transfer transaction
func (s *TransactionService) GetRelatedTransferTransaction(originalTransaction *models.Transaction) *models.Transaction {
var relatedType models.TransactionDbType
diff --git a/src/components/mobile/PasswordInputSheet.vue b/src/components/mobile/PasswordInputSheet.vue
index 4ec0f7d2..8c7f0762 100644
--- a/src/components/mobile/PasswordInputSheet.vue
+++ b/src/components/mobile/PasswordInputSheet.vue
@@ -26,7 +26,7 @@
diff --git a/src/consts/api.ts b/src/consts/api.ts
index 58d7b4f0..1e2d0bd5 100644
--- a/src/consts/api.ts
+++ b/src/consts/api.ts
@@ -7,6 +7,7 @@ export const DEFAULT_API_TIMEOUT: number = 10000; // 10s
export const DEFAULT_UPLOAD_API_TIMEOUT: number = 30000; // 30s
export const DEFAULT_EXPORT_API_TIMEOUT: number = 180000; // 180s
export const DEFAULT_IMPORT_API_TIMEOUT: number = 1800000; // 1800s
+export const DEFAULT_CLEAR_ALL_TRANSACTIONS_API_TIMEOUT: number = 1800000; // 1800s
export const DEFAULT_LLM_API_TIMEOUT: number = 600000; // 600s
export const GOOGLE_MAP_JAVASCRIPT_URL: string = 'https://maps.googleapis.com/maps/api/js';
diff --git a/src/lib/services.ts b/src/lib/services.ts
index 62654f35..33a124a0 100644
--- a/src/lib/services.ts
+++ b/src/lib/services.ts
@@ -21,6 +21,7 @@ import {
DEFAULT_UPLOAD_API_TIMEOUT,
DEFAULT_EXPORT_API_TIMEOUT,
DEFAULT_IMPORT_API_TIMEOUT,
+ DEFAULT_CLEAR_ALL_TRANSACTIONS_API_TIMEOUT,
DEFAULT_LLM_API_TIMEOUT,
GOOGLE_MAP_JAVASCRIPT_URL,
BAIDU_MAP_JAVASCRIPT_URL,
@@ -42,6 +43,7 @@ import type {
import type {
ExportTransactionDataRequest,
ClearDataRequest,
+ ClearAccountTransactionsRequest,
DataStatisticsResponse
} from '@/models/data_management.ts';
import type {
@@ -383,10 +385,19 @@ export default {
}
},
clearAllData: (req: ClearDataRequest): ApiResponsePromise
=> {
- return axios.post>('v1/data/clear/all.json', req);
+ return axios.post>('v1/data/clear/all.json', req, {
+ timeout: DEFAULT_CLEAR_ALL_TRANSACTIONS_API_TIMEOUT
+ } as ApiRequestConfig);
},
clearAllTransactions: (req: ClearDataRequest): ApiResponsePromise => {
- return axios.post>('v1/data/clear/transactions.json', req);
+ return axios.post>('v1/data/clear/transactions.json', req, {
+ timeout: DEFAULT_CLEAR_ALL_TRANSACTIONS_API_TIMEOUT
+ } as ApiRequestConfig);
+ },
+ clearAllTransactionsOfAccount: (req: ClearAccountTransactionsRequest): ApiResponsePromise => {
+ return axios.post>('v1/data/clear/transactions/by_account.json', req, {
+ timeout: DEFAULT_CLEAR_ALL_TRANSACTIONS_API_TIMEOUT
+ } as ApiRequestConfig);
},
getAllAccounts: ({ visibleOnly }: { visibleOnly: boolean }): ApiResponsePromise => {
return axios.get>('v1/accounts/list.json?visible_only=' + visibleOnly);
diff --git a/src/locales/de.json b/src/locales/de.json
index 95bc8666..b6db5eec 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Sind Sie sicher, dass Sie {count} Transaktionen importieren möchten?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "Sie haben {count} Transaktionen erfolgreich importiert.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Ein Aktivierungslink wurde an Ihre E-Mail-Adresse gesendet: {email}. Wenn Sie die E-Mail nicht erhalten haben, geben Sie bitte das Passwort erneut ein und klicken Sie auf die Schaltfläche unten, um die Bestätigungs-E-Mail erneut zu senden.",
"resendValidationEmailTip": "Wenn Sie die E-Mail nicht erhalten haben, geben Sie bitte das Passwort erneut ein und klicken Sie auf die Schaltfläche unten, um die Bestätigungs-E-Mail an: {email} erneut zu senden."
}
@@ -1409,6 +1410,7 @@
"Continue": "Weiter",
"Previous": "Zurück",
"Next": "Weiter",
+ "Confirm": "Confirm",
"Status": "Status",
"Enable": "Aktivieren",
"Enabled": "Aktiviert",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Diese Aktion kann NICHT rückgängig gemacht werden. Dies wird Ihre Konten, Kategorien, Tags und Transaktionsdaten löschen. Bitte geben Sie Ihr aktuelles Passwort ein, um zu bestätigen.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Alle Benutzerdaten wurden gelöscht",
"Unable to clear user data": "Benutzerdaten können nicht gelöscht werden",
diff --git a/src/locales/en.json b/src/locales/en.json
index efd5d747..9b31566f 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Are you sure you want to import {count} transactions?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "You have imported {count} transactions successfully.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Account activation link has been sent to your email address: {email}, If you don't receive the mail, please fill password again and click the button below to resend the validation mail.",
"resendValidationEmailTip": "If you don't receive the mail, please fill password again and click the button below to resend the validation mail to: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Continue",
"Previous": "Previous",
"Next": "Next",
+ "Confirm": "Confirm",
"Status": "Status",
"Enable": "Enable",
"Enabled": "Enabled",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "All user data has been cleared",
"Unable to clear user data": "Unable to clear user data",
diff --git a/src/locales/es.json b/src/locales/es.json
index 7ca796ff..0e1411dc 100644
--- a/src/locales/es.json
+++ b/src/locales/es.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "¿Está seguro de que desea importar {count} transacciones?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "Ha importado {count} transacciones correctamente.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "El enlace de activación de la cuenta se envió a su dirección de correo electrónico: {email}. Si no recibe el correo, ingrese la contraseña nuevamente y haga clic en el botón a continuación para reenviar el correo de validación.",
"resendValidationEmailTip": "Si no recibe el correo, complete nuevamente la contraseña y haga clic en el botón a continuación para reenviar el correo de validación a: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Continuar",
"Previous": "Anterior",
"Next": "Siguiente",
+ "Confirm": "Confirm",
"Status": "Estado",
"Enable": "Activar",
"Enabled": "Activado",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "NO PUEDE deshacer esta acción. Esto borrará sus cuentas, categorías, etiquetas y datos de transacciones. Por favor ingrese su contraseña actual para confirmar.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Todos los datos del usuario han sido borrados.",
"Unable to clear user data": "No se pueden borrar los datos del usuario",
diff --git a/src/locales/fr.json b/src/locales/fr.json
index cf72d434..1ae2f112 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Êtes-vous sûr de vouloir importer {count} transactions ?",
"importingTransactions": "Importation ({process}%)",
"importTransactionResult": "Vous avez importé {count} transactions avec succès.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Le lien d'activation du compte a été envoyé à votre adresse e-mail : {email}, Si vous ne recevez pas le mail, veuillez remplir à nouveau le mot de passe et cliquer sur le bouton ci-dessous pour renvoyer l'e-mail de validation.",
"resendValidationEmailTip": "Si vous ne recevez pas le mail, veuillez remplir à nouveau le mot de passe et cliquer sur le bouton ci-dessous pour renvoyer l'e-mail de validation à : {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Continuer",
"Previous": "Précédent",
"Next": "Suivant",
+ "Confirm": "Confirm",
"Status": "État",
"Enable": "Activer",
"Enabled": "Activé",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "Vous NE POUVEZ PAS annuler cette action. Ceci effacera vos données de transactions. Veuillez entrer votre mot de passe actuel pour confirmer.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Vous NE POUVEZ PAS annuler cette action. Ceci effacera vos comptes, catégories, étiquettes et données de transactions. Veuillez entrer votre mot de passe actuel pour confirmer.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Vous NE POUVEZ PAS annuler cette action. \"Effacer toutes les transactions\" effacera toutes vos données de transactions, et \"Effacer toutes les données\" effacera vos comptes, catégories, étiquettes et données de transactions. Veuillez entrer votre mot de passe actuel pour confirmer.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "Toutes les transactions ont été effacées",
"All user data has been cleared": "Toutes les données utilisateur ont été effacées",
"Unable to clear user data": "Impossible d'effacer les données utilisateur",
diff --git a/src/locales/it.json b/src/locales/it.json
index 6b063c57..1432ea3a 100644
--- a/src/locales/it.json
+++ b/src/locales/it.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Sei sicuro di voler importare {count} transazioni?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "Hai importato {count} transazioni.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Abbiamo inviato un link per l'attivazione del tuo account all'indirizzo {email}. Se non hai ricevuto la mail, inserisci nuovamente la password e premi il bottone per ritentare l'invio.",
"resendValidationEmailTip": "Se non hai ricevuto la mail, inserisci nuovamente la password e premi il bottone per ritentare l'invio all'indirizzo: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Continua",
"Previous": "Precedente",
"Next": "Successivo",
+ "Confirm": "Confirm",
"Status": "Stato",
"Enable": "Abilita",
"Enabled": "Abilitato",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "NON PUOI annullare questa azione. Questo cancellerà i tuoi account, categorie, tag e dati delle transazioni. Inserisci la tua password attuale per confermare.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Tutti i dati utente sono stati cancellati",
"Unable to clear user data": "Impossibile cancellare i dati utente",
diff --git a/src/locales/ja.json b/src/locales/ja.json
index 746944c7..a720311c 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "本当に{count}件の取引をインポートしますか?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "{count}件の取引を正常にインポートしました。",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "アカウントの有効化リンクがメールアドレスに送信されました:{email}、メールが届かない場合はパスワードをもう一度入力して下のボタンをクリックして認証メールを再送信してください。",
"resendValidationEmailTip": "メールが届かない場合は、パスワードをもう一度入力の上、以下のボタンをクリックして検証メールを再送信してください: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "続ける",
"Previous": "前",
"Next": "次",
+ "Confirm": "Confirm",
"Status": "ステータス",
"Enable": "有効",
"Enabled": "有効になっています",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "このアクションを元に戻すことはできません。これにより、口座、カテゴリ、タグ、および取引データがクリアされます。確認のため現在のパスワードを入力してください。",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "ユーザーデータがすべてクリアされました",
"Unable to clear user data": "ユーザーデータをクリアできません",
diff --git a/src/locales/nl.json b/src/locales/nl.json
index 94d88998..58bf0d7b 100644
--- a/src/locales/nl.json
+++ b/src/locales/nl.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Weet je zeker dat je {count} transacties wilt importeren?",
"importingTransactions": "Bezig met importeren ({process}%)",
"importTransactionResult": "Je hebt {count} transacties succesvol geïmporteerd.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Een activatielink is verzonden naar je e-mailadres: {email}. Als je de e-mail niet ontvangt, vul dan je wachtwoord opnieuw in en klik op de knop hieronder om de validatiemail opnieuw te verzenden.",
"resendValidationEmailTip": "Als je de e-mail niet ontvangt, vul dan je wachtwoord opnieuw in en klik op de knop hieronder om de validatiemail opnieuw te verzenden naar: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Doorgaan",
"Previous": "Vorige",
"Next": "Volgende",
+ "Confirm": "Confirm",
"Status": "Status",
"Enable": "Inschakelen",
"Enabled": "Ingeschakeld",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Dit kan NIET ongedaan worden gemaakt. Je rekeningen, categorieën, tags en transacties worden gewist. Voer je huidige wachtwoord in ter bevestiging.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Alle gebruikersgegevens zijn gewist",
"Unable to clear user data": "Kan gebruikersgegevens niet wissen",
diff --git a/src/locales/pt_BR.json b/src/locales/pt_BR.json
index a7f02c99..123e7e5d 100644
--- a/src/locales/pt_BR.json
+++ b/src/locales/pt_BR.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Tem certeza de que deseja importar {count} transações?",
"importingTransactions": "Importando ({process}%)",
"importTransactionResult": "Você importou {count} transações com sucesso.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "O link de ativação da conta foi enviado para seu endereço de e-mail: {email}. Se você não receber o e-mail, por favor preencha a senha novamente e clique no botão abaixo para reenviar o e-mail de validação.",
"resendValidationEmailTip": "Se você não receber o e-mail, por favor preencha a senha novamente e clique no botão abaixo para reenviar o e-mail de validação para: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Continuar",
"Previous": "Anterior",
"Next": "Próximo",
+ "Confirm": "Confirm",
"Status": "Status",
"Enable": "Habilitar",
"Enabled": "Habilitado",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Você NÃO PODE desfazer esta ação. Isto apagará seus dados de contas, categorias, tags e transações. Por favor, insira sua senha atual para confirmar.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Todos os dados de usuário foram apagados",
"Unable to clear user data": "Não foi possível limpar os dados de usuário",
diff --git a/src/locales/ru.json b/src/locales/ru.json
index 5614a948..285e6232 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Вы уверены, что хотите импортировать {count} транзакций?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "Вы успешно импортировали {count} транзакций.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Ссылка для активации учетной записи была отправлена на ваш электронный адрес: {email}. Если вы не получили письмо, заполните пароль снова и нажмите кнопку ниже, чтобы отправить письмо повторно.",
"resendValidationEmailTip": "Если вы не получили письмо, заполните пароль снова и нажмите кнопку ниже, чтобы отправить письмо повторно на: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Продолжить",
"Previous": "Предыдущий",
"Next": "Следующий",
+ "Confirm": "Confirm",
"Status": "Статус",
"Enable": "Включить",
"Enabled": "Включено",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Вы НЕ сможете отменить это действие. Это очистит данные ваших счетов, категорий, тегов и транзакций. Пожалуйста, введите текущий пароль для подтверждения.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Все данные пользователя были очищены",
"Unable to clear user data": "Не удалось очистить данные пользователя",
diff --git a/src/locales/uk.json b/src/locales/uk.json
index 2d01f297..d1876937 100644
--- a/src/locales/uk.json
+++ b/src/locales/uk.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Ви впевнені, що хочете імпортувати {count} транзакцій?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "Ви успішно імпортували {count} транзакцій.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Посилання для активації облікового запису було надіслано на вашу електронну адресу: {email}. Якщо ви не отримали лист, введіть пароль ще раз і натисніть кнопку нижче, щоб надіслати лист повторно.",
"resendValidationEmailTip": "Якщо ви не отримали лист, введіть пароль ще раз і натисніть кнопку нижче, щоб надіслати лист повторно на адресу: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Продовжити",
"Previous": "Назад",
"Next": "Далі",
+ "Confirm": "Confirm",
"Status": "Статус",
"Enable": "Увімкнути",
"Enabled": "Увімкнено",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Цю дію не можна скасувати. Будуть видалені рахунки, категорії, теги та транзакції. Введіть поточний пароль для підтвердження.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Усі дані користувача очищено",
"Unable to clear user data": "Не вдалося очистити дані",
diff --git a/src/locales/vi.json b/src/locales/vi.json
index 1e44b794..943d25d2 100644
--- a/src/locales/vi.json
+++ b/src/locales/vi.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "Bạn có chắc chắn muốn nhập {count} giao dịch không?",
"importingTransactions": "Importing ({process}%)",
"importTransactionResult": "Bạn đã nhập thành công {count} giao dịch.",
+ "clearTransactionsInAccountTip": "You CANNOT undo this action. This will clear your transactions data in {account}. Please enter your current password to confirm.",
"accountActivationAndResendValidationEmailTip": "Liên kết kích hoạt tài khoản đã được gửi tới email của bạn: {email}. Nếu bạn không nhận được email, vui lòng nhập lại mật khẩu và nhấp nút bên dưới để gửi lại email xác nhận.",
"resendValidationEmailTip": "Nếu bạn không nhận được email, vui lòng nhập lại mật khẩu và nhấp nút bên dưới để gửi lại email xác nhận tới: {email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "Tiếp tục",
"Previous": "Trước",
"Next": "Tiếp theo",
+ "Confirm": "Confirm",
"Status": "Trạng thái",
"Enable": "Bật",
"Enabled": "Đã bật",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "Bạn KHÔNG THỂ hoàn tác hành động này. Thao tác này sẽ xóa dữ liệu tài khoản, danh mục, thẻ và giao dịch của bạn. Vui lòng nhập mật khẩu hiện tại của bạn để xác nhận.",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.",
+ "All transactions in this account has been cleared": "All transactions in this account has been cleared",
"All transactions has been cleared": "All transactions has been cleared",
"All user data has been cleared": "Tất cả dữ liệu người dùng đã bị xóa",
"Unable to clear user data": "Không thể xóa dữ liệu người dùng",
diff --git a/src/locales/zh_Hans.json b/src/locales/zh_Hans.json
index 123aff3f..622fffcb 100644
--- a/src/locales/zh_Hans.json
+++ b/src/locales/zh_Hans.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "您确定要导入 {count} 个交易?",
"importingTransactions": "正在导入 ({process}%)",
"importTransactionResult": "您已经成功导入 {count} 个交易。",
+ "clearTransactionsInAccountTip": "您不能撤销该操作。该操作将会清除您在 {account} 账户中的交易数据。请输入您当前的密码以确认。",
"accountActivationAndResendValidationEmailTip": "账号激活链接已经发送到您的邮箱地址:{email},如果您没有收到邮件,请再次输入密码并点击下方的按钮重新发送验证邮件。",
"resendValidationEmailTip": "如果您没有收到邮件,请再次输入密码并点击下方的按钮重新发送验证邮件到:{email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "继续",
"Previous": "上一步",
"Next": "下一步",
+ "Confirm": "确认",
"Status": "状态",
"Enable": "启用",
"Enabled": "启用",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "您不能撤销该操作。该操作将会清除您的交易数据。请输入您当前的密码以确认。",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "您不能撤销该操作。该操作将会清除您的账户、分类、标签以及交易数据。请输入您当前的密码以确认。",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "您不能撤销该操作。\"清除所有交易\" 将会清除您的所有交易数据,以及 \"清除所有数据\" 将会清除您的账户、分类、标签以及交易数据。请输入您当前的密码以确认。",
+ "All transactions in this account has been cleared": "该账户中的所有交易已经清空",
"All transactions has been cleared": "所有交易已经清空",
"All user data has been cleared": "用户所有数据已经清空",
"Unable to clear user data": "无法清除用户数据",
diff --git a/src/locales/zh_Hant.json b/src/locales/zh_Hant.json
index ec08861a..286867e1 100644
--- a/src/locales/zh_Hant.json
+++ b/src/locales/zh_Hant.json
@@ -124,6 +124,7 @@
"confirmImportTransactions": "您確定要匯入 {count} 個交易?",
"importingTransactions": "正在匯入 ({process}%)",
"importTransactionResult": "您已經成功匯入 {count} 個交易。",
+ "clearTransactionsInAccountTip": "您不能還原此操作。此操作將會清除您在 {account} 帳戶中的交易資料。請輸入您目前的密碼以確認。",
"accountActivationAndResendValidationEmailTip": "帳號啟用連結已經傳送到您的信箱地址:{email},如果您沒有收到郵件,請再次輸入密碼並點擊下方的按鈕重新發送驗證郵件。",
"resendValidationEmailTip": "如果您沒有收到郵件,請再次輸入密碼並點擊下方的按鈕重新發送驗證郵件到:{email}"
}
@@ -1409,6 +1410,7 @@
"Continue": "繼續",
"Previous": "上一步",
"Next": "下一步",
+ "Confirm": "確認",
"Status": "狀態",
"Enable": "啟用",
"Enabled": "啟用",
@@ -2098,6 +2100,7 @@
"You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.": "您不能還原此操作。此操作將會清除您的交易資料。請輸入您目前的密碼以確認。",
"You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "您不能還原此操作。此操作將會清除您的帳戶、分類、標籤以及交易資料。請輸入您目前的密碼以確認。",
"You CANNOT undo this action. \"Clear All Transactions\" will clear all your transactions data, and \"Clear All Data\" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.": "您不能還原此操作。\"清除所有交易\" 將會清除您的所有交易資料,以及 \"清除所有資料\" 將會清除您的帳戶、分類、標籤以及交易資料。請輸入您目前的密碼以確認。",
+ "All transactions in this account has been cleared": "此帳戶中的所有交易已經清空",
"All transactions has been cleared": "所有交易已經清空",
"All user data has been cleared": "使用者所有資料已經清空",
"Unable to clear user data": "無法清除使用者資料",
diff --git a/src/models/data_management.ts b/src/models/data_management.ts
index dbee88f3..1a0e3426 100644
--- a/src/models/data_management.ts
+++ b/src/models/data_management.ts
@@ -14,6 +14,11 @@ export interface ClearDataRequest {
readonly password: string;
}
+export interface ClearAccountTransactionsRequest {
+ readonly accountId: string;
+ readonly password: string;
+}
+
export interface DataStatisticsResponse {
readonly totalAccountCount: string;
readonly totalTransactionCategoryCount: string;
diff --git a/src/stores/index.ts b/src/stores/index.ts
index 7cf5e9d1..8829973b 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -457,6 +457,46 @@ export const useRootStore = defineStore('root', () => {
});
}
+ function clearAllUserTransactionsOfAccount({ accountId, password }: { accountId: string, password: string }): Promise {
+ return new Promise((resolve, reject) => {
+ services.clearAllTransactionsOfAccount({
+ accountId: accountId,
+ password: password
+ }).then(response => {
+ const data = response.data;
+
+ if (!data || !data.success || !data.result) {
+ reject({ message: 'Unable to clear user data' });
+ return;
+ }
+
+ if (!accountsStore.accountListStateInvalid) {
+ accountsStore.updateAccountListInvalidState(true);
+ }
+
+ if (!overviewStore.transactionOverviewStateInvalid) {
+ overviewStore.updateTransactionOverviewInvalidState(true);
+ }
+
+ if (!statisticsStore.transactionStatisticsStateInvalid) {
+ statisticsStore.updateTransactionStatisticsInvalidState(true);
+ }
+
+ resolve(data.result);
+ }).catch(error => {
+ logger.error('failed to clear user data', error);
+
+ if (error && error.processed) {
+ reject(error);
+ } else if (error.response && error.response.data && error.response.data.errorMessage) {
+ reject({ error: error.response.data });
+ } else {
+ reject({ message: 'Unable to clear user data' });
+ }
+ });
+ });
+ }
+
function clearAllUserTransactions({ password }: { password: string }): Promise {
return new Promise((resolve, reject) => {
services.clearAllTransactions({
@@ -560,7 +600,8 @@ export const useRootStore = defineStore('root', () => {
resetPassword,
updateUserProfile,
resendVerifyEmailByLoginedUser,
- clearAllUserData,
- clearAllUserTransactions
+ clearAllUserTransactionsOfAccount,
+ clearAllUserTransactions,
+ clearAllUserData
};
});
diff --git a/src/views/desktop/accounts/ListPage.vue b/src/views/desktop/accounts/ListPage.vue
index ef216153..aaac9b48 100644
--- a/src/views/desktop/accounts/ListPage.vue
+++ b/src/views/desktop/accounts/ListPage.vue
@@ -248,6 +248,13 @@
@click="edit(element)">
{{ tt('Edit') }}
+
+ {{ tt('Clear All Transactions') }}
+
+
;
type SnackBarType = InstanceType;
type EditDialogType = InstanceType;
type ReconciliationStatementDialogType = InstanceType;
+type ClearAllTransactionsDialogType = InstanceType;
const display = useDisplay();
@@ -361,6 +372,7 @@ const confirmDialog = useTemplateRef('confirmDialog');
const snackbar = useTemplateRef('snackbar');
const editDialog = useTemplateRef('editDialog');
const reconciliationStatementDialog = useTemplateRef('reconciliationStatementDialog');
+const clearAllTransactionsDialog = useTemplateRef('clearAllTransactionsDialog');
const activeAccountCategoryType = ref(AccountCategory.Default.type);
const activeTab = ref('accountPage');
@@ -513,6 +525,16 @@ function showReconciliationStatementCustomDateRangeDialog(account: Account, date
});
}
+function clearAllTransactions(account: Account): void {
+ clearAllTransactionsDialog.value?.open(account).then(() => {
+ snackbar.value?.showMessage('All transactions in this account has been cleared');
+
+ if (accountsStore.accountListStateInvalid && !loading.value) {
+ reload(false);
+ }
+ });
+}
+
function hide(account: Account, targetAccount: Account, hidden: boolean): void {
loading.value = true;
diff --git a/src/views/desktop/accounts/list/dialogs/ClearAllTransactionsDialog.vue b/src/views/desktop/accounts/list/dialogs/ClearAllTransactionsDialog.vue
new file mode 100644
index 00000000..a0916a68
--- /dev/null
+++ b/src/views/desktop/accounts/list/dialogs/ClearAllTransactionsDialog.vue
@@ -0,0 +1,111 @@
+
+
+
+
+
+
{{ tt('Are you sure you want to clear all transactions?') }}
+
+
+ {{ tt('format.misc.clearTransactionsInAccountTip', { account: currentAccount?.name }) }}
+
+
+
+
+
+
+
+
+ {{ tt('Confirm') }}
+
+
+
+ {{ tt('Cancel') }}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/mobile/accounts/ListPage.vue b/src/views/mobile/accounts/ListPage.vue
index 2ac51170..4f2bc80f 100644
--- a/src/views/mobile/accounts/ListPage.vue
+++ b/src/views/mobile/accounts/ListPage.vue
@@ -162,12 +162,16 @@
{{ tt('Reconciliation Statement') }}
+
+ {{ tt('Clear All Transactions') }}
+
{{ subAccount.name }}
{{ tt('Reconciliation Statement') }}
+ {{ tt('Clear All Transactions') }}
@@ -198,6 +202,16 @@
{{ tt('Cancel') }}
+
+
+
@@ -209,6 +223,7 @@ import { useI18n } from '@/locales/helpers.ts';
import { useI18nUIComponents, showLoading, hideLoading } from '@/lib/ui/mobile.ts';
import { useAccountListPageBaseBase } from '@/views/base/accounts/AccountListPageBase.ts';
+import { useRootStore } from '@/stores/index.ts';
import { useAccountsStore } from '@/stores/account.ts';
import { TextDirection } from '@/core/text.ts';
@@ -238,15 +253,20 @@ const {
accountBalance
} = useAccountListPageBaseBase();
+const rootStore = useRootStore();
const accountsStore = useAccountsStore();
const loadingError = ref(null);
const sortable = ref(false);
const accountForMoreActionSheet = ref(null);
const accountToDelete = ref(null);
+const accountToClearTransactions = ref(null);
+const currentPasswordForClearData = ref('');
+const clearingData = ref(false);
const showAccountMoreActionSheet = ref(false);
const showMoreActionSheet = ref(false);
const showDeleteActionSheet = ref(false);
+const showInputPasswordSheetForClearAllTransactions = ref(false);
const displayOrderSaving = ref(false);
const textDirection = computed(() => getCurrentLanguageTextDirection());
@@ -343,6 +363,48 @@ function showReconciliationStatement(account: Account | null): void {
accountForMoreActionSheet.value = null;
}
+function showPasswordSheetForClearAllTransaction(account: Account | null): void {
+ if (!account) {
+ showAlert('An error occurred');
+ return;
+ }
+
+ accountToClearTransactions.value = account;
+ currentPasswordForClearData.value = '';
+ showInputPasswordSheetForClearAllTransactions.value = true;
+ showAccountMoreActionSheet.value = false;
+ accountForMoreActionSheet.value = null;
+}
+
+function clearAllTransactions(password: string): void {
+ if (!accountToClearTransactions.value) {
+ showAlert('An error occurred');
+ return;
+ }
+
+ clearingData.value = true;
+ showLoading(() => clearingData.value);
+
+ rootStore.clearAllUserTransactionsOfAccount({
+ accountId: accountToClearTransactions.value.id,
+ password: password
+ }).then(() => {
+ clearingData.value = false;
+ currentPasswordForClearData.value = '';
+ hideLoading();
+
+ showInputPasswordSheetForClearAllTransactions.value = false;
+ showToast('All transactions in this account has been cleared');
+ }).catch(error => {
+ clearingData.value = false;
+ hideLoading();
+
+ if (!error.processed) {
+ showToast(error.message || error);
+ }
+ });
+}
+
function hide(account: Account, hidden: boolean): void {
showLoading();