Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Remove available budgets endpoints.
James Colec120a908f3c7
diff --git a/app/Api/V1/Controllers/Models/AvailableBudget/DestroyController.php b/app/Api/V1/Controllers/Models/AvailableBudget/DestroyController.phpdeleted file mode 100644index 0297e839c7..0000000000--- a/app/Api/V1/Controllers/Models/AvailableBudget/DestroyController.php+++ /dev/null@@ -1,77 +0,0 @@-<?php-/*- * DestroyController.php- * Copyright (c) 2021 [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/>.- */--declare(strict_types=1);--namespace FireflyIII\Api\V1\Controllers\Models\AvailableBudget;--use FireflyIII\Api\V1\Controllers\Controller;-use FireflyIII\Models\AvailableBudget;-use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;-use FireflyIII\User;-use Illuminate\Http\JsonResponse;--/**- * Class DestroyController- */-class DestroyController extends Controller-{- private AvailableBudgetRepositoryInterface $abRepository;-- /**- * AvailableBudgetController constructor.- *- * @codeCoverageIgnore- */- public function __construct()- {- parent::__construct();- $this->middleware(- function ($request, $next) {- /** @var User $user */- $user = auth()->user();- $this->abRepository = app(AvailableBudgetRepositoryInterface::class);- $this->abRepository->setUser($user);-- return $next($request);- }- );- }-- /**- * This endpoint is documented at:- * https://api-docs.firefly-iii.org/#/available_budgets/listAvailableBudget- *- * Remove the specified resource from storage.- *- * @param AvailableBudget $availableBudget- *- * @codeCoverageIgnore- *- * @return JsonResponse- */- public function destroy(AvailableBudget $availableBudget): JsonResponse- {- $this->abRepository->destroyAvailableBudget($availableBudget);-- return response()->json([], 204);- }-}diff --git a/app/Api/V1/Controllers/Models/AvailableBudget/StoreController.php b/app/Api/V1/Controllers/Models/AvailableBudget/StoreController.phpdeleted file mode 100644index 38deff3b1f..0000000000--- a/app/Api/V1/Controllers/Models/AvailableBudget/StoreController.php+++ /dev/null@@ -1,105 +0,0 @@-<?php-/*- * StoreController.php- * Copyright (c) 2021 [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/>.- */--declare(strict_types=1);--namespace FireflyIII\Api\V1\Controllers\Models\AvailableBudget;--use FireflyIII\Api\V1\Controllers\Controller;-use FireflyIII\Api\V1\Requests\Models\AvailableBudget\Request;-use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Factory\TransactionCurrencyFactory;-use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;-use FireflyIII\Transformers\AvailableBudgetTransformer;-use FireflyIII\User;-use Illuminate\Http\JsonResponse;-use JsonException;-use League\Fractal\Resource\Item;--/**- * Class StoreController- */-class StoreController extends Controller-{- private AvailableBudgetRepositoryInterface $abRepository;-- /**- * AvailableBudgetController constructor.- *- * @codeCoverageIgnore- */- public function __construct()- {- parent::__construct();- $this->middleware(- function ($request, $next) {- /** @var User $user */- $user = auth()->user();- $this->abRepository = app(AvailableBudgetRepositoryInterface::class);- $this->abRepository->setUser($user);-- return $next($request);- }- );- }-- /**- * This endpoint is documented at:- * https://api-docs.firefly-iii.org/#/available_budgets/storeAvailableBudget- *- * Store a newly created resource in storage.- *- * @param Request $request- *- * @return JsonResponse- * @throws FireflyException- * @throws JsonException- */- public function store(Request $request): JsonResponse- {- $data = $request->getAll();- $data['start']->startOfDay();- $data['end']->endOfDay();-- // currency is not mandatory:- if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {- $factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);- $data['currency_id'] = $currency->id;- unset($data['currency_code']);- }- if (!array_key_exists('currency_id', $data)) {- $currency = app('amount')->getDefaultCurrencyByUser(auth()->user());- $data['currency_id'] = $currency->id;- }-- $availableBudget = $this->abRepository->store($data);- $manager = $this->getManager();-- /** @var AvailableBudgetTransformer $transformer */- $transformer = app(AvailableBudgetTransformer::class);- $transformer->setParameters($this->parameters);-- $resource = new Item($availableBudget, $transformer, 'available_budgets');-- return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);- }-}diff --git a/app/Api/V1/Controllers/Models/AvailableBudget/UpdateController.php b/app/Api/V1/Controllers/Models/AvailableBudget/UpdateController.phpdeleted file mode 100644index bb0969260c..0000000000--- a/app/Api/V1/Controllers/Models/AvailableBudget/UpdateController.php+++ /dev/null@@ -1,100 +0,0 @@-<?php-/*- * UpdateController.php- * Copyright (c) 2021 [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/>.- */--declare(strict_types=1);--namespace FireflyIII\Api\V1\Controllers\Models\AvailableBudget;--use FireflyIII\Api\V1\Controllers\Controller;-use FireflyIII\Api\V1\Requests\Models\AvailableBudget\Request;-use FireflyIII\Factory\TransactionCurrencyFactory;-use FireflyIII\Models\AvailableBudget;-use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;-use FireflyIII\Transformers\AvailableBudgetTransformer;-use FireflyIII\User;-use Illuminate\Http\JsonResponse;-use League\Fractal\Resource\Item;--/**- * Class UpdateController- */-class UpdateController extends Controller-{- private AvailableBudgetRepositoryInterface $abRepository;-- /**- * AvailableBudgetController constructor.- *- * @codeCoverageIgnore- */- public function __construct()- {- parent::__construct();- $this->middleware(- function ($request, $next) {- /** @var User $user */- $user = auth()->user();- $this->abRepository = app(AvailableBudgetRepositoryInterface::class);- $this->abRepository->setUser($user);-- return $next($request);- }- );- }-- /**- * This endpoint is documented at:- * https://api-docs.firefly-iii.org/#/available_budgets/updateAvailableBudget- *- * Update the specified resource in storage.- *- * @param Request $request- * @param AvailableBudget $availableBudget- *- * @return JsonResponse- */- public function update(Request $request, AvailableBudget $availableBudget): JsonResponse- {- $data = $request->getAll();-- // find and validate currency ID- if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {- $factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null) ?? app('amount')->getDefaultCurrency();- $currency->enabled = true;- $currency->save();- unset($data['currency_code']);- $data['currency_id'] = $currency->id;- }-- $this->abRepository->updateAvailableBudget($availableBudget, $data);- $manager = $this->getManager();-- /** @var AvailableBudgetTransformer $transformer */- $transformer = app(AvailableBudgetTransformer::class);- $transformer->setParameters($this->parameters);-- $resource = new Item($availableBudget, $transformer, 'available_budgets');-- return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);-- }-}diff --git a/routes/api.php b/routes/api.phpindex bdefc598cf..e55133aa1e 100644--- a/routes/api.php+++ b/routes/api.php@@ -331,10 +331,10 @@ Route::group(static function () {Route::get('', ['uses' => 'ShowController@index', 'as' => 'index']);- Route::post('', ['uses' => 'StoreController@store', 'as' => 'store']);+ //Route::post('', ['uses' => 'StoreController@store', 'as' => 'store']);Route::get('{availableBudget}', ['uses' => 'ShowController@show', 'as' => 'show']);- Route::put('{availableBudget}', ['uses' => 'UpdateController@update', 'as' => 'update']);- Route::delete('{availableBudget}', ['uses' => 'DestroyController@destroy', 'as' => 'delete']);+ //Route::put('{availableBudget}', ['uses' => 'UpdateController@update', 'as' => 'update']);+ //Route::delete('{availableBudget}', ['uses' => 'DestroyController@destroy', 'as' => 'delete']);});