mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Various code cleanup.
This commit is contained in:
		| @@ -13,7 +13,6 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Amount; | ||||
| use Carbon\Carbon; | ||||
| use ExpandedForm; | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| @@ -73,7 +72,7 @@ class AccountController extends Controller | ||||
|         $repository         = app(CurrencyRepositoryInterface::class); | ||||
|         $allCurrencies      = $repository->get(); | ||||
|         $currencySelectList = ExpandedForm::makeSelectList($allCurrencies); | ||||
|         $defaultCurrency    = Amount::getDefaultCurrency(); | ||||
|         $defaultCurrency    = app('amount')->getDefaultCurrency(); | ||||
|         $subTitleIcon       = config('firefly.subIconsByIdentifier.' . $what); | ||||
|         $subTitle           = trans('firefly.make_new_' . $what . '_account'); | ||||
|         $roles              = []; | ||||
| @@ -244,6 +243,7 @@ class AccountController extends Controller | ||||
|  | ||||
|     /** | ||||
|      * Show an account. | ||||
|      * | ||||
|      * @param Request                    $request | ||||
|      * @param JournalRepositoryInterface $repository | ||||
|      * @param Account                    $account | ||||
|   | ||||
| @@ -17,8 +17,8 @@ namespace FireflyIII\Http\Controllers\Admin; | ||||
| use FireflyIII\Events\AdminRequestedTestMessage; | ||||
| use FireflyIII\Http\Controllers\Controller; | ||||
| use Illuminate\Http\Request; | ||||
| use Session; | ||||
| use Log; | ||||
| use Session; | ||||
|  | ||||
| /** | ||||
|  * Class HomeController | ||||
| @@ -49,6 +49,7 @@ class HomeController extends Controller | ||||
|         Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress)); | ||||
|         event(new AdminRequestedTestMessage(auth()->user(), $ipAddress)); | ||||
|         Session::flash('info', strval(trans('firefly.send_test_triggered'))); | ||||
|  | ||||
|         return redirect(route('admin.index')); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,6 @@ declare(strict_types=1); | ||||
| namespace FireflyIII\Http\Controllers\Auth; | ||||
|  | ||||
| use FireflyConfig; | ||||
| use FireflyIII\Events\UserChangedEmail; | ||||
| use FireflyIII\Http\Controllers\Controller; | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Cookie\CookieJar; | ||||
|   | ||||
| @@ -13,7 +13,6 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Amount; | ||||
| use Carbon\Carbon; | ||||
| use FireflyIII\Helpers\Collector\JournalCollectorInterface; | ||||
| use FireflyIII\Http\Requests\BillFormRequest; | ||||
| @@ -131,7 +130,7 @@ class BillController extends Controller | ||||
|             $this->rememberPreviousUri('bills.edit.uri'); | ||||
|         } | ||||
|  | ||||
|         $currency         = Amount::getDefaultCurrency(); | ||||
|         $currency         = app('amount')->getDefaultCurrency(); | ||||
|         $bill->amount_min = round($bill->amount_min, $currency->decimal_places); | ||||
|         $bill->amount_max = round($bill->amount_max, $currency->decimal_places); | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,6 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Amount; | ||||
| use Carbon\Carbon; | ||||
| use Exception; | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| @@ -199,7 +198,7 @@ class BudgetController extends Controller | ||||
|         $periodStart       = $start->formatLocalized($this->monthAndDayFormat); | ||||
|         $periodEnd         = $end->formatLocalized($this->monthAndDayFormat); | ||||
|         $budgetInformation = $this->repository->collectBudgetInformation($budgets, $start, $end); | ||||
|         $defaultCurrency   = Amount::getDefaultCurrency(); | ||||
|         $defaultCurrency   = app('amount')->getDefaultCurrency(); | ||||
|         $available         = $this->repository->getAvailableBudget($defaultCurrency, $start, $end); | ||||
|         $spent             = array_sum(array_column($budgetInformation, 'spent')); | ||||
|         $budgeted          = array_sum(array_column($budgetInformation, 'budgeted')); | ||||
| @@ -268,7 +267,7 @@ class BudgetController extends Controller | ||||
|                 'earned'    => '0', | ||||
|                 'suggested' => '0', | ||||
|             ]; | ||||
|             $currency = Amount::getDefaultCurrency(); | ||||
|             $currency = app('amount')->getDefaultCurrency(); | ||||
|             $range    = Preferences::get('viewRange', '1M')->data; | ||||
|             $begin    = Navigation::subtractPeriod($start, $range, 3); | ||||
|  | ||||
| @@ -380,7 +379,7 @@ class BudgetController extends Controller | ||||
|     { | ||||
|         $start           = Carbon::createFromFormat('Y-m-d', $request->string('start')); | ||||
|         $end             = Carbon::createFromFormat('Y-m-d', $request->string('end')); | ||||
|         $defaultCurrency = Amount::getDefaultCurrency(); | ||||
|         $defaultCurrency = app('amount')->getDefaultCurrency(); | ||||
|         $amount          = $request->get('amount'); | ||||
|  | ||||
|         $this->repository->setAvailableBudget($defaultCurrency, $start, $end, $amount); | ||||
| @@ -515,7 +514,7 @@ class BudgetController extends Controller | ||||
|      */ | ||||
|     public function updateIncome(Carbon $start, Carbon $end) | ||||
|     { | ||||
|         $defaultCurrency = Amount::getDefaultCurrency(); | ||||
|         $defaultCurrency = app('amount')->getDefaultCurrency(); | ||||
|         $available       = $this->repository->getAvailableBudget($defaultCurrency, $start, $end); | ||||
|         $available       = round($available, $defaultCurrency->decimal_places); | ||||
|  | ||||
|   | ||||
| @@ -238,8 +238,8 @@ class CategoryController extends Controller | ||||
|             $subTitle = trans('firefly.all_journals_for_category', ['name' => $category->name]); | ||||
|             $first    = $repository->firstUseDate($category); | ||||
|             /** @var Carbon $start */ | ||||
|             $start    = is_null($first) ? new Carbon : $first; | ||||
|             $end      = new Carbon; | ||||
|             $start = is_null($first) ? new Carbon : $first; | ||||
|             $end   = new Carbon; | ||||
|         } | ||||
|  | ||||
|         // prep for "specific date" view. | ||||
| @@ -257,7 +257,7 @@ class CategoryController extends Controller | ||||
|         // prep for current period | ||||
|         if (strlen($moment) === 0) { | ||||
|             /** @var Carbon $start */ | ||||
|             $start    = clone session('start', Navigation::startOfPeriod(new Carbon, $range)); | ||||
|             $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range)); | ||||
|             /** @var Carbon $end */ | ||||
|             $end      = clone session('end', Navigation::endOfPeriod(new Carbon, $range)); | ||||
|             $periods  = $this->getPeriodOverview($category); | ||||
|   | ||||
| @@ -44,7 +44,7 @@ class Controller extends BaseController | ||||
|     protected $monthAndDayFormat; | ||||
|     /** @var string */ | ||||
|     protected $monthFormat; | ||||
|     /** @var string  */ | ||||
|     /** @var string */ | ||||
|     protected $redirectUri = '/'; | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -153,12 +153,12 @@ class HomeController extends Controller | ||||
|     public function routes() | ||||
|     { | ||||
|         $set    = RouteFacade::getRoutes(); | ||||
|         $ignore = ['chart.', 'javascript.', 'json.', 'report-data.', 'popup.', 'debugbar.','attachments.download', 'attachments.preview', | ||||
|                    'bills.rescan','budgets.income','currencies.def','error','flush','help.show','import.file', | ||||
|                    'login','logout','password.reset','profile.confirm-email-change','profile.undo-email-change', | ||||
|                    'register','report.options','routes','rule-groups.down','rule-groups.up','rules.up','rules.down', | ||||
|                    'rules.select','search.search','test-flash','transactions.link.delete','transactions.link.switch', | ||||
|                    'two-factor.lost','report.options' | ||||
|         $ignore = ['chart.', 'javascript.', 'json.', 'report-data.', 'popup.', 'debugbar.', 'attachments.download', 'attachments.preview', | ||||
|                    'bills.rescan', 'budgets.income', 'currencies.def', 'error', 'flush', 'help.show', 'import.file', | ||||
|                    'login', 'logout', 'password.reset', 'profile.confirm-email-change', 'profile.undo-email-change', | ||||
|                    'register', 'report.options', 'routes', 'rule-groups.down', 'rule-groups.up', 'rules.up', 'rules.down', | ||||
|                    'rules.select', 'search.search', 'test-flash', 'transactions.link.delete', 'transactions.link.switch', | ||||
|                    'two-factor.lost', 'report.options', | ||||
|  | ||||
|         ]; | ||||
|  | ||||
|   | ||||
| @@ -79,7 +79,7 @@ class BankController extends Controller | ||||
|             return redirect(route('import.bank.form', [$bank])); | ||||
|         } | ||||
|         $remoteAccounts = array_keys($remoteAccounts); | ||||
|         $class = config(sprintf('firefly.import_pre.%s', $bank)); | ||||
|         $class          = config(sprintf('firefly.import_pre.%s', $bank)); | ||||
|         // get import file | ||||
|  | ||||
|         // get import config | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Amount; | ||||
| use Carbon\Carbon; | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Models\Account; | ||||
| @@ -90,17 +89,17 @@ class JavascriptController extends Controller | ||||
|     public function variables(Request $request) | ||||
|     { | ||||
|         $localeconv                = localeconv(); | ||||
|         $accounting                = Amount::getJsConfig($localeconv); | ||||
|         $accounting                = app('amount')->getJsConfig($localeconv); | ||||
|         $localeconv                = localeconv(); | ||||
|         $defaultCurrency           = Amount::getDefaultCurrency(); | ||||
|         $defaultCurrency           = app('amount')->getDefaultCurrency(); | ||||
|         $localeconv['frac_digits'] = $defaultCurrency->decimal_places; | ||||
|         $pref                      = Preferences::get('language', config('firefly.default_language', 'en_US')); | ||||
|         $lang                      = $pref->data; | ||||
|         $dateRange                 = $this->getDateRangeConfig(); | ||||
|  | ||||
|         $data = [ | ||||
|             'currencyCode'    => Amount::getCurrencyCode(), | ||||
|             'currencySymbol'  => Amount::getCurrencySymbol(), | ||||
|             'currencyCode'    => app('amount')->getCurrencyCode(), | ||||
|             'currencySymbol'  => app('amount')->getCurrencySymbol(), | ||||
|             'accounting'      => $accounting, | ||||
|             'localeconv'      => $localeconv, | ||||
|             'language'        => $lang, | ||||
|   | ||||
| @@ -13,16 +13,10 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Amount; | ||||
| use Carbon\Carbon; | ||||
| use FireflyIII\Helpers\Collector\JournalCollectorInterface; | ||||
| use FireflyIII\Models\TransactionType; | ||||
| use FireflyIII\Repositories\Bill\BillRepositoryInterface; | ||||
| use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | ||||
| use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | ||||
| use FireflyIII\Repositories\Journal\JournalRepositoryInterface; | ||||
| use FireflyIII\Repositories\Tag\TagRepositoryInterface; | ||||
| use FireflyIII\Support\CacheProperties; | ||||
| use Illuminate\Http\Request; | ||||
| use Response; | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,6 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Amount; | ||||
| use Carbon\Carbon; | ||||
| use ExpandedForm; | ||||
| use FireflyIII\Http\Requests\PiggyBankFormRequest; | ||||
| @@ -277,14 +276,14 @@ class PiggyBankController extends Controller | ||||
|     public function postAdd(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) | ||||
|     { | ||||
|         $amount   = $request->get('amount'); | ||||
|         $currency = Amount::getDefaultCurrency(); | ||||
|         $currency = app('amount')->getDefaultCurrency(); | ||||
|         if ($repository->canAddAmount($piggyBank, $amount)) { | ||||
|             $repository->addAmount($piggyBank, $amount); | ||||
|             Session::flash( | ||||
|                 'success', strval( | ||||
|                              trans( | ||||
|                                  'firefly.added_amount_to_piggy', | ||||
|                                  ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name] | ||||
|                                  ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name] | ||||
|                              ) | ||||
|                          ) | ||||
|             ); | ||||
| @@ -296,7 +295,10 @@ class PiggyBankController extends Controller | ||||
|         Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.'); | ||||
|         Session::flash( | ||||
|             'error', strval( | ||||
|                        trans('firefly.cannot_add_amount_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]) | ||||
|                        trans( | ||||
|                            'firefly.cannot_add_amount_piggy', | ||||
|                            ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)] | ||||
|                        ) | ||||
|                    ) | ||||
|         ); | ||||
|  | ||||
| @@ -313,12 +315,16 @@ class PiggyBankController extends Controller | ||||
|     public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank) | ||||
|     { | ||||
|         $amount   = $request->get('amount'); | ||||
|         $currency = Amount::getDefaultCurrency(); | ||||
|         $currency = app('amount')->getDefaultCurrency(); | ||||
|         if ($repository->canRemoveAmount($piggyBank, $amount)) { | ||||
|             $repository->removeAmount($piggyBank, $amount); | ||||
|             Session::flash( | ||||
|                 'success', | ||||
|                 strval(trans('firefly.removed_amount_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name])) | ||||
|                 strval( | ||||
|                     trans( | ||||
|                         'firefly.removed_amount_from_piggy', ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name] | ||||
|                     ) | ||||
|                 ) | ||||
|             ); | ||||
|             Preferences::mark(); | ||||
|  | ||||
| @@ -329,7 +335,10 @@ class PiggyBankController extends Controller | ||||
|  | ||||
|         Session::flash( | ||||
|             'error', strval( | ||||
|                        trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]) | ||||
|                        trans( | ||||
|                            'firefly.cannot_remove_from_piggy', | ||||
|                            ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)] | ||||
|                        ) | ||||
|                    ) | ||||
|         ); | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,6 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Http\Middleware; | ||||
|  | ||||
| use Amount; | ||||
| use App; | ||||
| use Carbon\Carbon; | ||||
| use Closure; | ||||
| @@ -109,7 +108,7 @@ class Range | ||||
|         // save some formats: | ||||
|         $monthAndDayFormat = (string)trans('config.month_and_day'); | ||||
|         $dateTimeFormat    = (string)trans('config.date_time'); | ||||
|         $defaultCurrency   = Amount::getDefaultCurrency(); | ||||
|         $defaultCurrency   = app('amount')->getDefaultCurrency(); | ||||
|  | ||||
|         View::share('monthAndDayFormat', $monthAndDayFormat); | ||||
|         View::share('dateTimeFormat', $dateTimeFormat); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user