Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Merge branch 'develop' into 5.8-dev
James Cole5f11272d4998
diff --cc app/Api/V1/Controllers/Data/PurgeController.phpindex 0000000000,0000000000..34fa6d8695new file mode 100644--- /dev/null+++ b/app/Api/V1/Controllers/Data/PurgeController.php@@@ -1,0 -1,0 +1,93 @@@++<?php++/*++ * PurgeController.php++ * Copyright (c) 2022 [email protected]++ *++ * This file is part of Firefly III (https://github.com/firefly-iii).++ *++ * This program is free software: you can redistribute it and/or modify++ * it under the terms of the GNU Affero General Public License as++ * published by the Free Software Foundation, either version 3 of the++ * License, or (at your option) any later version.++ *++ * This program is distributed in the hope that it will be useful,++ * but WITHOUT ANY WARRANTY; without even the implied warranty of++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the++ * GNU Affero General Public License for more details.++ *++ * You should have received a copy of the GNU Affero General Public License++ * along with this program. If not, see <https://www.gnu.org/licenses/>.++ */++++namespace FireflyIII\Api\V1\Controllers\Data;++++use FireflyIII\Api\V1\Controllers\Controller;++use FireflyIII\Models\Account;++use FireflyIII\Models\Bill;++use FireflyIII\Models\Budget;++use FireflyIII\Models\Category;++use FireflyIII\Models\ObjectGroup;++use FireflyIII\Models\PiggyBank;++use FireflyIII\Models\Recurrence;++use FireflyIII\Models\Rule;++use FireflyIII\Models\RuleGroup;++use FireflyIII\Models\Tag;++use FireflyIII\Models\TransactionGroup;++use FireflyIII\Models\TransactionJournal;++use Illuminate\Http\JsonResponse;++++class PurgeController extends Controller++{++ /**++ * @return JsonResponse++ */++ public function purge(): JsonResponse++ {++++ $user = auth()->user();++++ // some manual code, too lazy to call all repositories.++ //,transactions,withdrawals,deposits,transfers';++++ // budgets:++ Budget::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // bills++ Bill::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // piggies++ $set = PiggyBank::leftJoin('accounts','accounts.id','piggy_banks.account_id')++ ->where('accounts.user_id', $user->id)->onlyTrashed()->get(['piggy_banks.*']);++ /** @var PiggyBank $piggy */++ foreach($set as $piggy) {++ $piggy->forceDelete();++ }++++ // rule group++ RuleGroup::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // rules++ Rule::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // recurring transactions++ Recurrence::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // categories++ Category::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // tags++ Tag::whereUserId($user->id)->onlyTrashed()->forceDelete();++++++ // accounts++ Account::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // transaction groups++ TransactionGroup::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ // transaction journals++ TransactionJournal::whereUserId($user->id)->onlyTrashed()->forceDelete();++++ return response()->json([], 204);++ }++}diff --cc app/Events/Admin/InvitationCreated.phpindex a91fc89e4c,0000000000..ac9d860255mode 100644,000000..100644--- a/app/Events/Admin/InvitationCreated.php+++ b/app/Events/Admin/InvitationCreated.php@@@ -1,49 -1,0 +1,50 @@@+<?php++declare(strict_types=1);+/*+ * InvitationCreated.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Events\Admin;++use FireflyIII\Events\Event;+use FireflyIII\Models\InvitedUser;+use FireflyIII\Models\TransactionGroup;+use Illuminate\Queue\SerializesModels;++/**+ * Class InvitationCreated+ */+class InvitationCreated extends Event+{+ use SerializesModels;++ public InvitedUser $invitee;++ public TransactionGroup $transactionGroup;++ /**+ * Create a new event instance.+ *+ * @param InvitedUser $invitee+ */+ public function __construct(InvitedUser $invitee)+ {+ $this->invitee = $invitee;+ }+}diff --cc app/Events/NewVersionAvailable.phpindex cd02644e4a,0000000000..645b79a6a7mode 100644,000000..100644--- a/app/Events/NewVersionAvailable.php+++ b/app/Events/NewVersionAvailable.php@@@ -1,41 -1,0 +1,42 @@@+<?php++declare(strict_types=1);+/*+ * NewVersionAvailable.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Events;++use Illuminate\Queue\SerializesModels;++class NewVersionAvailable extends Event+{+ use SerializesModels;++ public string $message;++ /**+ * Create a new event instance. This event is triggered when a new version is available.+ *+ * @param string $message+ */+ public function __construct(string $message)+ {+ $this->message = $message;+ }+}diff --cc app/Handlers/Events/UserEventHandler.phpindex 8588427697,2d8c2ca22d..bad99b16fd--- a/app/Handlers/Events/UserEventHandler.php+++ b/app/Handlers/Events/UserEventHandler.php@@@ -24,15 -24,17 +24,17 @@@ declare(strict_types=1)namespace FireflyIII\Handlers\Events;use Carbon\Carbon;+use Database\Seeders\ExchangeRateSeeder;use Exception;use FireflyIII\Events\ActuallyLoggedIn;++use FireflyIII\Events\Admin\InvitationCreated;use FireflyIII\Events\DetectedNewIPAddress;use FireflyIII\Events\RegisteredUser;use FireflyIII\Events\RequestedNewPassword;use FireflyIII\Events\UserChangedEmail;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Mail\ConfirmEmailChangeMail;-use FireflyIII\Mail\NewIPAddressWarningMail;-use FireflyIII\Mail\RegisteredUser as RegisteredUserMail;-use FireflyIII\Mail\RequestedNewPassword as RequestedNewPasswordMail;++use FireflyIII\Mail\InvitationMail;use FireflyIII\Mail\UndoEmailChangeMail;use FireflyIII\Models\GroupMembership;use FireflyIII\Models\UserGroup;@@@ -75,16 -71,8 +77,33 @@@ class UserEventHandleLog::debug('User count is one, attach role.');$repository->attachRole($event->user, 'owner');}+ }+++ /**++ * @param InvitationCreated $event++ * @return void++ */++ public function sendRegistrationInvite(InvitationCreated $event): void++ {++ $invitee = $event->invitee->email;++ $admin = $event->invitee->user->email;++ $url = route('invite', [$event->invitee->invite_code]);++ try {++ Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));++++ } catch (Exception $e) { // @phpstan-ignore-line++ Log::error($e->getMessage());++ }++ }+- return true;+ /**+ * @param RegisteredUser $event+ * @return bool+ */+ public function createExchangeRates(RegisteredUser $event): void+ {+ $seeder = new ExchangeRateSeeder;+ $seeder->run();}/**diff --cc app/Helpers/Collector/Extensions/MetaCollection.phpindex 4f94df0d79,dadb4067f7..d2347db148--- a/app/Helpers/Collector/Extensions/MetaCollection.php+++ b/app/Helpers/Collector/Extensions/MetaCollection.php@@@ -223,23 -102,6 +223,20 @@@ trait MetaCollectioreturn $this;}+ /**+ * @param string $url+ * @return GroupCollectorInterface+ */+ public function externalUrlDoesNotContain(string $url): GroupCollectorInterface+ {+ $this->joinMetaDataTables();+ $url = json_encode($url);+ $url = str_replace('\\', '\\\\', trim($url, '"'));+ $this->query->where('journal_meta.name', '=', 'external_url');+ $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $url));++ return $this;+ }---/*** @param string $url* @return GroupCollectorInterface@@@ -255,23 -117,6 +252,20 @@@return $this;}+ /**+ * @param string $url+ * @return GroupCollectorInterface+ */+ public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface+ {+ $this->joinMetaDataTables();+ $url = json_encode($url);+ $url = str_replace('\\', '\\\\', ltrim($url, '"'));+ $this->query->where('journal_meta.name', '=', 'external_url');+ $this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url));++ return $this;+ }---/*** @param string $url* @return GroupCollectorInterfacediff --cc app/Helpers/Collector/GroupCollectorInterface.phpindex f0cba4abf9,b950f12f1f..26e0fb2d74--- a/app/Helpers/Collector/GroupCollectorInterface.php+++ b/app/Helpers/Collector/GroupCollectorInterface.php@@@ -406,14 -183,6 +406,11 @@@ interface GroupCollectorInterfac*/public function externalIdContains(string $externalId): GroupCollectorInterface;+ /**+ * @param string $externalId+ * @return GroupCollectorInterface+ */+ public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface;---/*** @param string $externalId* @return GroupCollectorInterface@@@ -432,14 -195,6 +429,11 @@@*/public function externalIdStarts(string $externalId): GroupCollectorInterface;+ /**+ * @param string $externalId+ * @return GroupCollectorInterface+ */+ public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface;---/*** @param string $url* @return GroupCollectorInterface@@@ -1030,17 -636,6 +1024,14 @@@*/public function setInternalReference(string $externalId): GroupCollectorInterface;+ /**+ * Look for specific external ID's.+ *+ * @param string $externalId+ *+ * @return GroupCollectorInterface+ */+ public function excludeInternalReference(string $externalId): GroupCollectorInterface;---/*** Limit the result to a set of specific transaction journals.*diff --cc app/Http/Requests/InviteUserFormRequest.phpindex fb603b74ee,0000000000..628b655c29mode 100644,000000..100644--- a/app/Http/Requests/InviteUserFormRequest.php+++ b/app/Http/Requests/InviteUserFormRequest.php@@@ -1,43 -1,0 +1,44 @@@+<?php++declare(strict_types=1);+/*+ * InviteUserFormRequest.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Http\Requests;++use FireflyIII\Support\Request\ChecksLogin;+use FireflyIII\Support\Request\ConvertsDataTypes;+use Illuminate\Foundation\Http\FormRequest;++class InviteUserFormRequest extends FormRequest+{+ use ConvertsDataTypes, ChecksLogin;++ /**+ * Rules for this request.+ *+ * @return array+ */+ public function rules(): array+ {+ return [+ 'invited_user' => 'required|email|unique:invited_users,email',+ ];+ }+}diff --cc app/Http/Requests/RecurrenceFormRequest.phpindex e2bf43d001,e2bf43d001..2b4bf8ed41--- a/app/Http/Requests/RecurrenceFormRequest.php+++ b/app/Http/Requests/RecurrenceFormRequest.php@@@ -99,7 -99,7 +99,7 @@@ class RecurrenceFormRequest extends For];// fill in foreign currency data-- if (null !== $this->float('foreign_amount')) {++ if (null !== $this->convertFloat('foreign_amount')) {$return['transactions'][0]['foreign_amount'] = $this->convertString('foreign_amount');$return['transactions'][0]['foreign_currency_id'] = $this->convertInteger('foreign_currency_id');}@@@ -228,7 -228,7 +228,7 @@@$rules['repetitions'] = 'required|numeric|between:0,254';}// if foreign amount, currency must be different.-- if (null !== $this->float('foreign_amount')) {++ if (null !== $this->convertFloat('foreign_amount')) {$rules['foreign_currency_id'] = 'exists:transaction_currencies,id|different:transaction_currency_id';}diff --cc app/Mail/InvitationMail.phpindex 0000000000,0000000000..5ad5ee1ac9new file mode 100644--- /dev/null+++ b/app/Mail/InvitationMail.php@@@ -1,0 -1,0 +1,61 @@@++<?php++/*++ * InvitationMail.php++ * Copyright (c) 2022 [email protected]++ *++ * This file is part of Firefly III (https://github.com/firefly-iii).++ *++ * This program is free software: you can redistribute it and/or modify++ * it under the terms of the GNU Affero General Public License as++ * published by the Free Software Foundation, either version 3 of the++ * License, or (at your option) any later version.++ *++ * This program is distributed in the hope that it will be useful,++ * but WITHOUT ANY WARRANTY; without even the implied warranty of++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the++ * GNU Affero General Public License for more details.++ *++ * You should have received a copy of the GNU Affero General Public License++ * along with this program. If not, see <https://www.gnu.org/licenses/>.++ */++++namespace FireflyIII\Mail;++++use Illuminate\Bus\Queueable;++use Illuminate\Mail\Mailable;++use Illuminate\Queue\SerializesModels;++++class InvitationMail extends Mailable++{++ use Queueable, SerializesModels;++++ public string $invitee;++ public string $admin;++ public string $url;++ public string $host;++++ /**++ * OAuthTokenCreatedMail constructor.++ *++ * @param string $ipAddress++ */++ public function __construct(string $invitee, string $admin, string $url)++ {++ $this->invitee = $invitee;++ $this->admin = $admin;++ $this->url = $url;++ $this->host = parse_url($url, PHP_URL_HOST);++ }++++ /**++ * Build the message.++ *++ * @return $this++ */++ public function build(): self++ {++ return $this++ ->markdown('emails.invitation')++ ->subject((string) trans('email.invite_user_subject'));++ }++}diff --cc app/Models/InvitedUser.phpindex 22e0c7bf15,0000000000..09f7c4ad25mode 100644,000000..100644--- a/app/Models/InvitedUser.php+++ b/app/Models/InvitedUser.php@@@ -1,49 -1,0 +1,50 @@@+<?php++declare(strict_types=1);+/*+ * InvitedUser.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Models;++use FireflyIII\User;+use Illuminate\Database\Eloquent\Model;+use Illuminate\Database\Eloquent\Relations\BelongsTo;++/**+ * Class InvitedUser+ */+class InvitedUser extends Model+{+ protected $fillable = ['user_id', 'email', 'invite_code', 'expires', 'redeemed'];++ protected $casts+ = [+ 'expires' => 'datetime',+ 'redeemed' => 'boolean',+ ];++ /**+ * @codeCoverageIgnore+ * @return BelongsTo+ */+ public function user(): BelongsTo+ {+ return $this->belongsTo(User::class);+ }+}diff --cc app/Providers/EventServiceProvider.phpindex 4811817068,c8f9302154..ade51af104--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@@ -111,14 -102,6 +111,14 @@@ class EventServiceProvider extends ServAdminRequestedTestMessage::class => ['FireflyIII\Handlers\Events\AdminEventHandler@sendTestMessage',],+ NewVersionAvailable::class => [+ 'FireflyIII\Handlers\Events\AdminEventHandler@sendNewVersion',+ ],+ InvitationCreated::class => [+ 'FireflyIII\Handlers\Events\AdminEventHandler@sendInvitationNotification',- //'FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationInvite',++ 'FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationInvite',+ ],+// is a Transaction Journal related event.StoredTransactionGroup::class => ['FireflyIII\Handlers\Events\StoredGroupEventHandler@processRules',diff --cc app/Repositories/User/UserRepository.phpindex 4d6c60dc95,d841a6bc46..3770c1b550--- a/app/Repositories/User/UserRepository.php+++ b/app/Repositories/User/UserRepository.php@@@ -436,34 -416,4 +436,34 @@@ class UserRepository implements UserRep{return Role::where('name', $role)->first();}++ /**+ * @inheritDoc+ */+ public function getInvitedUsers(): Collection+ {+ return InvitedUser::with('user')->get();+ }++ /**+ * @inheritDoc+ */+ public function validateInviteCode(string $code): bool+ {+ $now = Carbon::now();- $invitee = InvitedUser::where('invite_code', $code)->where('expires', '<=', $now)->where('redeemed', 0)->first();++ $invitee = InvitedUser::where('invite_code', $code)->where('expires', '>', $now->format('Y-m-d H:i:s'))->where('redeemed', 0)->first();+ return null !== $invitee;+ }++ /**+ * @inheritDoc+ */+ public function redeemCode(string $code): void+ {+ $obj = InvitedUser::where('invite_code', $code)->where('redeemed', 0)->first();+ if ($obj) {+ $obj->redeemed = true;+ $obj->save();+ }+ }}diff --cc app/Support/Request/ConvertsDataTypes.phpindex f2c39bfaf1,cc0d51b459..05b06f92cd--- a/app/Support/Request/ConvertsDataTypes.php+++ b/app/Support/Request/ConvertsDataTypes.php@@@ -219,7 -216,7 +219,7 @@@ trait ConvertsDataType** @return float|null*/-- protected function float(string $field): ?float++ protected function convertFloat(string $field): ?float{$res = $this->get($field);if (null === $res) {diff --cc app/TransactionRules/Actions/AppendDescriptionToNotes.phpindex 7ce4e37a5d,0000000000..783320c0cemode 100644,000000..100644--- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php+++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php@@@ -1,57 -1,0 +1,58 @@@+<?php++declare(strict_types=1);+/*+ * AppendDescriptionToNotes.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\TransactionRules\Actions;++use FireflyIII\Models\Note;+use FireflyIII\Models\TransactionJournal;+use Illuminate\Support\Facades\Log;++class AppendDescriptionToNotes implements ActionInterface+{+ /**+ * @inheritDoc+ */+ public function actOnArray(array $journal): bool+ {+ /** @var TransactionJournal $journal */+ $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ if (null === $journal) {+ Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));+ return false;+ }+ $note = $journal->notes()->first();+ if (null === $note) {+ $note = new Note;+ $note->noteable()->associate($journal);+ $note->text = '';+ }+ if ('' !== $note->text) {+ $note->text = trim(sprintf("%s \n%s", $note->text, $journal->description));+ }+ if ('' === $note->text) {+ $note->text = (string) $journal->description;+ }++ $note->save();+ return true;+ }+}diff --cc app/TransactionRules/Actions/AppendNotesToDescription.phpindex 53a4d1db24,0000000000..81d1dca2a6mode 100644,000000..100644--- a/app/TransactionRules/Actions/AppendNotesToDescription.php+++ b/app/TransactionRules/Actions/AppendNotesToDescription.php@@@ -1,64 -1,0 +1,65 @@@+<?php++declare(strict_types=1);+/*+ * AppendNotesToDescription.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\TransactionRules\Actions;++use FireflyIII\Models\Note;+use FireflyIII\Models\TransactionJournal;+use FireflyIII\Support\Request\ConvertsDataTypes;+use FireflyIII\Support\Steam;+use Illuminate\Support\Facades\Log;++/**+ * Class AppendNotesToDescription+ */+class AppendNotesToDescription implements ActionInterface+{+ use ConvertsDataTypes;+ /**+ * @inheritDoc+ */+ public function actOnArray(array $journal): bool+ {+ Log::debug('Now in AppendNotesToDescription');+ /** @var TransactionJournal $journal */+ $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ if (null === $journal) {+ Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));+ return false;+ }+ $note = $journal->notes()->first();+ if (null === $note) {+ Log::debug('Journal has no notes.');+ $note = new Note;+ $note->noteable()->associate($journal);+ $note->text = '';+ }+ // only append if there is something to append+ if ('' !== $note->text) {+ $journal->description = trim(sprintf("%s %s", $journal->description, (string) $this->clearString($note->text, false)));+ $journal->save();+ Log::debug(sprintf('Journal description is updated to "%s".', $journal->description));+ return true;+ }+ return false;+ }+}diff --cc app/TransactionRules/Actions/MoveDescriptionToNotes.phpindex cbad52ed07,0000000000..58c9724f1cmode 100644,000000..100644--- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php+++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php@@@ -1,63 -1,0 +1,64 @@@+<?php++declare(strict_types=1);+/*+ * MoveDescriptionToNotes.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\TransactionRules\Actions;++use FireflyIII\Models\Note;+use FireflyIII\Models\TransactionJournal;+use Illuminate\Support\Facades\Log;++/**+ * Class MoveDescriptionToNotes+ */+class MoveDescriptionToNotes implements ActionInterface+{+ /**+ * @inheritDoc+ */+ public function actOnArray(array $journal): bool+ {+ /** @var TransactionJournal $journal */+ $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ if (null === $journal) {+ Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));+ return false;+ }+ $note = $journal->notes()->first();+ if (null === $note) {+ $note = new Note;+ $note->noteable()->associate($journal);+ $note->text = '';+ }+ if ('' !== $note->text) {+ $note->text = trim(sprintf("%s \n%s", $note->text, $journal->description));+ $journal->description = '(no description)';+ }+ if ('' === $note->text) {+ $note->text = (string) $journal->description;+ $journal->description = '(no description)';+ }++ $note->save();+ $journal->save();+ return true;+ }+}diff --cc app/TransactionRules/Actions/MoveNotesToDescription.phpindex f261d44c7a,0000000000..ddc8b17c19mode 100644,000000..100644--- a/app/TransactionRules/Actions/MoveNotesToDescription.php+++ b/app/TransactionRules/Actions/MoveNotesToDescription.php@@@ -1,59 -1,0 +1,60 @@@+<?php++declare(strict_types=1);+/*+ * MoveNotesToDescription.php+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\TransactionRules\Actions;++use FireflyIII\Models\TransactionJournal;+use FireflyIII\Support\Request\ConvertsDataTypes;+use Illuminate\Support\Facades\Log;++class MoveNotesToDescription implements ActionInterface+{+ use ConvertsDataTypes;++ /**+ * @inheritDoc+ */+ public function actOnArray(array $journal): bool+ {+ /** @var TransactionJournal $journal */+ $journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ if (null === $journal) {+ Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));+ return false;+ }+ $note = $journal->notes()->first();+ if (null === $note) {+ // nothing to move, return null+ return false;+ }+ if ('' === $note->text) {+ // nothing to move, return null+ $note->delete();+ return false;+ }+ $journal->description = (string) $this->clearString($note->text, false);+ $journal->save();+ $note->delete();++ return true;+ }+}diff --cc database/migrations/2022_10_01_074908_invited_users.phpindex 00af7e9129,0000000000..9ceadcf524mode 100644,000000..100644--- a/database/migrations/2022_10_01_074908_invited_users.php+++ b/database/migrations/2022_10_01_074908_invited_users.php@@@ -1,37 -1,0 +1,38 @@@+<?php++declare(strict_types=1);++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up(): void+ {+ Schema::create('invited_users', function (Blueprint $table) {+ $table->id();+ $table->timestamps();+ $table->integer('user_id', false, true);+ $table->string('email', 255);+ $table->string('invite_code', 64);+ $table->dateTime('expires');+ $table->boolean('redeemed');+ $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');+ });+ }++ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down(): void+ {+ Schema::dropIfExists('invited_users');+ }+};diff --cc resources/lang/en_US/email.phpindex a8d96e80b4,cf1c77981d..97d02af36f--- a/resources/lang/en_US/email.php+++ b/resources/lang/en_US/email.php@@@ -33,13 -33,8 +33,17 @@@ return'admin_test_subject' => 'A test message from your Firefly III installation','admin_test_body' => 'This is a test message from your Firefly III instance. It was sent to :email.',+ // invite+ 'invitation_created_subject' => 'An invitation has been created',+ 'invitation_created_body' => 'Admin user ":email" created a user invitation which can be used by whoever is behind email address ":invitee". The invite will be valid for 48hrs.',++ 'invite_user_subject' => 'You\'ve been invited to create a Firefly III account.',++ 'invitation_introduction' => 'You\'ve been invited to create a Firefly III account on **:host**. Firefly III is a personal, self-hosted, private personal finance manager. All the cool kids are using it.',++ 'invitation_invited_by' => 'You\'ve been invited by ":admin" and this invitation was sent to ":invitee". That\'s you, right?',++ 'invitation_url' => 'The invitation is valid for 48 hours and can be redeemed by surfing to [Firefly III](:url). Enjoy!',+// new IP'login_from_new_ip' => 'New login on Firefly III',+ 'slack_login_from_new_ip' => 'New Firefly III login from IP :ip (:host)','new_ip_body' => 'Firefly III detected a new login on your account from an unknown IP address. If you never logged in from the IP address below, or it has been more than six months ago, Firefly III will warn you.','new_ip_warning' => 'If you recognize this IP address or the login, you can ignore this message. If you didn\'t login, of if you have no idea what this is about, verify your password security, change it, and log out all other sessions. To do this, go to your profile page. Of course you have 2FA enabled already, right? Stay safe!','ip_address' => 'IP address',diff --cc resources/lang/en_US/firefly.phpindex b3321b00c7,755842b29d..9698373633--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@@ -1325,19 -1007,10 +1325,25 @@@ return'optional_field_attachments' => 'Attachments','optional_field_meta_data' => 'Optional meta data','external_url' => 'External URL',+ 'pref_notification_bill_reminder' => 'Reminder about expiring bills',+ 'pref_notification_new_access_token' => 'Alert when a new API access token is created',+ 'pref_notification_transaction_creation' => 'Alert when a transaction is created automatically',+ 'pref_notification_user_login' => 'Alert when you login from a new location',+ 'pref_notifications' => 'Notifications',+ 'pref_notifications_help' => 'Indicate if these are notifications you would like to get. Some notifications may contain sensitive financial information.',+ 'slack_webhook_url' => 'Slack Webhook URL',+ 'slack_webhook_url_help' => 'If you want Firefly III to notify you using Slack, enter the webhook URL here. Otherwise leave the field blank. If you are an admin, you need to set this URL in the administration as well.',+ 'slack_url_label' => 'Slack "incoming webhook" URL',// profile:-- 'delete_stuff_header' => 'Delete data',-- 'permanent_delete_stuff' => 'Be careful with these buttons. Deleting stuff is permanent.',++ 'purge_data_title' => 'Purge data from Firefly III',++ 'purge_data_expl' => '"Purging" means "deleting that which is already deleted". In normal circumstances, Firefly III deletes nothing permanently. It just hides it. This can be annoying when you import data from other sources, as removed transactions will still be recognized as possible duplicates. The button below deletes all of these previously "deleted" records FOREVER.',++ 'delete_stuff_header' => 'Delete and purge data',++ 'purge_all_data' => 'Purge all deleted records',++ 'purge_data' => 'Purge data',++ 'purged_all_records' => 'All deleted records have been purged.',++ 'delete_data_title' => 'Delete data from Firefly III',++ 'permanent_delete_stuff' => 'You can delete stuff from Firefly III. Using the buttons below means that your items will be removed from view and hidden. There is no undo-button for this, but the items may remain in the database where you can salvage them if necessary.','other_sessions_logged_out' => 'All your other sessions have been logged out.','delete_all_budgets' => 'Delete ALL your budgets','delete_all_categories' => 'Delete ALL your categories',@@@ -2221,71 -1893,55 +2227,72 @@@'updated_tag' => 'Updated tag ":tag"','created_tag' => 'Tag ":tag" has been created!',- 'transaction_journal_information' => 'Transaction information',- 'transaction_journal_meta' => 'Meta information',- 'transaction_journal_more' => 'More information',- 'basic_journal_information' => 'Basic transaction information',- 'transaction_journal_extra' => 'Extra information',- 'att_part_of_journal' => 'Stored under ":journal"',- 'total_amount' => 'Total amount',- 'number_of_decimals' => 'Number of decimals',+ 'transaction_journal_information' => 'Transaction information',+ 'transaction_journal_meta' => 'Meta information',+ 'transaction_journal_more' => 'More information',+ 'basic_journal_information' => 'Basic transaction information',+ 'transaction_journal_extra' => 'Extra information',+ 'att_part_of_journal' => 'Stored under ":journal"',+ 'total_amount' => 'Total amount',+ 'number_of_decimals' => 'Number of decimals',// administration- 'administration' => 'Administration',- 'user_administration' => 'User administration',- 'list_all_users' => 'All users',- 'all_users' => 'All users',- 'instance_configuration' => 'Configuration',- 'firefly_instance_configuration' => 'Configuration options for Firefly III',- 'setting_single_user_mode' => 'Single user mode',- 'setting_single_user_mode_explain' => 'By default, Firefly III only accepts one (1) registration: you. This is a security measure, preventing others from using your instance unless you allow them to. Future registrations are blocked. When you uncheck this box, others can use your instance as well, assuming they can reach it (when it is connected to the internet).',- 'store_configuration' => 'Store configuration',- 'single_user_administration' => 'User administration for :email',- 'edit_user' => 'Edit user :email',- 'hidden_fields_preferences' => 'You can enable more transaction options in your <a href="preferences">preferences</a>.',- 'user_data_information' => 'User data',- 'user_information' => 'User information',- 'total_size' => 'total size',- 'budget_or_budgets' => ':count budget|:count budgets',- 'budgets_with_limits' => ':count budget with configured amount|:count budgets with configured amount',- 'nr_of_rules_in_total_groups' => ':count_rules rule(s) in :count_groups rule group(s)',- 'tag_or_tags' => ':count tag|:count tags',- 'configuration_updated' => 'The configuration has been updated',- 'setting_is_demo_site' => 'Demo site',- 'setting_is_demo_site_explain' => 'If you check this box, this installation will behave as if it is the demo site, which can have weird side effects.',- 'block_code_bounced' => 'Email message(s) bounced',- 'block_code_expired' => 'Demo account expired',- 'no_block_code' => 'No reason for block or user not blocked',- 'block_code_email_changed' => 'User has not yet confirmed new email address',- 'admin_update_email' => 'Contrary to the profile page, the user will NOT be notified their email address has changed!',- 'update_user' => 'Update user',- 'updated_user' => 'User data has been changed.',- 'delete_user' => 'Delete user :email',- 'user_deleted' => 'The user has been deleted',- 'send_test_email' => 'Send test email message',- 'send_test_email_text' => 'To see if your installation is capable of sending email, please press this button. You will not see an error here (if any), <strong>the log files will reflect any errors</strong>. You can press this button as many times as you like. There is no spam control. The message will be sent to <code>:email</code> and should arrive shortly.',- 'send_message' => 'Send message',- 'send_test_triggered' => 'Test was triggered. Check your inbox and the log files.',- 'give_admin_careful' => 'Users who are given admin rights can take away yours. Be careful.',- 'admin_maintanance_title' => 'Maintenance',- 'admin_maintanance_expl' => 'Some nifty buttons for Firefly III maintenance',- 'admin_maintenance_clear_cache' => 'Clear cache',+ 'invite_new_user_title' => 'Invite new user',+ 'invite_new_user_text' => 'As an administrator, you can invite users to register on your Firefly III administration. Using the direct link you can share with them, they will be able to register an account. The invited user and their invite link will appear in the table below. You are free to share the invitation link with them.',+ 'invited_user_mail' => 'Email address',+ 'invite_user' => 'Invite user',+ 'user_is_invited' => 'Email address ":address" was invited to Firefly III',+ 'administration' => 'Administration',+ 'code_already_used' => 'Invite code has been used',+ 'user_administration' => 'User administration',+ 'list_all_users' => 'All users',+ 'all_users' => 'All users',+ 'instance_configuration' => 'Configuration',+ 'firefly_instance_configuration' => 'Configuration options for Firefly III',+ 'setting_single_user_mode' => 'Single user mode',+ 'setting_single_user_mode_explain' => 'By default, Firefly III only accepts one (1) registration: you. This is a security measure, preventing others from using your instance unless you allow them to. Future registrations are blocked. When you uncheck this box, others can use your instance as well, assuming they can reach it (when it is connected to the internet).',+ 'store_configuration' => 'Store configuration',+ 'single_user_administration' => 'User administration for :email',+ 'edit_user' => 'Edit user :email',+ 'hidden_fields_preferences' => 'You can enable more transaction options in your <a href="preferences">preferences</a>.',+ 'user_data_information' => 'User data',+ 'user_information' => 'User information',+ 'total_size' => 'total size',+ 'budget_or_budgets' => ':count budget|:count budgets',+ 'budgets_with_limits' => ':count budget with configured amount|:count budgets with configured amount',+ 'nr_of_rules_in_total_groups' => ':count_rules rule(s) in :count_groups rule group(s)',+ 'tag_or_tags' => ':count tag|:count tags',+ 'configuration_updated' => 'The configuration has been updated',+ 'setting_is_demo_site' => 'Demo site',+ 'setting_is_demo_site_explain' => 'If you check this box, this installation will behave as if it is the demo site, which can have weird side effects.',+ 'block_code_bounced' => 'Email message(s) bounced',+ 'block_code_expired' => 'Demo account expired',+ 'no_block_code' => 'No reason for block or user not blocked',+ 'block_code_email_changed' => 'User has not yet confirmed new email address',+ 'admin_update_email' => 'Contrary to the profile page, the user will NOT be notified their email address has changed!',+ 'update_user' => 'Update user',+ 'updated_user' => 'User data has been changed.',+ 'delete_user' => 'Delete user :email',+ 'user_deleted' => 'The user has been deleted',+ 'send_test_email' => 'Send test email message',+ 'send_test_email_text' => 'To see if your installation is capable of sending email or posting Slack messages, please press this button. You will not see an error here (if any), <strong>the log files will reflect any errors</strong>. You can press this button as many times as you like. There is no spam control. The message will be sent to <code>:email</code> and should arrive shortly.',+ 'send_message' => 'Send message',+ 'send_test_triggered' => 'Test was triggered. Check your inbox and the log files.',+ 'give_admin_careful' => 'Users who are given admin rights can take away yours. Be careful.',+ 'admin_maintanance_title' => 'Maintenance',+ 'admin_maintanance_expl' => 'Some nifty buttons for Firefly III maintenance',+ 'admin_maintenance_clear_cache' => 'Clear cache',+ 'admin_notifications' => 'Admin notifications',+ 'admin_notifications_expl' => 'The following notifications can be enabled or disabled by the administrator. If you want to get these messages over Slack as well, set the "incoming webhook" URL.',+ 'admin_notification_check_user_new_reg' => 'User gets post-registration welcome message',+ 'admin_notification_check_admin_new_reg' => 'Administrator(s) get new user registration notification',+ 'admin_notification_check_new_version' => 'A new version is available',+ 'admin_notification_check_invite_created' => 'A user is invited to Firefly III',+ 'admin_notification_check_invite_redeemed' => 'A user invitation is redeemed',++ 'all_invited_users' => 'All invited users',+ 'save_notification_settings' => 'Save settings',+ 'notification_settings_saved' => 'The notification settings have been saved',+'split_transaction_title' => 'Description of the split transaction','split_transaction_title_help' => 'If you create a split transaction, there must be a global description for all splits of the transaction.',diff --cc resources/views/emails/invitation.blade.phpindex 0000000000,0000000000..7f6cd99445new file mode 100644--- /dev/null+++ b/resources/views/emails/invitation.blade.php@@@ -1,0 -1,0 +1,8 @@@++@component('mail::message')++{{ trans('email.invitation_introduction', ['host' => $host]) }}++++{{ trans('email.invitation_invited_by', ['invitee' => $invitee, 'admin' => $admin]) }}++++{{ trans('email.invitation_url', ['url' => $url]) }}++++@endcomponentdiff --cc resources/views/profile/index.twigindex f9e91e6fef,f9e91e6fef..11a56516cd--- a/resources/views/profile/index.twig+++ b/resources/views/profile/index.twig@@@ -13,7 -13,7 +13,8 @@@<!-- Nav tabs --><ul class="nav nav-tabs" role="tablist"><li role="presentation" class="active">-- <a href="{{ route('profile.index') }}#options" aria-controls="home" role="tab" data-toggle="tab">{{ 'options'|_ }}</a>++ <a href="{{ route('profile.index') }}#options" aria-controls="home" role="tab"++ data-toggle="tab">{{ 'options'|_ }}</a></li><li role="presentation"><a href="#cmd" aria-controls="profile" role="tab" data-toggle="tab">{{ 'command_line_token'|_ }}</a>@@@ -22,14 -22,14 +23,16 @@@<a href="#oauth" aria-controls="messages" role="tab" data-toggle="tab">{{ 'oauth'|_ }}</a></li>{% if true == isInternalAuth and true == isInternalIdentity %}-- <li role="presentation">-- <a href="#mfa" aria-controls="settings" role="tab" data-toggle="tab">{{ 'pref_two_factor_auth'|_ }}</a>-- </li>++ <li role="presentation">++ <a href="#mfa" aria-controls="settings" role="tab"++ data-toggle="tab">{{ 'pref_two_factor_auth'|_ }}</a>++ </li>{% endif %}{% if true == isInternalAuth and true == isInternalIdentity %}-- <li role="presentation">-- <a href="#delete" aria-controls="settings" role="tab" data-toggle="tab">{{ 'delete_stuff_header'|_ }}</a>-- </li>++ <li role="presentation">++ <a href="#delete" aria-controls="settings" role="tab"++ data-toggle="tab">{{ 'delete_stuff_header'|_ }}</a>++ </li>{% endif %}</ul><div class="tab-content">@@@ -45,23 -45,23 +48,24 @@@<div class="col-lg-6"><ul>{% if true == isInternalAuth and true == isInternalIdentity %}-- <li>-- <a href="{{ route('profile.change-email') }}">{{ 'change_your_email'|_ }}</a>-- </li>-- <li>-- <a href="{{ route('profile.change-password') }}">{{ 'change_your_password'|_ }}</a>-- </li>++ <li>++ <a href="{{ route('profile.change-email') }}">{{ 'change_your_email'|_ }}</a>++ </li>++ <li>++ <a href="{{ route('profile.change-password') }}">{{ 'change_your_password'|_ }}</a>++ </li>{% endif %}-- <li><a href="{{ route('logout') }}" class="logout-link">{{ 'logout'|_ }}</a></li>++ <li><a href="{{ route('logout') }}" class="logout-link">{{ 'logout'|_ }}</a>++ </li>{% if true == isInternalAuth and true == isInternalIdentity %}-- <li>-- <a href="{{ route('profile.logout-others') }}">{{ 'logout_other_sessions'|_ }}</a>-- </li>-- <li><a class="text-danger"-- href="{{ route('profile.delete-account') }}">{{ 'delete_account'|_ }}</a>-- </li>++ <li>++ <a href="{{ route('profile.logout-others') }}">{{ 'logout_other_sessions'|_ }}</a>++ </li>++ <li><a class="text-danger"++ href="{{ route('profile.delete-account') }}">{{ 'delete_account'|_ }}</a>++ </li>{% endif %}</ul></div>@@@ -102,153 -102,153 +106,181 @@@</div>{% if true == isInternalAuth and true == isInternalIdentity %}-- <!-- MFA -->-- <div role="tabpanel" class="tab-pane" id="mfa">-- <div class="box box-default">-- <div class="box-body">-- <p class="text-info">{{ 'pref_two_factor_auth_help'|_ }}</p>-- {% if enabled2FA == true %}-- <p class="text-info">-- {{ trans_choice('firefly.pref_two_factor_backup_code_count', mfaBackupCount) }}-- </p>---- <div class="btn-group">-- <a class="btn btn-info" href="{{ route('profile.code') }}">-- <span class="fa fa-recycle"></span>-- {{ 'pref_two_factor_auth_reset_code'|_ }}</a>-- </div>-- <form method="post" action="{{ route('profile.delete-code') }}">-- <input type="hidden" name="_token" value="{{ csrf_token() }}" />-- <input class="btn btn-danger" style="margin-top:20px;" type="submit" name="submit" value="{{ 'pref_two_factor_auth_disable_2fa'|_ }}" />-- </form>-- <form method="post" action="{{ route('profile.new-backup-codes') }}">-- <input type="hidden" name="_token" value="{{ csrf_token() }}" />-- <input class="btn btn-default" style="margin-top:20px;" type="submit" name="submit" value="{{ 'pref_two_factor_new_backup_codes'|_ }}" />-- </form>-- {% else %}-- <form action="{{ route('profile.enable2FA') }}" method="post">-- <input type="hidden" name="_token" value="{{ csrf_token() }}"/>-- <button type="submit" class="btn btn-info"><span-- class="fa fa-lock"></span> {{ 'pref_enable_two_factor_auth'|_ }}</button>-- </form>-- {% endif %}++ <!-- MFA -->++ <div role="tabpanel" class="tab-pane" id="mfa">++ <div class="box box-default">++ <div class="box-body">++ <p class="text-info">{{ 'pref_two_factor_auth_help'|_ }}</p>++ {% if enabled2FA == true %}++ <p class="text-info">++ {{ trans_choice('firefly.pref_two_factor_backup_code_count', mfaBackupCount) }}++ </p>++++ <div class="btn-group">++ <a class="btn btn-info" href="{{ route('profile.code') }}">++ <span class="fa fa-recycle"></span>++ {{ 'pref_two_factor_auth_reset_code'|_ }}</a>++ </div>++ <form method="post" action="{{ route('profile.delete-code') }}">++ <input type="hidden" name="_token" value="{{ csrf_token() }}"/>++ <input class="btn btn-danger" style="margin-top:20px;" type="submit"++ name="submit" value="{{ 'pref_two_factor_auth_disable_2fa'|_ }}"/>++ </form>++ <form method="post" action="{{ route('profile.new-backup-codes') }}">++ <input type="hidden" name="_token" value="{{ csrf_token() }}"/>++ <input class="btn btn-default" style="margin-top:20px;" type="submit"++ name="submit" value="{{ 'pref_two_factor_new_backup_codes'|_ }}"/>++ </form>++ {% else %}++ <form action="{{ route('profile.enable2FA') }}" method="post">++ <input type="hidden" name="_token" value="{{ csrf_token() }}"/>++ <button type="submit" class="btn btn-info"><span++ class="fa fa-lock"></span> {{ 'pref_enable_two_factor_auth'|_ }}++ </button>++ </form>++ {% endif %}++ </div></div></div>-- </div>{% endif %}-- <!-- delete stuff -->++ <!-- purge stuff --><div role="tabpanel" class="tab-pane" id="delete"><div class="box box-default">++ <div class="box-header with-border">++ <h3 class="box-title">{{ 'purge_data_title'|_ }}</h3>++ </div><div class="box-body with-border"><div class="col-lg-12">++ <p class="text-info">++ {{ 'purge_data_expl'|_ }}++ </p><p>++ <button type="button"++ data-success="{{ trans('firefly.purged_all_records')|escape('html') }}"++ data-type="purge" class="confirm btn btn-danger btn-sm"><span++ class="fa fa-trash"></span> {{ 'purge_all_data'|_ }}</button>++++ </p>++++ </div>++ </div>++ </div>++ <!-- delete stuff -->++ <div class="box box-default">++ <div class="box-header with-border">++ <h3 class="box-title">{{ 'delete_data_title'|_ }}</h3>++ </div>++ <div class="box-body with-border">++ <div class="col-lg-12">++ <p class="text-info">{{ 'permanent_delete_stuff'|_ }}</p><h4>{{ 'financial_control'|_ }}</h4>-- <p>++ <div class="btn-group"><button type="button"data-success="{{ trans('firefly.deleted_all_budgets')|escape('html') }}"-- data-type="budgets" class="confirm btn btn-danger btn-sm"><span++ data-type="budgets" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-pie-chart"></span> {{ 'delete_all_budgets'|_ }}</button><button type="button"data-success="{{ trans('firefly.deleted_all_bills')|escape('html') }}"-- data-type="bills" class="confirm btn btn-danger btn-sm"><span++ data-type="bills" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-calendar-o"></span> {{ 'delete_all_bills'|_ }}</button><button type="button"data-success="{{ trans('firefly.deleted_all_piggy_banks')|escape('html') }}"-- data-type="piggy_banks" class="confirm btn btn-danger btn-sm"><span++ data-type="piggy_banks" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-bullseye"></span> {{ 'delete_all_piggy_banks'|_ }}</button>-- </p>++ </div><h4>{{ 'automation'|_ }}</h4>-- <p>++ <div class="btn-group"><button type="button"data-success="{{ trans('firefly.deleted_all_rules')|escape('html') }}"-- data-type="rules" class="confirm btn btn-danger btn-sm"><span++ data-type="rules" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-random"></span> {{ 'delete_all_rules'|_ }}</button><button type="button"data-success="{{ trans('firefly.deleted_all_recurring')|escape('html') }}"-- data-type="recurring" class="confirm btn btn-danger btn-sm"><span-- class="fa fa-paint-brush"></span> {{ 'delete_all_recurring'|_ }}</button>-- </p>++ data-type="recurring" class="confirm btn btn-warning btn-sm"><span++ class="fa fa-paint-brush"></span> {{ 'delete_all_recurring'|_ }}++ </button>++ </div><h4>{{ 'classification'|_ }}</h4>-- <p>++ <div class="btn-group"><button type="button"data-success="{{ trans('firefly.deleted_all_categories')|escape('html') }}"-- data-type="categories" class="confirm btn btn-danger btn-sm"><span++ data-type="categories" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-bookmark"></span> {{ 'delete_all_categories'|_ }}</button><button type="button"data-success="{{ trans('firefly.deleted_all_tags')|escape('html') }}"-- data-type="tags" class="confirm btn btn-danger btn-sm"><span++ data-type="tags" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-tag"></span> {{ 'delete_all_tags'|_ }}</button><button type="button"data-success="{{ trans('firefly.deleted_all_object_groups')|escape('html') }}"-- data-type="object_groups" class="confirm btn btn-danger btn-sm"><span-- class="fa fa-envelope-o"></span> {{ 'delete_all_object_groups'|_ }}</button>-- </p>++ data-type="object_groups" class="confirm btn btn-warning btn-sm"><span++ class="fa fa-envelope-o"></span> {{ 'delete_all_object_groups'|_ }}++ </button>++ </div><h4>{{ 'accounts'|_ }}</h4><p><em class="text-danger">{{ 'also_delete_transactions'|_ }}</em></p>-- <p>++ <div class="btn-group"><button type="button"data-success="{{ trans('firefly.deleted_all_accounts')|escape('html') }}"-- data-type="accounts" class="confirm btn btn-danger btn-sm"><span++ data-type="accounts" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-credit-card"></span> {{ 'delete_all_accounts'|_ }}</button><button type="button"data-success="{{ trans('firefly.deleted_all_asset_accounts')|escape('html') }}"-- data-type="asset_accounts" class="confirm btn btn-danger btn-sm"><span++ data-type="asset_accounts" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-money"></span> {{ 'delete_all_asset_accounts'|_ }}</button><button type="button"data-success="{{ trans('firefly.deleted_all_expense_accounts')|escape('html') }}"-- data-type="expense_accounts" class="confirm btn btn-danger btn-sm"><span-- class="fa fa-shopping-cart"></span> {{ 'delete_all_expense_accounts'|_ }}</button>-- </p>-- <p>++ data-type="expense_accounts" class="confirm btn btn-warning btn-sm"><span++ class="fa fa-shopping-cart"></span> {{ 'delete_all_expense_accounts'|_ }}++ </button><button type="button"data-success="{{ trans('firefly.deleted_all_revenue_accounts')|escape('html') }}"-- data-type="revenue_accounts" class="confirm btn btn-danger btn-sm"><span-- class="fa fa-download"></span> {{ 'delete_all_revenue_accounts'|_ }}</button>++ data-type="revenue_accounts" class="confirm btn btn-warning btn-sm"><span++ class="fa fa-download"></span> {{ 'delete_all_revenue_accounts'|_ }}++ </button><button type="button"data-success="{{ trans('firefly.deleted_all_liabilities')|escape('html') }}"-- data-type="liabilities" class="confirm btn btn-danger btn-sm"><span++ data-type="liabilities" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-ticket"></span> {{ 'delete_all_liabilities'|_ }}</button>-- </p>++ </div><h4>{{ 'transactions'|_ }}</h4>-- <p>++ <div class="btn-group"><button type="button"data-success="{{ trans('firefly.deleted_all_transactions')|escape('html') }}"-- data-type="transactions" class="confirm btn btn-danger btn-sm"><span-- class="fa fa-exchange"></span> {{ 'delete_all_transactions'|_ }}</button>++ data-type="transactions" class="confirm btn btn-warning btn-sm"><span++ class="fa fa-exchange"></span> {{ 'delete_all_transactions'|_ }}++ </button><button type="button"data-success="{{ trans('firefly.deleted_all_withdrawals')|escape('html') }}"-- data-type="withdrawals" class="confirm btn btn-danger btn-sm"><span-- class="fa fa-long-arrow-left"></span> {{ 'delete_all_withdrawals'|_ }}</button>++ data-type="withdrawals" class="confirm btn btn-warning btn-sm"><span++ class="fa fa-long-arrow-left"></span> {{ 'delete_all_withdrawals'|_ }}++ </button><button type="button"data-success="{{ trans('firefly.deleted_all_deposits')|escape('html') }}"-- data-type="deposits" class="confirm btn btn-danger btn-sm"><span-- class="fa fa-long-arrow-right"></span> {{ 'delete_all_deposits'|_ }}</button>------ </p>-- <p>++ data-type="deposits" class="confirm btn btn-warning btn-sm"><span++ class="fa fa-long-arrow-right"></span> {{ 'delete_all_deposits'|_ }}++ </button><button type="button"data-success="{{ trans('firefly.deleted_all_transfers')|escape('html') }}"-- data-type="transfers" class="confirm btn btn-danger btn-sm"><span++ data-type="transfers" class="confirm btn btn-warning btn-sm"><spanclass="fa fa-exchange"></span> {{ 'delete_all_transfers'|_ }}</button>-- </p>++ </div></div></div></div>@@@ -267,6 -267,6 +299,11 @@@$('.confirm').on('click', function (e) {var link = $(e.currentTarget);var classes = link.find('i').attr('class');++ var url = deleteAPIRoute + '?objects=' + link.data('type');++ // different URL for purge route:++ if(link.data('type') === 'purge') {++ url = '{{ route('api.v1.data.purge') }}';++ }// replace icon with loading thinglink.prop('disabled', true);@@@ -275,7 -275,7 +312,7 @@@// call API:$.ajax({method: 'DELETE',-- url: deleteAPIRoute + '?objects=' + link.data('type'),++ url: url,}).done(function () {// enable button again:diff --cc routes/api.phpindex e55133aa1e,8744b83ae2..3d5cfaa0b7--- a/routes/api.php+++ b/routes/api.php@@@ -181,6 -88,6 +181,13 @@@ Route::groupRoute::delete('', ['uses' => 'DestroyController@destroy', 'as' => 'destroy']);});++Route::group(++ ['namespace' => 'FireflyIII\Api\V1\Controllers\Data', 'prefix' => 'v1/data/purge',++ 'as' => 'api.v1.data.',],++ static function () {++ Route::delete('', ['uses' => 'PurgeController@purge', 'as' => 'purge']);++ }++);// Bulk update API routesRoute::group(