From 32a36bbb12a0edaad5dba768905aeadae99dfb8c Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 24 Oct 2023 18:32:24 +0200 Subject: [PATCH] Restore missing methods and fix silly bugs. --- .../Upgrade/UpgradeCurrencyPreferences.php | 2 + app/Factory/TransactionCurrencyFactory.php | 3 +- app/Http/Controllers/CurrencyController.php | 255 ------------------ .../Transaction/EditController.php | 1 - .../TransactionCurrency/CreateController.php | 121 +++++++++ .../TransactionCurrency/DeleteController.php | 127 +++++++++ .../TransactionCurrency/EditController.php | 130 +++++++++ .../TransactionCurrency/IndexController.php | 5 +- .../Currency/CurrencyRepository.php | 5 +- .../Currency/CurrencyRepositoryInterface.php | 1 - app/Support/Amount.php | 2 +- app/Validation/GroupValidation.php | 3 +- ...10_21_113213_add_currency_pivot_tables.php | 8 +- resources/views/currencies/edit.twig | 2 +- routes/web.php | 2 +- .../NavigationCustomEndOfPeriodTest.php | 3 +- 16 files changed, 397 insertions(+), 273 deletions(-) create mode 100644 app/Http/Controllers/TransactionCurrency/CreateController.php create mode 100644 app/Http/Controllers/TransactionCurrency/DeleteController.php create mode 100644 app/Http/Controllers/TransactionCurrency/EditController.php diff --git a/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php index 29c21063f6..2da07ec117 100644 --- a/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php +++ b/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php @@ -1,5 +1,7 @@ whereCode($data['code'])->count(); @@ -63,7 +62,7 @@ class TransactionCurrencyFactory 'code' => $data['code'], 'symbol' => $data['symbol'], 'decimal_places' => $data['decimal_places'], - 'enabled' => $data['enabled'], + 'enabled' => false, ] ); } catch (QueryException $e) { diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index 0d3b332109..203cf27074 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -45,259 +45,4 @@ use Psr\Container\NotFoundExceptionInterface; */ class CurrencyController extends Controller { - protected CurrencyRepositoryInterface $repository; - protected UserRepositoryInterface $userRepository; - - /** - * CurrencyController constructor. - * - - */ - public function __construct() - { - parent::__construct(); - - $this->middleware( - function ($request, $next) { - app('view')->share('title', (string)trans('firefly.currencies')); - app('view')->share('mainTitleIcon', 'fa-usd'); - $this->repository = app(CurrencyRepositoryInterface::class); - $this->userRepository = app(UserRepositoryInterface::class); - - return $next($request); - } - ); - } - - /** - * Create a currency. - * - * @param Request $request - * - * @return Factory|RedirectResponse|Redirector|View - */ - public function create(Request $request) - { - /** @var User $user */ - $user = auth()->user(); - if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); - - return redirect(route('currencies.index')); - } - - $subTitleIcon = 'fa-plus'; - $subTitle = (string)trans('firefly.create_currency'); - - // put previous url in session if not redirect from store (not "create another"). - if (true !== session('currencies.create.fromStore')) { - $this->rememberPreviousUrl('currencies.create.url'); - } - $request->session()->forget('currencies.create.fromStore'); - - Log::channel('audit')->info('Create new currency.'); - - return view('currencies.create', compact('subTitleIcon', 'subTitle')); - } - - - - /** - * Deletes a currency. - * - * @param Request $request - * @param TransactionCurrency $currency - * - * @return Factory|RedirectResponse|Redirector|View - */ - public function delete(Request $request, TransactionCurrency $currency) - { - /** @var User $user */ - $user = auth()->user(); - if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); - Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code)); - - return redirect(route('currencies.index')); - } - - if ($this->repository->currencyInUse($currency)) { - $location = $this->repository->currencyInUseAt($currency); - $message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]); - $request->session()->flash('error', $message); - Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code)); - - return redirect(route('currencies.index')); - } - - // put previous url in session - $this->rememberPreviousUrl('currencies.delete.url'); - $subTitle = (string)trans('form.delete_currency', ['name' => $currency->name]); - Log::channel('audit')->info(sprintf('Visit page to delete currency %s.', $currency->code)); - - return view('currencies.delete', compact('currency', 'subTitle')); - } - - /** - * Destroys a currency. - * - * @param Request $request - * @param TransactionCurrency $currency - * - * @return RedirectResponse|Redirector - */ - public function destroy(Request $request, TransactionCurrency $currency) - { - /** @var User $user */ - $user = auth()->user(); - if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); - Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code)); - - return redirect(route('currencies.index')); - } - - if ($this->repository->currencyInUse($currency)) { - $request->session()->flash('error', (string)trans('firefly.cannot_delete_currency', ['name' => e($currency->name)])); - Log::channel('audit')->info(sprintf('Tried to delete currency %s but is in use.', $currency->code)); - - return redirect(route('currencies.index')); - } - - if ($this->repository->isFallbackCurrency($currency)) { - $request->session()->flash('error', (string)trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)])); - Log::channel('audit')->info(sprintf('Tried to delete currency %s but is FALLBACK.', $currency->code)); - - return redirect(route('currencies.index')); - } - - Log::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code)); - $this->repository->destroy($currency); - - $request->session()->flash('success', (string)trans('firefly.deleted_currency', ['name' => $currency->name])); - - return redirect($this->getPreviousUrl('currencies.delete.url')); - } - - - /** - * Edit a currency. - * - * @param Request $request - * @param TransactionCurrency $currency - * - * @return Factory|RedirectResponse|Redirector|View - */ - public function edit(Request $request, TransactionCurrency $currency) - { - /** @var User $user */ - $user = auth()->user(); - if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); - Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code)); - - return redirect(route('currencies.index')); - } - - $subTitleIcon = 'fa-pencil'; - $subTitle = (string)trans('breadcrumbs.edit_currency', ['name' => $currency->name]); - $currency->symbol = htmlentities($currency->symbol); - - // code to handle active-checkboxes - $hasOldInput = null !== $request->old('_token'); - $preFilled = [ - 'enabled' => $hasOldInput ? (bool)$request->old('enabled') : $currency->enabled, - ]; - - $request->session()->flash('preFilled', $preFilled); - Log::channel('audit')->info('Edit currency.', $currency->toArray()); - - // put previous url in session if not redirect from store (not "return_to_edit"). - if (true !== session('currencies.edit.fromUpdate')) { - $this->rememberPreviousUrl('currencies.edit.url'); - } - $request->session()->forget('currencies.edit.fromUpdate'); - - return view('currencies.edit', compact('currency', 'subTitle', 'subTitleIcon')); - } - - /** - * Store new currency. - * - * @param CurrencyFormRequest $request - * - * @return $this|RedirectResponse|Redirector - */ - public function store(CurrencyFormRequest $request) - { - /** @var User $user */ - $user = auth()->user(); - $data = $request->getCurrencyData(); - if (!$this->userRepository->hasRole($user, 'owner')) { - Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.'); - Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data); - - return redirect($this->getPreviousUrl('currencies.create.url')); - } - - $data['enabled'] = true; - try { - $currency = $this->repository->store($data); - } catch (FireflyException $e) { - Log::error($e->getMessage()); - Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data); - $request->session()->flash('error', (string)trans('firefly.could_not_store_currency')); - $currency = null; - } - $redirect = redirect($this->getPreviousUrl('currencies.create.url')); - - if (null !== $currency) { - $request->session()->flash('success', (string)trans('firefly.created_currency', ['name' => $currency->name])); - Log::channel('audit')->info('Created (POST) currency.', $data); - if (1 === (int)$request->get('create_another')) { - $request->session()->put('currencies.create.fromStore', true); - - $redirect = redirect(route('currencies.create'))->withInput(); - } - } - - return $redirect; - } - - /** - * Updates a currency. - * - * @param CurrencyFormRequest $request - * @param TransactionCurrency $currency - * - * @return RedirectResponse|Redirector - */ - public function update(CurrencyFormRequest $request, TransactionCurrency $currency) - { - /** @var User $user */ - $user = auth()->user(); - $data = $request->getCurrencyData(); - - if (false === $data['enabled'] && $this->repository->currencyInUse($currency)) { - $data['enabled'] = true; - } - if (!$this->userRepository->hasRole($user, 'owner')) { - $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); - Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data); - - return redirect(route('currencies.index')); - } - $currency = $this->repository->update($currency, $data); - Log::channel('audit')->info('Updated (POST) currency.', $data); - $request->session()->flash('success', (string)trans('firefly.updated_currency', ['name' => $currency->name])); - app('preferences')->mark(); - - if (1 === (int)$request->get('return_to_edit')) { - $request->session()->put('currencies.edit.fromUpdate', true); - - return redirect(route('currencies.edit', [$currency->id])); - } - - return redirect($this->getPreviousUrl('currencies.edit.url')); - } } diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php index 42aa53780c..5949af4a02 100644 --- a/app/Http/Controllers/Transaction/EditController.php +++ b/app/Http/Controllers/Transaction/EditController.php @@ -39,7 +39,6 @@ use Illuminate\View\View; */ class EditController extends Controller { - private JournalRepositoryInterface $repository; /** diff --git a/app/Http/Controllers/TransactionCurrency/CreateController.php b/app/Http/Controllers/TransactionCurrency/CreateController.php new file mode 100644 index 0000000000..f293a9dd80 --- /dev/null +++ b/app/Http/Controllers/TransactionCurrency/CreateController.php @@ -0,0 +1,121 @@ +middleware( + function ($request, $next) { + app('view')->share('title', (string)trans('firefly.currencies')); + app('view')->share('mainTitleIcon', 'fa-usd'); + $this->repository = app(CurrencyRepositoryInterface::class); + $this->userRepository = app(UserRepositoryInterface::class); + + return $next($request); + } + ); + } + /** + * Create a currency. + * + * @param Request $request + * + * @return Factory|RedirectResponse|Redirector|View + */ + public function create(Request $request) + { + /** @var User $user */ + $user = auth()->user(); + if (!$this->userRepository->hasRole($user, 'owner')) { + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + + return redirect(route('currencies.index')); + } + + $subTitleIcon = 'fa-plus'; + $subTitle = (string)trans('firefly.create_currency'); + + // put previous url in session if not redirect from store (not "create another"). + if (true !== session('currencies.create.fromStore')) { + $this->rememberPreviousUrl('currencies.create.url'); + } + $request->session()->forget('currencies.create.fromStore'); + + Log::channel('audit')->info('Create new currency.'); + + return view('currencies.create', compact('subTitleIcon', 'subTitle')); + } + + /** + * Store new currency. + * + * @param CurrencyFormRequest $request + * + * @return $this|RedirectResponse|Redirector + */ + public function store(CurrencyFormRequest $request) + { + /** @var User $user */ + $user = auth()->user(); + $data = $request->getCurrencyData(); + if (!$this->userRepository->hasRole($user, 'owner')) { + Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.'); + Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data); + + return redirect($this->getPreviousUrl('currencies.create.url'))->withInput(); + } + + $data['enabled'] = true; + try { + $currency = $this->repository->store($data); + } catch (FireflyException $e) { + Log::error($e->getMessage()); + Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data); + $request->session()->flash('error', (string)trans('firefly.could_not_store_currency')); + $currency = null; + } + $redirect = redirect($this->getPreviousUrl('currencies.create.url')); + + if (null !== $currency) { + $request->session()->flash('success', (string)trans('firefly.created_currency', ['name' => $currency->name])); + Log::channel('audit')->info('Created (POST) currency.', $data); + if (1 === (int)$request->get('create_another')) { + $request->session()->put('currencies.create.fromStore', true); + + $redirect = redirect(route('currencies.create'))->withInput(); + } + } + + return $redirect; + } +} diff --git a/app/Http/Controllers/TransactionCurrency/DeleteController.php b/app/Http/Controllers/TransactionCurrency/DeleteController.php new file mode 100644 index 0000000000..87a1ad2217 --- /dev/null +++ b/app/Http/Controllers/TransactionCurrency/DeleteController.php @@ -0,0 +1,127 @@ +middleware( + function ($request, $next) { + app('view')->share('title', (string)trans('firefly.currencies')); + app('view')->share('mainTitleIcon', 'fa-usd'); + $this->repository = app(CurrencyRepositoryInterface::class); + $this->userRepository = app(UserRepositoryInterface::class); + + return $next($request); + } + ); + } + + + + /** + * Deletes a currency. + * + * @param Request $request + * @param TransactionCurrency $currency + * + * @return Factory|RedirectResponse|Redirector|View + */ + public function delete(Request $request, TransactionCurrency $currency) + { + /** @var User $user */ + $user = auth()->user(); + if (!$this->userRepository->hasRole($user, 'owner')) { + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code)); + + return redirect(route('currencies.index')); + } + + if ($this->repository->currencyInUse($currency)) { + $location = $this->repository->currencyInUseAt($currency); + $message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]); + $request->session()->flash('error', $message); + Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code)); + + return redirect(route('currencies.index')); + } + + // put previous url in session + $this->rememberPreviousUrl('currencies.delete.url'); + $subTitle = (string)trans('form.delete_currency', ['name' => $currency->name]); + Log::channel('audit')->info(sprintf('Visit page to delete currency %s.', $currency->code)); + + return view('currencies.delete', compact('currency', 'subTitle')); + } + + /** + * Destroys a currency. + * + * @param Request $request + * @param TransactionCurrency $currency + * + * @return RedirectResponse|Redirector + */ + public function destroy(Request $request, TransactionCurrency $currency) + { + /** @var User $user */ + $user = auth()->user(); + if (!$this->userRepository->hasRole($user, 'owner')) { + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code)); + + return redirect(route('currencies.index')); + } + + if ($this->repository->currencyInUse($currency)) { + $request->session()->flash('error', (string)trans('firefly.cannot_delete_currency', ['name' => e($currency->name)])); + Log::channel('audit')->info(sprintf('Tried to delete currency %s but is in use.', $currency->code)); + + return redirect(route('currencies.index')); + } + + if ($this->repository->isFallbackCurrency($currency)) { + $request->session()->flash('error', (string)trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)])); + Log::channel('audit')->info(sprintf('Tried to delete currency %s but is FALLBACK.', $currency->code)); + + return redirect(route('currencies.index')); + } + + Log::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code)); + $this->repository->destroy($currency); + + $request->session()->flash('success', (string)trans('firefly.deleted_currency', ['name' => $currency->name])); + + return redirect($this->getPreviousUrl('currencies.delete.url')); + } + +} diff --git a/app/Http/Controllers/TransactionCurrency/EditController.php b/app/Http/Controllers/TransactionCurrency/EditController.php new file mode 100644 index 0000000000..3ffd571991 --- /dev/null +++ b/app/Http/Controllers/TransactionCurrency/EditController.php @@ -0,0 +1,130 @@ +middleware( + function ($request, $next) { + app('view')->share('title', (string)trans('firefly.currencies')); + app('view')->share('mainTitleIcon', 'fa-usd'); + $this->repository = app(CurrencyRepositoryInterface::class); + $this->userRepository = app(UserRepositoryInterface::class); + + return $next($request); + } + ); + } + + /** + * Edit a currency. + * + * @param Request $request + * @param TransactionCurrency $currency + * + * @return Factory|RedirectResponse|Redirector|View + */ + public function edit(Request $request, TransactionCurrency $currency) + { + /** @var User $user */ + $user = auth()->user(); + if (!$this->userRepository->hasRole($user, 'owner')) { + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code)); + + return redirect(route('currencies.index')); + } + + $subTitleIcon = 'fa-pencil'; + $subTitle = (string)trans('breadcrumbs.edit_currency', ['name' => $currency->name]); + $currency->symbol = htmlentities($currency->symbol); + + // is currently enabled (for this user?) + $userCurrencies = $this->repository->get()->pluck('id')->toArray(); + $enabled = in_array($currency->id, $userCurrencies, true); + + // code to handle active-checkboxes + $hasOldInput = null !== $request->old('_token'); + $preFilled = [ + 'enabled' => $hasOldInput ? (bool)$request->old('enabled') : $enabled, + ]; + + $request->session()->flash('preFilled', $preFilled); + Log::channel('audit')->info('Edit currency.', $currency->toArray()); + + // put previous url in session if not redirect from store (not "return_to_edit"). + if (true !== session('currencies.edit.fromUpdate')) { + $this->rememberPreviousUrl('currencies.edit.url'); + } + $request->session()->forget('currencies.edit.fromUpdate'); + + return view('currencies.edit', compact('currency', 'subTitle', 'subTitleIcon')); + } + + + /** + * Updates a currency. + * + * @param CurrencyFormRequest $request + * @param TransactionCurrency $currency + * + * @return RedirectResponse|Redirector + */ + public function update(CurrencyFormRequest $request, TransactionCurrency $currency) + { + /** @var User $user */ + $user = auth()->user(); + $data = $request->getCurrencyData(); + + if (false === $data['enabled'] && $this->repository->currencyInUse($currency)) { + $data['enabled'] = true; + } + + if (!$this->userRepository->hasRole($user, 'owner')) { + $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); + Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data); + + return redirect(route('currencies.index')); + } + $currency = $this->repository->update($currency, $data); + Log::channel('audit')->info('Updated (POST) currency.', $data); + $request->session()->flash('success', (string)trans('firefly.updated_currency', ['name' => $currency->name])); + app('preferences')->mark(); + + if (1 === (int)$request->get('return_to_edit')) { + $request->session()->put('currencies.edit.fromUpdate', true); + + return redirect(route('currencies.edit', [$currency->id])); + } + + return redirect($this->getPreviousUrl('currencies.edit.url')); + } + +} diff --git a/app/Http/Controllers/TransactionCurrency/IndexController.php b/app/Http/Controllers/TransactionCurrency/IndexController.php index 7467b37d0a..2692e8be87 100644 --- a/app/Http/Controllers/TransactionCurrency/IndexController.php +++ b/app/Http/Controllers/TransactionCurrency/IndexController.php @@ -1,4 +1,5 @@ userDefault ? 0 : 1; $enabled = true === $currency->userEnabled ? 0 : 1; - return sprintf('%s-%s-%s',$default, $enabled, $currency->code); + return sprintf('%s-%s-%s', $default, $enabled, $currency->code); } ); @@ -81,7 +82,7 @@ class IndexController extends Controller $isOwner = false; } - return view('currencies.index', compact('currencies', 'isOwner')); + return view('currencies.index', compact('currencies', 'isOwner')); } } diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index f24e90b44b..6f51384b8c 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -546,13 +546,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface */ public function store(array $data): TransactionCurrency { - throw new FireflyException(sprintf('Method "%s" needs a refactor.', __METHOD__)); /** @var TransactionCurrencyFactory $factory */ $factory = app(TransactionCurrencyFactory::class); $result = $factory->create($data); - if (null === $result) { - throw new FireflyException('400004: Could not store new currency.'); + if (true === $data['enabled']) { + $this->user->currencies()->attach($result->id); } return $result; diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.php index 40efbc2608..e1a53d16be 100644 --- a/app/Repositories/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php @@ -37,7 +37,6 @@ use Illuminate\Support\Collection; */ interface CurrencyRepositoryInterface { - /** * Returns the complete set of transactions but needs * no user object. diff --git a/app/Support/Amount.php b/app/Support/Amount.php index c018e502c7..440ff66638 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -110,7 +110,7 @@ class Amount { /** @var User $user */ $user = auth()->user(); - return $user->currencies()->orderBy('code','ASC')->get(); + return $user->currencies()->orderBy('code', 'ASC')->get(); } /** diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.php index 154f36f018..025a5b2d40 100644 --- a/app/Validation/GroupValidation.php +++ b/app/Validation/GroupValidation.php @@ -48,8 +48,7 @@ trait GroupValidation { app('log')->debug(sprintf('Now in %s', __METHOD__)); - $count = Transaction - ::leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id') + $count = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id') ->leftJoin('transaction_groups', 'transaction_groups.id', 'transaction_journals.transaction_group_id') ->where('transaction_journals.transaction_group_id', $transactionGroup->id) ->where('transactions.reconciled', 1)->where('transactions.amount', '<', 0)->count(['transactions.id']); diff --git a/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php b/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php index 214729e075..32a4b9b5dc 100644 --- a/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php +++ b/database/migrations/2023_10_21_113213_add_currency_pivot_tables.php @@ -1,10 +1,12 @@ boolean('user_default')->default(false); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade'); - $table->unique(['user_id', 'transaction_currency_id'],'unique_combo'); + $table->unique(['user_id', 'transaction_currency_id'], 'unique_combo'); }); } catch (QueryException $e) { app('log')->error(sprintf('Could not create table "transaction_currency_user": %s', $e->getMessage())); @@ -40,7 +42,7 @@ return new class extends Migration { $table->boolean('group_default')->default(false); $table->foreign('user_group_id')->references('id')->on('user_groups')->onDelete('cascade'); $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade'); - $table->unique(['user_group_id', 'transaction_currency_id'],'unique_combo'); + $table->unique(['user_group_id', 'transaction_currency_id'], 'unique_combo'); }); } catch (QueryException $e) { app('log')->error(sprintf('Could not create table "transaction_currency_user_group": %s', $e->getMessage())); diff --git a/resources/views/currencies/edit.twig b/resources/views/currencies/edit.twig index 3bd7e52b21..053891d825 100644 --- a/resources/views/currencies/edit.twig +++ b/resources/views/currencies/edit.twig @@ -22,7 +22,7 @@ {{ ExpandedForm.text('symbol', currency.symbol,{'maxlength' : 51}) }} {{ ExpandedForm.text('code', currency.code,{'maxlength' : 51}) }} {{ ExpandedForm.integer('decimal_places', currency.decimal_places,{'maxlength' : 2,'min': 0,'max': 12}) }} - {{ ExpandedForm.checkbox('enabled', currency.enabled) }} + {{ ExpandedForm.checkbox('enabled', null, currency.enabled) }} diff --git a/routes/web.php b/routes/web.php index 17a8fdad55..21c83f3676 100644 --- a/routes/web.php +++ b/routes/web.php @@ -342,7 +342,7 @@ Route::group( Route::post('store', ['uses' => 'CreateController@store', 'as' => 'store']); Route::post('update/{currency}', ['uses' => 'EditController@update', 'as' => 'update']); - Route::post('destroy/{currency}', ['uses' => 'EditController@destroy', 'as' => 'destroy']); + Route::post('destroy/{currency}', ['uses' => 'DeleteController@destroy', 'as' => 'destroy']); } ); diff --git a/tests/integration/Support/NavigationCustomEndOfPeriodTest.php b/tests/integration/Support/NavigationCustomEndOfPeriodTest.php index a7bd3c1652..412b9cf4fc 100644 --- a/tests/integration/Support/NavigationCustomEndOfPeriodTest.php +++ b/tests/integration/Support/NavigationCustomEndOfPeriodTest.php @@ -1,5 +1,7 @@