From 5291f485acdcc02ce14ed99663a00cef0554e619 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 4 Mar 2023 22:16:59 +0100 Subject: [PATCH 1/3] Fix #7127 by adding an option to the API --- .../V1/Controllers/Data/DestroyController.php | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.php index 18de6b961c..7da833a4b4 100644 --- a/app/Api/V1/Controllers/Data/DestroyController.php +++ b/app/Api/V1/Controllers/Data/DestroyController.php @@ -94,19 +94,39 @@ class DestroyController extends Controller case 'object_groups': $this->destroyObjectGroups(); break; + case 'not_assets_liabilities': + $this->destroyAccounts( + [ + AccountType::BENEFICIARY, + AccountType::CASH, + AccountType::CREDITCARD, + AccountType::DEFAULT, + AccountType::EXPENSE, + AccountType::IMPORT, + AccountType::INITIAL_BALANCE, + AccountType::LIABILITY_CREDIT, + AccountType::RECONCILIATION, + AccountType::REVENUE, + ] + ); + break; case 'accounts': $this->destroyAccounts( [ AccountType::ASSET, - AccountType::DEFAULT, AccountType::BENEFICIARY, - AccountType::EXPENSE, - AccountType::REVENUE, - AccountType::INITIAL_BALANCE, + AccountType::CASH, + AccountType::CREDITCARD, AccountType::DEBT, + AccountType::DEFAULT, + AccountType::EXPENSE, + AccountType::IMPORT, + AccountType::INITIAL_BALANCE, + AccountType::LIABILITY_CREDIT, AccountType::LOAN, AccountType::MORTGAGE, - AccountType::CREDITCARD, + AccountType::RECONCILIATION, + AccountType::REVENUE, ] ); break; From 79951453cd192dd46219f74fb3582cd75f782d8c Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 4 Mar 2023 22:17:19 +0100 Subject: [PATCH 2/3] Switch the button --- resources/views/profile/index.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/profile/index.twig b/resources/views/profile/index.twig index b2e2dbe23b..166a240404 100644 --- a/resources/views/profile/index.twig +++ b/resources/views/profile/index.twig @@ -318,7 +318,7 @@ url = '{{ route('api.v1.data.purge') }}'; } if (link.data('type') === 'unused_accounts') { - url = deleteAPIRoute + '?objects=accounts&unused=true'; + url = deleteAPIRoute + '?objects=not_assets_liabilities&unused=true'; } // replace icon with loading thing From 4657d34ae462423cd8501a5adb4d084cbc3366b8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 4 Mar 2023 22:18:37 +0100 Subject: [PATCH 3/3] Fix request --- app/Api/V1/Requests/Data/DestroyRequest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Api/V1/Requests/Data/DestroyRequest.php b/app/Api/V1/Requests/Data/DestroyRequest.php index bc8026c703..299ecf138b 100644 --- a/app/Api/V1/Requests/Data/DestroyRequest.php +++ b/app/Api/V1/Requests/Data/DestroyRequest.php @@ -53,7 +53,8 @@ class DestroyRequest extends FormRequest public function rules(): array { $valid = 'budgets,bills,piggy_banks,rules,recurring,categories,tags,object_groups'. - ',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'; + ',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'. + ',not_assets_liabilities'; return [ 'objects' => sprintf('required|min:1|string|in:%s', $valid),