mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Improve code quality.
This commit is contained in:
		| @@ -231,6 +231,7 @@ class ReconcileController extends Controller | |||||||
|      * @param TransactionJournal $journal |      * @param TransactionJournal $journal | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View |      * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View | ||||||
|  |      * @throws FireflyException | ||||||
|      */ |      */ | ||||||
|     public function show(TransactionJournal $journal) |     public function show(TransactionJournal $journal) | ||||||
|     { |     { | ||||||
| @@ -242,6 +243,9 @@ class ReconcileController extends Controller | |||||||
|  |  | ||||||
|         // get main transaction: |         // get main transaction: | ||||||
|         $transaction = $this->repository->getAssetTransaction($journal); |         $transaction = $this->repository->getAssetTransaction($journal); | ||||||
|  |         if(null === $transaction) { | ||||||
|  |             throw new FireflyException('The transaction data is incomplete. This is probably a bug. Apologies.'); | ||||||
|  |         } | ||||||
|         $account     = $transaction->account; |         $account     = $transaction->account; | ||||||
|  |  | ||||||
|         return view('accounts.reconcile.show', compact('journal', 'subTitle', 'transaction', 'account')); |         return view('accounts.reconcile.show', compact('journal', 'subTitle', 'transaction', 'account')); | ||||||
|   | |||||||
| @@ -294,6 +294,7 @@ class AccountController extends Controller | |||||||
|         $subTitle  = trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]); |         $subTitle  = trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]); | ||||||
|         $chartUri  = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); |         $chartUri  = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]); | ||||||
|         $periods   = $this->getPeriodOverview($account, $end); |         $periods   = $this->getPeriodOverview($account, $end); | ||||||
|  |         /** @var JournalCollectorInterface $collector */ | ||||||
|         $collector = app(JournalCollectorInterface::class); |         $collector = app(JournalCollectorInterface::class); | ||||||
|         $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); |         $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); | ||||||
|         $collector->setRange($start, $end); |         $collector->setRange($start, $end); | ||||||
| @@ -337,6 +338,7 @@ class AccountController extends Controller | |||||||
|         } |         } | ||||||
|         $subTitle  = trans('firefly.all_journals_for_account', ['name' => $account->name]); |         $subTitle  = trans('firefly.all_journals_for_account', ['name' => $account->name]); | ||||||
|         $periods   = new Collection; |         $periods   = new Collection; | ||||||
|  |         /** @var JournalCollectorInterface $collector */ | ||||||
|         $collector = app(JournalCollectorInterface::class); |         $collector = app(JournalCollectorInterface::class); | ||||||
|         $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); |         $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); | ||||||
|         $transactions = $collector->getPaginatedJournals(); |         $transactions = $collector->getPaginatedJournals(); | ||||||
| @@ -475,6 +477,7 @@ class AccountController extends Controller | |||||||
|             $spent = (string)$collector->getJournals()->sum('transaction_amount'); |             $spent = (string)$collector->getJournals()->sum('transaction_amount'); | ||||||
|  |  | ||||||
|             $dateName = app('navigation')->periodShow($currentDate['start'], $currentDate['period']); |             $dateName = app('navigation')->periodShow($currentDate['start'], $currentDate['period']); | ||||||
|  |             /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|             $entries->push( |             $entries->push( | ||||||
|                 [ |                 [ | ||||||
|                     'name'   => $dateName, |                     'name'   => $dateName, | ||||||
|   | |||||||
| @@ -28,7 +28,6 @@ use FireflyIII\Http\Middleware\IsDemoUser; | |||||||
| use FireflyIII\Http\Middleware\IsSandStormUser; | use FireflyIII\Http\Middleware\IsSandStormUser; | ||||||
| use FireflyIII\Http\Requests\ConfigurationRequest; | use FireflyIII\Http\Requests\ConfigurationRequest; | ||||||
| use FireflyIII\Support\Facades\FireflyConfig; | use FireflyIII\Support\Facades\FireflyConfig; | ||||||
| use Redirect; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class ConfigurationController. |  * Class ConfigurationController. | ||||||
| @@ -92,6 +91,6 @@ class ConfigurationController extends Controller | |||||||
|         session()->flash('success', (string)trans('firefly.configuration_updated')); |         session()->flash('success', (string)trans('firefly.configuration_updated')); | ||||||
|         app('preferences')->mark(); |         app('preferences')->mark(); | ||||||
|  |  | ||||||
|         return Redirect::route('admin.configuration.index'); |         return redirect()->route('admin.configuration.index'); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ use FireflyIII\Events\AdminRequestedTestMessage; | |||||||
| use FireflyIII\Http\Controllers\Controller; | use FireflyIII\Http\Controllers\Controller; | ||||||
| use FireflyIII\Http\Middleware\IsDemoUser; | use FireflyIII\Http\Middleware\IsDemoUser; | ||||||
| use FireflyIII\Http\Middleware\IsSandStormUser; | use FireflyIII\Http\Middleware\IsSandStormUser; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Log; | use Log; | ||||||
|  |  | ||||||
| @@ -63,9 +64,11 @@ class HomeController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function testMessage(Request $request) |     public function testMessage(Request $request) | ||||||
|     { |     { | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         $ipAddress = $request->ip(); |         $ipAddress = $request->ip(); | ||||||
|         Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress)); |         Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress)); | ||||||
|         event(new AdminRequestedTestMessage(auth()->user(), $ipAddress)); |         event(new AdminRequestedTestMessage($user, $ipAddress)); | ||||||
|         session()->flash('info', (string)trans('firefly.send_test_triggered')); |         session()->flash('info', (string)trans('firefly.send_test_triggered')); | ||||||
|  |  | ||||||
|         return redirect(route('admin.index')); |         return redirect(route('admin.index')); | ||||||
|   | |||||||
| @@ -85,7 +85,7 @@ class ForgotPasswordController extends Controller | |||||||
|             $request->only('email') |             $request->only('email') | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         if ($response == Password::RESET_LINK_SENT) { |         if ($response === Password::RESET_LINK_SENT) { | ||||||
|             return back()->with('status', trans($response)); |             return back()->with('status', trans($response)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -60,12 +60,9 @@ class LoginController extends Controller | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Handle a login request to the application. |  | ||||||
|      * |  | ||||||
|      * @param Request $request |      * @param Request $request | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response |      * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response|void | ||||||
|      * |  | ||||||
|      * @throws \Illuminate\Validation\ValidationException |      * @throws \Illuminate\Validation\ValidationException | ||||||
|      */ |      */ | ||||||
|     public function login(Request $request) |     public function login(Request $request) | ||||||
| @@ -78,6 +75,8 @@ class LoginController extends Controller | |||||||
|         if ($this->hasTooManyLoginAttempts($request)) { |         if ($this->hasTooManyLoginAttempts($request)) { | ||||||
|             $this->fireLockoutEvent($request); |             $this->fireLockoutEvent($request); | ||||||
|  |  | ||||||
|  |             /** @noinspection PhpInconsistentReturnPointsInspection */ | ||||||
|  |             /** @noinspection PhpVoidFunctionResultUsedInspection */ | ||||||
|             return $this->sendLockoutResponse($request); |             return $this->sendLockoutResponse($request); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -85,6 +84,8 @@ class LoginController extends Controller | |||||||
|             // user is logged in. Save in session if the user requested session to be remembered: |             // user is logged in. Save in session if the user requested session to be remembered: | ||||||
|             $request->session()->put('remember_login', $request->filled('remember')); |             $request->session()->put('remember_login', $request->filled('remember')); | ||||||
|  |  | ||||||
|  |             /** @noinspection PhpInconsistentReturnPointsInspection */ | ||||||
|  |             /** @noinspection PhpVoidFunctionResultUsedInspection */ | ||||||
|             return $this->sendLoginResponse($request); |             return $this->sendLoginResponse($request); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -93,6 +94,8 @@ class LoginController extends Controller | |||||||
|         // user surpasses their maximum number of attempts they will get locked out. |         // user surpasses their maximum number of attempts they will get locked out. | ||||||
|         $this->incrementLoginAttempts($request); |         $this->incrementLoginAttempts($request); | ||||||
|  |  | ||||||
|  |         /** @noinspection PhpInconsistentReturnPointsInspection */ | ||||||
|  |         /** @noinspection PhpVoidFunctionResultUsedInspection */ | ||||||
|         return $this->sendFailedLoginResponse($request); |         return $this->sendFailedLoginResponse($request); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -77,6 +77,7 @@ class RegisterController extends Controller | |||||||
|             return view('error', compact('message')); |             return view('error', compact('message')); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|         $this->validator($request->all())->validate(); |         $this->validator($request->all())->validate(); | ||||||
|  |  | ||||||
|         event(new Registered($user = $this->create($request->all()))); |         event(new Registered($user = $this->create($request->all()))); | ||||||
|   | |||||||
| @@ -77,6 +77,7 @@ class ResetPasswordController extends Controller | |||||||
|             $allowRegistration = false; |             $allowRegistration = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /** @noinspection PhpUndefinedFieldInspection */ | ||||||
|         return view('auth.passwords.reset')->with( |         return view('auth.passwords.reset')->with( | ||||||
|             ['token' => $token, 'email' => $request->email, 'allowRegistration' => $allowRegistration] |             ['token' => $token, 'email' => $request->email, 'allowRegistration' => $allowRegistration] | ||||||
|         ); |         ); | ||||||
|   | |||||||
| @@ -25,6 +25,7 @@ namespace FireflyIII\Http\Controllers\Auth; | |||||||
| use FireflyIII\Exceptions\FireflyException; | use FireflyIII\Exceptions\FireflyException; | ||||||
| use FireflyIII\Http\Controllers\Controller; | use FireflyIII\Http\Controllers\Controller; | ||||||
| use FireflyIII\Http\Requests\TokenFormRequest; | use FireflyIII\Http\Requests\TokenFormRequest; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Cookie\CookieJar; | use Illuminate\Cookie\CookieJar; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Log; | use Log; | ||||||
| @@ -71,6 +72,7 @@ class TwoFactorController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function lostTwoFactor() |     public function lostTwoFactor() | ||||||
|     { |     { | ||||||
|  |         /** @var User $user */ | ||||||
|         $user      = auth()->user(); |         $user      = auth()->user(); | ||||||
|         $siteOwner = env('SITE_OWNER', ''); |         $siteOwner = env('SITE_OWNER', ''); | ||||||
|         $title     = (string)trans('firefly.two_factor_forgot_title'); |         $title     = (string)trans('firefly.two_factor_forgot_title'); | ||||||
|   | |||||||
| @@ -326,6 +326,7 @@ class BillController extends Controller | |||||||
|             $return = 'true'; |             $return = 'true'; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         $group = null; | ||||||
|         // find first rule group, or create one: |         // find first rule group, or create one: | ||||||
|         $count = $this->ruleGroupRepos->count(); |         $count = $this->ruleGroupRepos->count(); | ||||||
|         if (0 === $count) { |         if (0 === $count) { | ||||||
| @@ -336,7 +337,7 @@ class BillController extends Controller | |||||||
|             $group = $this->ruleGroupRepos->store($data); |             $group = $this->ruleGroupRepos->store($data); | ||||||
|         } |         } | ||||||
|         if ($count > 0) { |         if ($count > 0) { | ||||||
|             $group = $this->ruleGroupRepos->getActiveGroups(auth()->user())->first(); |             $group = $this->ruleGroupRepos->getActiveGroups($bill->user)->first(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // redirect to page that will create a new rule. |         // redirect to page that will create a new rule. | ||||||
|   | |||||||
| @@ -298,6 +298,7 @@ class BudgetController extends Controller | |||||||
|  |  | ||||||
|         // select thing for last 12 periods: |         // select thing for last 12 periods: | ||||||
|         $previousLoop = []; |         $previousLoop = []; | ||||||
|  |         /** @var Carbon $previousDate */ | ||||||
|         $previousDate = clone $start; |         $previousDate = clone $start; | ||||||
|         $count        = 0; |         $count        = 0; | ||||||
|         while ($count < 12) { |         while ($count < 12) { | ||||||
| @@ -310,6 +311,7 @@ class BudgetController extends Controller | |||||||
|  |  | ||||||
|         // select thing for next 12 periods: |         // select thing for next 12 periods: | ||||||
|         $nextLoop = []; |         $nextLoop = []; | ||||||
|  |         /** @var Carbon $nextDate */ | ||||||
|         $nextDate = clone $end; |         $nextDate = clone $end; | ||||||
|         $nextDate->addDay(); |         $nextDate->addDay(); | ||||||
|         $count = 0; |         $count = 0; | ||||||
| @@ -368,7 +370,8 @@ class BudgetController extends Controller | |||||||
|         ]; |         ]; | ||||||
|         $currency = app('amount')->getDefaultCurrency(); |         $currency = app('amount')->getDefaultCurrency(); | ||||||
|         $range    = Preferences::get('viewRange', '1M')->data; |         $range    = Preferences::get('viewRange', '1M')->data; | ||||||
|         $begin    = app('navigation')->subtractPeriod($start, $range, 3); |         /** @var Carbon $begin */ | ||||||
|  |         $begin = app('navigation')->subtractPeriod($start, $range, 3); | ||||||
|  |  | ||||||
|         Log::debug(sprintf('Range is %s', $range)); |         Log::debug(sprintf('Range is %s', $range)); | ||||||
|         Log::debug(sprintf('infoIncome begin is %s', $begin->format('Y-m-d'))); |         Log::debug(sprintf('infoIncome begin is %s', $begin->format('Y-m-d'))); | ||||||
| @@ -378,6 +381,7 @@ class BudgetController extends Controller | |||||||
|         $count        = 0; |         $count        = 0; | ||||||
|         $currentStart = clone $begin; |         $currentStart = clone $begin; | ||||||
|         while ($currentStart < $start) { |         while ($currentStart < $start) { | ||||||
|  |  | ||||||
|             Log::debug(sprintf('Loop: currentStart is %s', $currentStart->format('Y-m-d'))); |             Log::debug(sprintf('Loop: currentStart is %s', $currentStart->format('Y-m-d'))); | ||||||
|             $currentEnd   = app('navigation')->endOfPeriod($currentStart, $range); |             $currentEnd   = app('navigation')->endOfPeriod($currentStart, $range); | ||||||
|             $total        = bcadd($total, $this->repository->getAvailableBudget($currency, $currentStart, $currentEnd)); |             $total        = bcadd($total, $this->repository->getAvailableBudget($currency, $currentStart, $currentEnd)); | ||||||
| @@ -441,6 +445,7 @@ class BudgetController extends Controller | |||||||
|         // prep for "specific date" view. |         // prep for "specific date" view. | ||||||
|         if ('all' !== $moment && \strlen($moment) > 0) { |         if ('all' !== $moment && \strlen($moment) > 0) { | ||||||
|             $start    = new Carbon($moment); |             $start    = new Carbon($moment); | ||||||
|  |             /** @var Carbon $end */ | ||||||
|             $end      = app('navigation')->endOfPeriod($start, $range); |             $end      = app('navigation')->endOfPeriod($start, $range); | ||||||
|             $subTitle = trans( |             $subTitle = trans( | ||||||
|                 'firefly.without_budget_between', |                 'firefly.without_budget_between', | ||||||
| @@ -697,6 +702,7 @@ class BudgetController extends Controller | |||||||
|             $set      = $collector->getJournals(); |             $set      = $collector->getJournals(); | ||||||
|             $sum      = (string)($set->sum('transaction_amount') ?? '0'); |             $sum      = (string)($set->sum('transaction_amount') ?? '0'); | ||||||
|             $journals = $set->count(); |             $journals = $set->count(); | ||||||
|  |             /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|             $dateStr  = $date['end']->format('Y-m-d'); |             $dateStr  = $date['end']->format('Y-m-d'); | ||||||
|             $dateName = app('navigation')->periodShow($date['end'], $date['period']); |             $dateName = app('navigation')->periodShow($date['end'], $date['period']); | ||||||
|             $entries->push(['string' => $dateStr, 'name' => $dateName, 'count' => $journals, 'sum' => $sum, 'date' => clone $date['end']]); |             $entries->push(['string' => $dateStr, 'name' => $dateName, 'count' => $journals, 'sum' => $sum, 'date' => clone $date['end']]); | ||||||
|   | |||||||
| @@ -192,7 +192,9 @@ class CategoryController extends Controller | |||||||
|  |  | ||||||
|         // prep for "specific date" view. |         // prep for "specific date" view. | ||||||
|         if ('all' !== $moment && \strlen($moment) > 0) { |         if ('all' !== $moment && \strlen($moment) > 0) { | ||||||
|  |             /** @var Carbon $start */ | ||||||
|             $start    = app('navigation')->startOfPeriod(new Carbon($moment), $range); |             $start    = app('navigation')->startOfPeriod(new Carbon($moment), $range); | ||||||
|  |             /** @var Carbon $end */ | ||||||
|             $end      = app('navigation')->endOfPeriod($start, $range); |             $end      = app('navigation')->endOfPeriod($start, $range); | ||||||
|             $subTitle = trans( |             $subTitle = trans( | ||||||
|                 'firefly.without_category_between', |                 'firefly.without_category_between', | ||||||
| @@ -257,6 +259,7 @@ class CategoryController extends Controller | |||||||
|         // prep for "specific date" view. |         // prep for "specific date" view. | ||||||
|         if ('all' !== $moment && \strlen($moment) > 0) { |         if ('all' !== $moment && \strlen($moment) > 0) { | ||||||
|             $start    = app('navigation')->startOfPeriod(new Carbon($moment), $range); |             $start    = app('navigation')->startOfPeriod(new Carbon($moment), $range); | ||||||
|  |             /** @var Carbon $end */ | ||||||
|             $end      = app('navigation')->endOfPeriod($start, $range); |             $end      = app('navigation')->endOfPeriod($start, $range); | ||||||
|             $subTitle = trans( |             $subTitle = trans( | ||||||
|                 'firefly.journals_in_period_for_category', |                 'firefly.journals_in_period_for_category', | ||||||
| @@ -406,6 +409,7 @@ class CategoryController extends Controller | |||||||
|                 [TransactionType::DEPOSIT] |                 [TransactionType::DEPOSIT] | ||||||
|             ); |             ); | ||||||
|             $earned   = $collector->getJournals()->sum('transaction_amount'); |             $earned   = $collector->getJournals()->sum('transaction_amount'); | ||||||
|  |             /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|             $dateStr  = $date['end']->format('Y-m-d'); |             $dateStr  = $date['end']->format('Y-m-d'); | ||||||
|             $dateName = app('navigation')->periodShow($date['end'], $date['period']); |             $dateName = app('navigation')->periodShow($date['end'], $date['period']); | ||||||
|             $entries->push( |             $entries->push( | ||||||
| @@ -460,6 +464,7 @@ class CategoryController extends Controller | |||||||
|         foreach ($dates as $currentDate) { |         foreach ($dates as $currentDate) { | ||||||
|             $spent    = $this->repository->spentInPeriod(new Collection([$category]), $accounts, $currentDate['start'], $currentDate['end']); |             $spent    = $this->repository->spentInPeriod(new Collection([$category]), $accounts, $currentDate['start'], $currentDate['end']); | ||||||
|             $earned   = $this->repository->earnedInPeriod(new Collection([$category]), $accounts, $currentDate['start'], $currentDate['end']); |             $earned   = $this->repository->earnedInPeriod(new Collection([$category]), $accounts, $currentDate['start'], $currentDate['end']); | ||||||
|  |             /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|             $dateStr  = $currentDate['end']->format('Y-m-d'); |             $dateStr  = $currentDate['end']->format('Y-m-d'); | ||||||
|             $dateName = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); |             $dateName = app('navigation')->periodShow($currentDate['end'], $currentDate['period']); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|  * You should have received a copy of the GNU General Public License |  * You should have received a copy of the GNU General Public License | ||||||
|  * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |  * along with Firefly III. If not, see <http://www.gnu.org/licenses/>. | ||||||
|  */ |  */ | ||||||
|  | /** @noinspection NullPointerExceptionInspection */ | ||||||
| declare(strict_types=1); | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace FireflyIII\Http\Controllers\Chart; | namespace FireflyIII\Http\Controllers\Chart; | ||||||
| @@ -216,6 +217,7 @@ class AccountController extends Controller | |||||||
|         return $this->expenseCategory($account, $start, $end); |         return $this->expenseCategory($account, $start, $end); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Shows the balances for all the user's frontpage accounts. |      * Shows the balances for all the user's frontpage accounts. | ||||||
|      * |      * | ||||||
| @@ -230,6 +232,8 @@ class AccountController extends Controller | |||||||
|         $defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray(); |         $defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray(); | ||||||
|         Log::debug('Default set is ', $defaultSet); |         Log::debug('Default set is ', $defaultSet); | ||||||
|         $frontPage = Preferences::get('frontPageAccounts', $defaultSet); |         $frontPage = Preferences::get('frontPageAccounts', $defaultSet); | ||||||
|  |  | ||||||
|  |  | ||||||
|         Log::debug('Frontpage preference set is ', $frontPage->data); |         Log::debug('Frontpage preference set is ', $frontPage->data); | ||||||
|         if (0 === \count($frontPage->data)) { |         if (0 === \count($frontPage->data)) { | ||||||
|             $frontPage->data = $defaultSet; |             $frontPage->data = $defaultSet; | ||||||
|   | |||||||
| @@ -107,6 +107,7 @@ class BudgetController extends Controller | |||||||
|         $current          = app('navigation')->startOfPeriod($current, $step); |         $current          = app('navigation')->startOfPeriod($current, $step); | ||||||
|  |  | ||||||
|         while ($end >= $current) { |         while ($end >= $current) { | ||||||
|  |             /** @var Carbon $currentEnd */ | ||||||
|             $currentEnd = app('navigation')->endOfPeriod($current, $step); |             $currentEnd = app('navigation')->endOfPeriod($current, $step); | ||||||
|             if ('1Y' === $step) { |             if ('1Y' === $step) { | ||||||
|                 $currentEnd->subDay(); // @codeCoverageIgnore |                 $currentEnd->subDay(); // @codeCoverageIgnore | ||||||
| @@ -182,9 +183,10 @@ class BudgetController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit): JsonResponse |     public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit): JsonResponse | ||||||
|     { |     { | ||||||
|         $cache = new CacheProperties; |         $budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id; | ||||||
|  |         $cache         = new CacheProperties; | ||||||
|         $cache->addProperty($budget->id); |         $cache->addProperty($budget->id); | ||||||
|         $cache->addProperty($budgetLimit->id ?? 0); |         $cache->addProperty($budgetLimitId); | ||||||
|         $cache->addProperty('chart.budget.expense-asset'); |         $cache->addProperty('chart.budget.expense-asset'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get()); // @codeCoverageIgnore | ||||||
| @@ -193,7 +195,7 @@ class BudgetController extends Controller | |||||||
|         /** @var JournalCollectorInterface $collector */ |         /** @var JournalCollectorInterface $collector */ | ||||||
|         $collector = app(JournalCollectorInterface::class); |         $collector = app(JournalCollectorInterface::class); | ||||||
|         $collector->setAllAssetAccounts()->setBudget($budget); |         $collector->setAllAssetAccounts()->setBudget($budget); | ||||||
|         if (null !== $budgetLimit->id) { |         if (null !== $budgetLimit) { | ||||||
|             $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date); |             $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -227,9 +229,10 @@ class BudgetController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit): JsonResponse |     public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit): JsonResponse | ||||||
|     { |     { | ||||||
|  |         $budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id; | ||||||
|         $cache = new CacheProperties; |         $cache = new CacheProperties; | ||||||
|         $cache->addProperty($budget->id); |         $cache->addProperty($budget->id); | ||||||
|         $cache->addProperty($budgetLimit->id ?? 0); |         $cache->addProperty($budgetLimitId); | ||||||
|         $cache->addProperty('chart.budget.expense-category'); |         $cache->addProperty('chart.budget.expense-category'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get()); // @codeCoverageIgnore | ||||||
| @@ -238,7 +241,7 @@ class BudgetController extends Controller | |||||||
|         /** @var JournalCollectorInterface $collector */ |         /** @var JournalCollectorInterface $collector */ | ||||||
|         $collector = app(JournalCollectorInterface::class); |         $collector = app(JournalCollectorInterface::class); | ||||||
|         $collector->setAllAssetAccounts()->setBudget($budget)->withCategoryInformation(); |         $collector->setAllAssetAccounts()->setBudget($budget)->withCategoryInformation(); | ||||||
|         if (null !== $budgetLimit->id) { |         if (null !== $budgetLimit) { | ||||||
|             $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date); |             $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -274,9 +277,10 @@ class BudgetController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit): JsonResponse |     public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit): JsonResponse | ||||||
|     { |     { | ||||||
|  |         $budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id; | ||||||
|         $cache = new CacheProperties; |         $cache = new CacheProperties; | ||||||
|         $cache->addProperty($budget->id); |         $cache->addProperty($budget->id); | ||||||
|         $cache->addProperty($budgetLimit->id ?? 0); |         $cache->addProperty($budgetLimitId); | ||||||
|         $cache->addProperty('chart.budget.expense-expense'); |         $cache->addProperty('chart.budget.expense-expense'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get()); // @codeCoverageIgnore | ||||||
| @@ -285,7 +289,7 @@ class BudgetController extends Controller | |||||||
|         /** @var JournalCollectorInterface $collector */ |         /** @var JournalCollectorInterface $collector */ | ||||||
|         $collector = app(JournalCollectorInterface::class); |         $collector = app(JournalCollectorInterface::class); | ||||||
|         $collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withOpposingAccount(); |         $collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withOpposingAccount(); | ||||||
|         if (null !== $budgetLimit->id) { |         if (null !== $budgetLimit) { | ||||||
|             $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date); |             $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -481,7 +485,9 @@ class BudgetController extends Controller | |||||||
|         $current  = clone $start; |         $current  = clone $start; | ||||||
|         $budgeted = []; |         $budgeted = []; | ||||||
|         while ($current < $end) { |         while ($current < $end) { | ||||||
|  |             /** @var Carbon $currentStart */ | ||||||
|             $currentStart     = app('navigation')->startOfPeriod($current, $range); |             $currentStart     = app('navigation')->startOfPeriod($current, $range); | ||||||
|  |             /** @var Carbon $currentEnd */ | ||||||
|             $currentEnd       = app('navigation')->endOfPeriod($current, $range); |             $currentEnd       = app('navigation')->endOfPeriod($current, $range); | ||||||
|             $budgetLimits     = $this->repository->getBudgetLimits($budget, $currentStart, $currentEnd); |             $budgetLimits     = $this->repository->getBudgetLimits($budget, $currentStart, $currentEnd); | ||||||
|             $index            = $currentStart->format($key); |             $index            = $currentStart->format($key); | ||||||
|   | |||||||
| @@ -191,6 +191,7 @@ class BudgetReportController extends Controller | |||||||
|                     $chartData[$budget->id . '-left']['entries'][$label] = $leftOfLimits[$budgetLimitId]; |                     $chartData[$budget->id . '-left']['entries'][$label] = $leftOfLimits[$budgetLimitId]; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |             /** @var Carbon $currentStart */ | ||||||
|             $currentStart = clone $currentEnd; |             $currentStart = clone $currentEnd; | ||||||
|             $currentStart->addDay(); |             $currentStart->addDay(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -248,6 +248,7 @@ class CategoryReportController extends Controller | |||||||
|                 $chartData[$labelSumIn]['entries'][$label]  = $sumOfIncome[$category->id]; |                 $chartData[$labelSumIn]['entries'][$label]  = $sumOfIncome[$category->id]; | ||||||
|                 $chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$category->id]; |                 $chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$category->id]; | ||||||
|             } |             } | ||||||
|  |             /** @var Carbon $currentStart */ | ||||||
|             $currentStart = clone $currentEnd; |             $currentStart = clone $currentEnd; | ||||||
|             $currentStart->addDay(); |             $currentStart->addDay(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -165,6 +165,7 @@ class ExpenseReportController extends Controller | |||||||
|                 $chartData[$labelSumIn]['entries'][$label]  = $sumOfIncome[$exp->id]; |                 $chartData[$labelSumIn]['entries'][$label]  = $sumOfIncome[$exp->id]; | ||||||
|                 $chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$exp->id]; |                 $chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$exp->id]; | ||||||
|             } |             } | ||||||
|  |             /** @var Carbon $currentStart */ | ||||||
|             $currentStart = clone $currentEnd; |             $currentStart = clone $currentEnd; | ||||||
|             $currentStart->addDay(); |             $currentStart->addDay(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -237,6 +237,7 @@ class TagReportController extends Controller | |||||||
|                 $chartData[$labelSumIn]['entries'][$label]  = $sumOfIncome[$tag->id]; |                 $chartData[$labelSumIn]['entries'][$label]  = $sumOfIncome[$tag->id]; | ||||||
|                 $chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$tag->id]; |                 $chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$tag->id]; | ||||||
|             } |             } | ||||||
|  |             /** @var Carbon $currentStart */ | ||||||
|             $currentStart = clone $currentEnd; |             $currentStart = clone $currentEnd; | ||||||
|             $currentStart->addDay(); |             $currentStart->addDay(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ use FireflyIII\Http\Requests\CurrencyFormRequest; | |||||||
| use FireflyIII\Models\TransactionCurrency; | use FireflyIII\Models\TransactionCurrency; | ||||||
| use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; | use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; | ||||||
| use FireflyIII\Repositories\User\UserRepositoryInterface; | use FireflyIII\Repositories\User\UserRepositoryInterface; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Illuminate\Pagination\LengthAwarePaginator; | use Illuminate\Pagination\LengthAwarePaginator; | ||||||
| use Log; | use Log; | ||||||
| @@ -71,7 +72,9 @@ class CurrencyController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function create(Request $request) |     public function create(Request $request) | ||||||
|     { |     { | ||||||
|         if (!$this->userRepository->hasRole(auth()->user(), 'owner')) { |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); |             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.index')); |             return redirect(route('currencies.index')); | ||||||
| @@ -116,7 +119,9 @@ class CurrencyController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function delete(Request $request, TransactionCurrency $currency) |     public function delete(Request $request, TransactionCurrency $currency) | ||||||
|     { |     { | ||||||
|         if (!$this->userRepository->hasRole(auth()->user(), 'owner')) { |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |             // @codeCoverageIgnoreStart | ||||||
|             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); |             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); | ||||||
|  |  | ||||||
| @@ -146,7 +151,9 @@ class CurrencyController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function destroy(Request $request, TransactionCurrency $currency) |     public function destroy(Request $request, TransactionCurrency $currency) | ||||||
|     { |     { | ||||||
|         if (!$this->userRepository->hasRole(auth()->user(), 'owner')) { |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |             // @codeCoverageIgnoreStart | ||||||
|             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); |             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); | ||||||
|  |  | ||||||
| @@ -175,7 +182,9 @@ class CurrencyController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function edit(Request $request, TransactionCurrency $currency) |     public function edit(Request $request, TransactionCurrency $currency) | ||||||
|     { |     { | ||||||
|         if (!$this->userRepository->hasRole(auth()->user(), 'owner')) { |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |             // @codeCoverageIgnoreStart | ||||||
|             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); |             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); | ||||||
|  |  | ||||||
| @@ -203,6 +212,8 @@ class CurrencyController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function index(Request $request) |     public function index(Request $request) | ||||||
|     { |     { | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|         $page       = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); |         $page       = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); | ||||||
|         $pageSize   = (int)Preferences::get('listPageSize', 50)->data; |         $pageSize   = (int)Preferences::get('listPageSize', 50)->data; | ||||||
|         $collection = $this->repository->get(); |         $collection = $this->repository->get(); | ||||||
| @@ -218,7 +229,7 @@ class CurrencyController extends Controller | |||||||
|  |  | ||||||
|         $defaultCurrency = $this->repository->getCurrencyByPreference(Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR'))); |         $defaultCurrency = $this->repository->getCurrencyByPreference(Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR'))); | ||||||
|         $isOwner         = true; |         $isOwner         = true; | ||||||
|         if (!$this->userRepository->hasRole(auth()->user(), 'owner')) { |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             $request->session()->flash('info', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); |             $request->session()->flash('info', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); | ||||||
|             $isOwner = false; |             $isOwner = false; | ||||||
|         } |         } | ||||||
| @@ -234,7 +245,9 @@ class CurrencyController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function store(CurrencyFormRequest $request) |     public function store(CurrencyFormRequest $request) | ||||||
|     { |     { | ||||||
|         if (!$this->userRepository->hasRole(auth()->user(), 'owner')) { |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |             // @codeCoverageIgnoreStart | ||||||
|             Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.'); |             Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.'); | ||||||
|  |  | ||||||
| @@ -244,17 +257,24 @@ class CurrencyController extends Controller | |||||||
|  |  | ||||||
|         $data     = $request->getCurrencyData(); |         $data     = $request->getCurrencyData(); | ||||||
|         $currency = $this->repository->store($data); |         $currency = $this->repository->store($data); | ||||||
|         $request->session()->flash('success', trans('firefly.created_currency', ['name' => $currency->name])); |         $redirect = redirect($this->getPreviousUri('currencies.create.uri')); | ||||||
|  |         if (null !== $currency) { | ||||||
|  |             $request->session()->flash('success', trans('firefly.created_currency', ['name' => $currency->name])); | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('create_another')) { |             if (1 === (int)$request->get('create_another')) { | ||||||
|             // @codeCoverageIgnoreStart |                 // @codeCoverageIgnoreStart | ||||||
|             $request->session()->put('currencies.create.fromStore', true); |                 $request->session()->put('currencies.create.fromStore', true); | ||||||
|  |  | ||||||
|  |                 $redirect = redirect(route('currencies.create'))->withInput(); | ||||||
|  |                 // @codeCoverageIgnoreEnd | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         if (null === $currency) { | ||||||
|  |             $request->session()->flash('error', trans('firefly.could_not_store_currency')); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.create'))->withInput(); |  | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return redirect($this->getPreviousUri('currencies.create.uri')); |         return $redirect; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -266,7 +286,9 @@ class CurrencyController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function update(CurrencyFormRequest $request, TransactionCurrency $currency) |     public function update(CurrencyFormRequest $request, TransactionCurrency $currency) | ||||||
|     { |     { | ||||||
|         if (!$this->userRepository->hasRole(auth()->user(), 'owner')) { |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |             // @codeCoverageIgnoreStart | ||||||
|             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); |             $request->session()->flash('error', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,6 +31,7 @@ use FireflyIII\Http\Middleware\IsSandStormUser; | |||||||
| use FireflyIII\Models\AccountType; | use FireflyIII\Models\AccountType; | ||||||
| use FireflyIII\Repositories\Account\AccountRepositoryInterface; | use FireflyIII\Repositories\Account\AccountRepositoryInterface; | ||||||
| use FireflyIII\Repositories\Bill\BillRepositoryInterface; | use FireflyIII\Repositories\Bill\BillRepositoryInterface; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\JsonResponse; | use Illuminate\Http\JsonResponse; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
| @@ -118,6 +119,7 @@ class HomeController extends Controller | |||||||
|         $start = session('start', Carbon::now()->startOfMonth()); |         $start = session('start', Carbon::now()->startOfMonth()); | ||||||
|         /** @var Carbon $end */ |         /** @var Carbon $end */ | ||||||
|         $end      = session('end', Carbon::now()->endOfMonth()); |         $end      = session('end', Carbon::now()->endOfMonth()); | ||||||
|  |         /** @noinspection NullPointerExceptionInspection */ | ||||||
|         $accounts = $repository->getAccountsById($frontPage->data); |         $accounts = $repository->getAccountsById($frontPage->data); | ||||||
|         $today    = new Carbon; |         $today    = new Carbon; | ||||||
|  |  | ||||||
| @@ -134,7 +136,9 @@ class HomeController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // fire check update event: |         // fire check update event: | ||||||
|         event(new RequestedVersionCheckStatus(auth()->user())); |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         event(new RequestedVersionCheckStatus($user)); | ||||||
|  |  | ||||||
|         return view( |         return view( | ||||||
|             'index', |             'index', | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ use FireflyIII\Import\Prerequisites\PrerequisitesInterface; | |||||||
| use FireflyIII\Models\ImportJob; | use FireflyIII\Models\ImportJob; | ||||||
| use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; | use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; | ||||||
| use FireflyIII\Repositories\User\UserRepositoryInterface; | use FireflyIII\Repositories\User\UserRepositoryInterface; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\Response as LaravelResponse; | use Illuminate\Http\Response as LaravelResponse; | ||||||
| use Log; | use Log; | ||||||
|  |  | ||||||
| @@ -117,7 +118,7 @@ class IndexController extends Controller | |||||||
|         } |         } | ||||||
|         /** @var PrerequisitesInterface $providerPre */ |         /** @var PrerequisitesInterface $providerPre */ | ||||||
|         $providerPre = app($class); |         $providerPre = app($class); | ||||||
|         $providerPre->setUser(auth()->user()); |         $providerPre->setUser($importJob->user); | ||||||
|  |  | ||||||
|         if (!$providerPre->isComplete()) { |         if (!$providerPre->isComplete()) { | ||||||
|             Log::debug('Job provider prerequisites are not yet filled in. Redirect to prerequisites-page.'); |             Log::debug('Job provider prerequisites are not yet filled in. Redirect to prerequisites-page.'); | ||||||
| @@ -196,10 +197,12 @@ class IndexController extends Controller | |||||||
|     private function getProviders(): array |     private function getProviders(): array | ||||||
|     { |     { | ||||||
|         // get and filter all import routines: |         // get and filter all import routines: | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         /** @var array $config */ |         /** @var array $config */ | ||||||
|         $providerNames = array_keys(config('import.enabled')); |         $providerNames = array_keys(config('import.enabled')); | ||||||
|         $providers     = []; |         $providers     = []; | ||||||
|         $isDemoUser    = $this->userRepository->hasRole(auth()->user(), 'demo'); |         $isDemoUser    = $this->userRepository->hasRole($user, 'demo'); | ||||||
|         $isDebug       = (bool)config('app.debug'); |         $isDebug       = (bool)config('app.debug'); | ||||||
|         foreach ($providerNames as $providerName) { |         foreach ($providerNames as $providerName) { | ||||||
|             //Log::debug(sprintf('Now with provider %s', $providerName)); |             //Log::debug(sprintf('Now with provider %s', $providerName)); | ||||||
| @@ -230,7 +233,7 @@ class IndexController extends Controller | |||||||
|                 //Log::debug('Will not check prerequisites.'); |                 //Log::debug('Will not check prerequisites.'); | ||||||
|                 /** @var PrerequisitesInterface $object */ |                 /** @var PrerequisitesInterface $object */ | ||||||
|                 $object = app($class); |                 $object = app($class); | ||||||
|                 $object->setUser(auth()->user()); |                 $object->setUser($user); | ||||||
|                 $result = $object->isComplete(); |                 $result = $object->isComplete(); | ||||||
|             } |             } | ||||||
|             $providers[$providerName]['prereq_complete'] = $result; |             $providers[$providerName]['prereq_complete'] = $result; | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ use FireflyIII\Http\Controllers\Controller; | |||||||
| use FireflyIII\Import\Prerequisites\PrerequisitesInterface; | use FireflyIII\Import\Prerequisites\PrerequisitesInterface; | ||||||
| use FireflyIII\Models\ImportJob; | use FireflyIII\Models\ImportJob; | ||||||
| use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; | use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Log; | use Log; | ||||||
|  |  | ||||||
| @@ -73,7 +74,7 @@ class PrerequisitesController extends Controller | |||||||
|     { |     { | ||||||
|         // catch impossible status: |         // catch impossible status: | ||||||
|         $allowed = ['new']; |         $allowed = ['new']; | ||||||
|         if (null !== $importJob && !in_array($importJob->status, $allowed, true)) { |         if (null !== $importJob && !\in_array($importJob->status, $allowed, true)) { | ||||||
|             Log::error(sprintf('Job has state "%s" but this Prerequisites::index() only accepts %s', $importJob->status, json_encode($allowed))); |             Log::error(sprintf('Job has state "%s" but this Prerequisites::index() only accepts %s', $importJob->status, json_encode($allowed))); | ||||||
|             session()->flash('error', trans('import.bad_job_status', ['status' => $importJob->status])); |             session()->flash('error', trans('import.bad_job_status', ['status' => $importJob->status])); | ||||||
|  |  | ||||||
| @@ -85,9 +86,11 @@ class PrerequisitesController extends Controller | |||||||
|         if (!class_exists($class)) { |         if (!class_exists($class)) { | ||||||
|             throw new FireflyException(sprintf('No class to handle prerequisites for "%s".', $importProvider)); // @codeCoverageIgnore |             throw new FireflyException(sprintf('No class to handle prerequisites for "%s".', $importProvider)); // @codeCoverageIgnore | ||||||
|         } |         } | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         /** @var PrerequisitesInterface $object */ |         /** @var PrerequisitesInterface $object */ | ||||||
|         $object = app($class); |         $object = app($class); | ||||||
|         $object->setUser(auth()->user()); |         $object->setUser($user); | ||||||
|  |  | ||||||
|         if (null !== $importJob && $object->isComplete()) { |         if (null !== $importJob && $object->isComplete()) { | ||||||
|             // update job: |             // update job: | ||||||
| @@ -139,9 +142,11 @@ class PrerequisitesController extends Controller | |||||||
|         if (!class_exists($class)) { |         if (!class_exists($class)) { | ||||||
|             throw new FireflyException(sprintf('Cannot find class %s', $class)); // @codeCoverageIgnore |             throw new FireflyException(sprintf('Cannot find class %s', $class)); // @codeCoverageIgnore | ||||||
|         } |         } | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         /** @var PrerequisitesInterface $object */ |         /** @var PrerequisitesInterface $object */ | ||||||
|         $object = app($class); |         $object = app($class); | ||||||
|         $object->setUser(auth()->user()); |         $object->setUser($user); | ||||||
|         Log::debug('Going to store entered prerequisites.'); |         Log::debug('Going to store entered prerequisites.'); | ||||||
|         // store post data |         // store post data | ||||||
|         $data   = $request->all(); |         $data   = $request->all(); | ||||||
|   | |||||||
| @@ -48,14 +48,16 @@ class JavascriptController extends Controller | |||||||
|     { |     { | ||||||
|         $accounts   = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); |         $accounts   = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); | ||||||
|         $preference = Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR')); |         $preference = Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR')); | ||||||
|         $default    = $currencyRepository->findByCodeNull($preference->data); |         /** @noinspection NullPointerExceptionInspection */ | ||||||
|  |         $default = $currencyRepository->findByCodeNull($preference->data); | ||||||
|  |  | ||||||
|         $data = ['accounts' => []]; |         $data = ['accounts' => []]; | ||||||
|  |  | ||||||
|         /** @var Account $account */ |         /** @var Account $account */ | ||||||
|         foreach ($accounts as $account) { |         foreach ($accounts as $account) { | ||||||
|             $accountId                    = $account->id; |             $accountId = $account->id; | ||||||
|             $currency                     = (int)$repository->getMetaValue($account, 'currency_id'); |             $currency  = (int)$repository->getMetaValue($account, 'currency_id'); | ||||||
|  |             /** @noinspection NullPointerExceptionInspection */ | ||||||
|             $currency                     = 0 === $currency ? $default->id : $currency; |             $currency                     = 0 === $currency ? $default->id : $currency; | ||||||
|             $entry                        = ['preferredCurrency' => $currency, 'name' => $account->name]; |             $entry                        = ['preferredCurrency' => $currency, 'name' => $account->name]; | ||||||
|             $data['accounts'][$accountId] = $entry; |             $data['accounts'][$accountId] = $entry; | ||||||
| @@ -113,8 +115,9 @@ class JavascriptController extends Controller | |||||||
|         $localeconv                = localeconv(); |         $localeconv                = localeconv(); | ||||||
|         $localeconv['frac_digits'] = $currency->decimal_places; |         $localeconv['frac_digits'] = $currency->decimal_places; | ||||||
|         $pref                      = Preferences::get('language', config('firefly.default_language', 'en_US')); |         $pref                      = Preferences::get('language', config('firefly.default_language', 'en_US')); | ||||||
|         $lang                      = $pref->data; |         /** @noinspection NullPointerExceptionInspection */ | ||||||
|         $dateRange                 = $this->getDateRangeConfig(); |         $lang      = $pref->data; | ||||||
|  |         $dateRange = $this->getDateRangeConfig(); | ||||||
|  |  | ||||||
|         $data = [ |         $data = [ | ||||||
|             'currencyCode'    => $currency->code, |             'currencyCode'    => $currency->code, | ||||||
| @@ -173,7 +176,9 @@ class JavascriptController extends Controller | |||||||
|         $ranges[$index] = [$nextStart, $nextEnd]; |         $ranges[$index] = [$nextStart, $nextEnd]; | ||||||
|  |  | ||||||
|         // today: |         // today: | ||||||
|  |         /** @var Carbon $todayStart */ | ||||||
|         $todayStart = app('navigation')->startOfPeriod($today, $viewRange); |         $todayStart = app('navigation')->startOfPeriod($today, $viewRange); | ||||||
|  |         /** @var Carbon $todayEnd */ | ||||||
|         $todayEnd   = app('navigation')->endOfPeriod($todayStart, $viewRange); |         $todayEnd   = app('navigation')->endOfPeriod($todayStart, $viewRange); | ||||||
|         if ($todayStart->ne($start) || $todayEnd->ne($end)) { |         if ($todayStart->ne($start) || $todayEnd->ne($end)) { | ||||||
|             $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd]; |             $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd]; | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ use FireflyIII\Http\Controllers\Controller; | |||||||
| use FireflyIII\Models\TransactionCurrency; | use FireflyIII\Models\TransactionCurrency; | ||||||
| use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; | use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; | ||||||
| use FireflyIII\Services\Currency\ExchangeRateInterface; | use FireflyIII\Services\Currency\ExchangeRateInterface; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\JsonResponse; | use Illuminate\Http\JsonResponse; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Log; | use Log; | ||||||
| @@ -56,9 +57,11 @@ class ExchangeController extends Controller | |||||||
|             Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d'))); |             Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d'))); | ||||||
|  |  | ||||||
|             // create service: |             // create service: | ||||||
|  |             /** @var User $user */ | ||||||
|  |             $user = auth()->user(); | ||||||
|             /** @var ExchangeRateInterface $service */ |             /** @var ExchangeRateInterface $service */ | ||||||
|             $service = app(ExchangeRateInterface::class); |             $service = app(ExchangeRateInterface::class); | ||||||
|             $service->setUser(auth()->user()); |             $service->setUser($user); | ||||||
|  |  | ||||||
|             // get rate: |             // get rate: | ||||||
|             $rate = $service->getRate($fromCurrency, $toCurrency, $date); |             $rate = $service->getRate($fromCurrency, $toCurrency, $date); | ||||||
|   | |||||||
| @@ -130,12 +130,13 @@ class ReportController extends Controller | |||||||
|         $account = $this->accountRepository->findNull((int)$attributes['accountId']); |         $account = $this->accountRepository->findNull((int)$attributes['accountId']); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         switch (true) { |         switch (true) { | ||||||
|             case BalanceLine::ROLE_DEFAULTROLE === $role && null !== $budget->id: |             case BalanceLine::ROLE_DEFAULTROLE === $role && null !== $budget && null !== $account: | ||||||
|                 // normal row with a budget: |                 // normal row with a budget: | ||||||
|                 $journals = $this->popupHelper->balanceForBudget($budget, $account, $attributes); |                 $journals = $this->popupHelper->balanceForBudget($budget, $account, $attributes); | ||||||
|                 break; |                 break; | ||||||
|             case BalanceLine::ROLE_DEFAULTROLE === $role && null === $budget->id: |             case BalanceLine::ROLE_DEFAULTROLE === $role && null === $budget && null !== $account: | ||||||
|                 // normal row without a budget: |                 // normal row without a budget: | ||||||
|                 $journals     = $this->popupHelper->balanceForNoBudget($account, $attributes); |                 $journals     = $this->popupHelper->balanceForNoBudget($account, $attributes); | ||||||
|                 $budget->name = (string)trans('firefly.no_budget'); |                 $budget->name = (string)trans('firefly.no_budget'); | ||||||
| @@ -160,6 +161,9 @@ class ReportController extends Controller | |||||||
|     private function budgetSpentAmount(array $attributes): string |     private function budgetSpentAmount(array $attributes): string | ||||||
|     { |     { | ||||||
|         $budget   = $this->budgetRepository->findNull((int)$attributes['budgetId']); |         $budget   = $this->budgetRepository->findNull((int)$attributes['budgetId']); | ||||||
|  |         if(null === $budget) { | ||||||
|  |             throw new FireflyException('This is an unknown budget. Apologies.'); | ||||||
|  |         } | ||||||
|         $journals = $this->popupHelper->byBudget($budget, $attributes); |         $journals = $this->popupHelper->byBudget($budget, $attributes); | ||||||
|         $view     = view('popup.report.budget-spent-amount', compact('journals', 'budget'))->render(); |         $view     = view('popup.report.budget-spent-amount', compact('journals', 'budget'))->render(); | ||||||
|  |  | ||||||
| @@ -177,6 +181,11 @@ class ReportController extends Controller | |||||||
|     private function categoryEntry(array $attributes): string |     private function categoryEntry(array $attributes): string | ||||||
|     { |     { | ||||||
|         $category = $this->categoryRepository->findNull((int)$attributes['categoryId']); |         $category = $this->categoryRepository->findNull((int)$attributes['categoryId']); | ||||||
|  |  | ||||||
|  |         if(null === $category) { | ||||||
|  |             throw new FireflyException('This is an unknown category. Apologies.'); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $journals = $this->popupHelper->byCategory($category, $attributes); |         $journals = $this->popupHelper->byCategory($category, $attributes); | ||||||
|         $view     = view('popup.report.category-entry', compact('journals', 'category'))->render(); |         $view     = view('popup.report.category-entry', compact('journals', 'category'))->render(); | ||||||
|  |  | ||||||
| @@ -194,6 +203,11 @@ class ReportController extends Controller | |||||||
|     private function expenseEntry(array $attributes): string |     private function expenseEntry(array $attributes): string | ||||||
|     { |     { | ||||||
|         $account  = $this->accountRepository->findNull((int)$attributes['accountId']); |         $account  = $this->accountRepository->findNull((int)$attributes['accountId']); | ||||||
|  |  | ||||||
|  |         if(null === $account) { | ||||||
|  |             throw new FireflyException('This is an unknown account. Apologies.'); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $journals = $this->popupHelper->byExpenses($account, $attributes); |         $journals = $this->popupHelper->byExpenses($account, $attributes); | ||||||
|         $view     = view('popup.report.expense-entry', compact('journals', 'account'))->render(); |         $view     = view('popup.report.expense-entry', compact('journals', 'account'))->render(); | ||||||
|  |  | ||||||
| @@ -211,6 +225,11 @@ class ReportController extends Controller | |||||||
|     private function incomeEntry(array $attributes): string |     private function incomeEntry(array $attributes): string | ||||||
|     { |     { | ||||||
|         $account  = $this->accountRepository->findNull((int)$attributes['accountId']); |         $account  = $this->accountRepository->findNull((int)$attributes['accountId']); | ||||||
|  |  | ||||||
|  |         if(null === $account) { | ||||||
|  |             throw new FireflyException('This is an unknown category. Apologies.'); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $journals = $this->popupHelper->byIncome($account, $attributes); |         $journals = $this->popupHelper->byIncome($account, $attributes); | ||||||
|         $view     = view('popup.report.income-entry', compact('journals', 'account'))->render(); |         $view     = view('popup.report.income-entry', compact('journals', 'account'))->render(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -58,6 +58,7 @@ class PreferencesController extends Controller | |||||||
|     { |     { | ||||||
|         $accounts           = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); |         $accounts           = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); | ||||||
|         $viewRangePref      = Preferences::get('viewRange', '1M'); |         $viewRangePref      = Preferences::get('viewRange', '1M'); | ||||||
|  |         /** @noinspection NullPointerExceptionInspection */ | ||||||
|         $viewRange          = $viewRangePref->data; |         $viewRange          = $viewRangePref->data; | ||||||
|         $frontPageAccounts  = Preferences::get('frontPageAccounts', []); |         $frontPageAccounts  = Preferences::get('frontPageAccounts', []); | ||||||
|         $language           = Preferences::get('language', config('firefly.default_language', 'en_US'))->data; |         $language           = Preferences::get('language', config('firefly.default_language', 'en_US'))->data; | ||||||
|   | |||||||
| @@ -39,6 +39,7 @@ use FireflyIII\User; | |||||||
| use Google2FA; | use Google2FA; | ||||||
| use Hash; | use Hash; | ||||||
| use Illuminate\Contracts\Auth\Guard; | use Illuminate\Contracts\Auth\Guard; | ||||||
|  | use Illuminate\Support\Collection; | ||||||
| use Laravel\Passport\ClientRepository; | use Laravel\Passport\ClientRepository; | ||||||
| use Laravel\Passport\Passport; | use Laravel\Passport\Passport; | ||||||
| use Log; | use Log; | ||||||
| @@ -123,6 +124,7 @@ class ProfileController extends Controller | |||||||
|     public function confirmEmailChange(UserRepositoryInterface $repository, string $token) |     public function confirmEmailChange(UserRepositoryInterface $repository, string $token) | ||||||
|     { |     { | ||||||
|         // find preference with this token value. |         // find preference with this token value. | ||||||
|  |         /** @var Collection $set */ | ||||||
|         $set  = Preferences::findByName('email_change_confirm_token'); |         $set  = Preferences::findByName('email_change_confirm_token'); | ||||||
|         $user = null; |         $user = null; | ||||||
|         Log::debug(sprintf('Found %d preferences', $set->count())); |         Log::debug(sprintf('Found %d preferences', $set->count())); | ||||||
| @@ -179,7 +181,9 @@ class ProfileController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function enable2FA(UserRepositoryInterface $repository) |     public function enable2FA(UserRepositoryInterface $repository) | ||||||
|     { |     { | ||||||
|         if ($repository->hasRole(auth()->user(), 'demo')) { |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|  |         if ($repository->hasRole($user, 'demo')) { | ||||||
|             return redirect(route('profile.index')); |             return redirect(route('profile.index')); | ||||||
|         } |         } | ||||||
|         $hasTwoFactorAuthSecret = (null !== Preferences::get('twoFactorAuthSecret')); |         $hasTwoFactorAuthSecret = (null !== Preferences::get('twoFactorAuthSecret')); | ||||||
| @@ -217,11 +221,13 @@ class ProfileController extends Controller | |||||||
|         $subTitle   = auth()->user()->email; |         $subTitle   = auth()->user()->email; | ||||||
|         $userId     = auth()->user()->id; |         $userId     = auth()->user()->id; | ||||||
|         $enabled2FA = 1 === (int)Preferences::get('twoFactorAuthEnabled', 0)->data; |         $enabled2FA = 1 === (int)Preferences::get('twoFactorAuthEnabled', 0)->data; | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |  | ||||||
|         // get access token or create one. |         // get access token or create one. | ||||||
|         $accessToken = Preferences::get('access_token', null); |         $accessToken = Preferences::get('access_token', null); | ||||||
|         if (null === $accessToken) { |         if (null === $accessToken) { | ||||||
|             $token       = auth()->user()->generateAccessToken(); |             $token       = $user->generateAccessToken(); | ||||||
|             $accessToken = Preferences::set('access_token', $token); |             $accessToken = Preferences::set('access_token', $token); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -282,21 +288,23 @@ class ProfileController extends Controller | |||||||
|         // the request has already validated both new passwords must be equal. |         // the request has already validated both new passwords must be equal. | ||||||
|         $current = $request->get('current_password'); |         $current = $request->get('current_password'); | ||||||
|         $new     = $request->get('new_password'); |         $new     = $request->get('new_password'); | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         try { |         try { | ||||||
|             $this->validatePassword(auth()->user(), $current, $new); |             $this->validatePassword($user, $current, $new); | ||||||
|         } catch (ValidationException $e) { |         } catch (ValidationException $e) { | ||||||
|             session()->flash('error', $e->getMessage()); |             session()->flash('error', $e->getMessage()); | ||||||
|  |  | ||||||
|             return redirect(route('profile.change-password')); |             return redirect(route('profile.change-password')); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $repository->changePassword(auth()->user(), $request->get('new_password')); |         $repository->changePassword($user, $request->get('new_password')); | ||||||
|         session()->flash('success', (string)trans('firefly.password_changed')); |         session()->flash('success', (string)trans('firefly.password_changed')); | ||||||
|  |  | ||||||
|         return redirect(route('profile.index')); |         return redirect(route('profile.index')); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** @noinspection PhpUnusedParameterInspection */ | ||||||
|     /** |     /** | ||||||
|      * @param TokenFormRequest $request |      * @param TokenFormRequest $request | ||||||
|      * |      * | ||||||
| @@ -326,6 +334,7 @@ class ProfileController extends Controller | |||||||
|  |  | ||||||
|             return redirect(route('profile.delete-account')); |             return redirect(route('profile.delete-account')); | ||||||
|         } |         } | ||||||
|  |         /** @var User $user */ | ||||||
|         $user = auth()->user(); |         $user = auth()->user(); | ||||||
|         Log::info(sprintf('User #%d has opted to delete their account', auth()->user()->id)); |         Log::info(sprintf('User #%d has opted to delete their account', auth()->user()->id)); | ||||||
|         // make repository delete user: |         // make repository delete user: | ||||||
| @@ -341,7 +350,9 @@ class ProfileController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function regenerate() |     public function regenerate() | ||||||
|     { |     { | ||||||
|         $token = auth()->user()->generateAccessToken(); |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|  |         $token = $user->generateAccessToken(); | ||||||
|         Preferences::set('access_token', $token); |         Preferences::set('access_token', $token); | ||||||
|         session()->flash('success', (string)trans('firefly.token_regenerated')); |         session()->flash('success', (string)trans('firefly.token_regenerated')); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -77,11 +77,10 @@ class ReportController extends Controller | |||||||
|      * @param Carbon     $start |      * @param Carbon     $start | ||||||
|      * @param Carbon     $end |      * @param Carbon     $end | ||||||
|      * |      * | ||||||
|      * @return string |      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string | ||||||
|      * |  | ||||||
|      * @throws \FireflyIII\Exceptions\FireflyException |      * @throws \FireflyIII\Exceptions\FireflyException | ||||||
|      */ |      */ | ||||||
|     public function accountReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): string |     public function accountReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore |             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore | ||||||
| @@ -111,11 +110,11 @@ class ReportController extends Controller | |||||||
|      * @param Carbon     $start |      * @param Carbon     $start | ||||||
|      * @param Carbon     $end |      * @param Carbon     $end | ||||||
|      * |      * | ||||||
|      * @return string |      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string | ||||||
|      * |      * | ||||||
|      * @throws \FireflyIII\Exceptions\FireflyException |      * @throws \FireflyIII\Exceptions\FireflyException | ||||||
|      */ |      */ | ||||||
|     public function auditReport(Collection $accounts, Carbon $start, Carbon $end): string |     public function auditReport(Collection $accounts, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore |             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore | ||||||
| @@ -148,11 +147,11 @@ class ReportController extends Controller | |||||||
|      * @param Carbon     $start |      * @param Carbon     $start | ||||||
|      * @param Carbon     $end |      * @param Carbon     $end | ||||||
|      * |      * | ||||||
|      * @return string |      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string | ||||||
|      * |      * | ||||||
|      * @throws \FireflyIII\Exceptions\FireflyException |      * @throws \FireflyIII\Exceptions\FireflyException | ||||||
|      */ |      */ | ||||||
|     public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end): string |     public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore |             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore | ||||||
| @@ -186,11 +185,11 @@ class ReportController extends Controller | |||||||
|      * @param Carbon     $start |      * @param Carbon     $start | ||||||
|      * @param Carbon     $end |      * @param Carbon     $end | ||||||
|      * |      * | ||||||
|      * @return string |      *  @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string | ||||||
|      * |      * | ||||||
|      * @throws \FireflyIII\Exceptions\FireflyException |      * @throws \FireflyIII\Exceptions\FireflyException | ||||||
|      */ |      */ | ||||||
|     public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): string |     public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore |             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore | ||||||
| @@ -223,11 +222,11 @@ class ReportController extends Controller | |||||||
|      * @param Carbon     $start |      * @param Carbon     $start | ||||||
|      * @param Carbon     $end |      * @param Carbon     $end | ||||||
|      * |      * | ||||||
|      * @return string |      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string | ||||||
|      * |      * | ||||||
|      * @throws \FireflyIII\Exceptions\FireflyException |      * @throws \FireflyIII\Exceptions\FireflyException | ||||||
|      */ |      */ | ||||||
|     public function defaultReport(Collection $accounts, Carbon $start, Carbon $end): string |     public function defaultReport(Collection $accounts, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             return view('error')->with('message', trans('firefly.end_after_start_date')); |             return view('error')->with('message', trans('firefly.end_after_start_date')); | ||||||
| @@ -382,11 +381,11 @@ class ReportController extends Controller | |||||||
|      * @param Carbon     $start |      * @param Carbon     $start | ||||||
|      * @param Carbon     $end |      * @param Carbon     $end | ||||||
|      * |      * | ||||||
|      * @return string |      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string | ||||||
|      * |      * | ||||||
|      * @throws \FireflyIII\Exceptions\FireflyException |      * @throws \FireflyIII\Exceptions\FireflyException | ||||||
|      */ |      */ | ||||||
|     public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): string |     public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore |             return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore | ||||||
| @@ -427,7 +426,7 @@ class ReportController extends Controller | |||||||
|         $set        = new Collection; |         $set        = new Collection; | ||||||
|         $names      = $revenue->pluck('name')->toArray(); |         $names      = $revenue->pluck('name')->toArray(); | ||||||
|         foreach ($expense as $exp) { |         foreach ($expense as $exp) { | ||||||
|             if (in_array($exp->name, $names, true)) { |             if (\in_array($exp->name, $names, true)) { | ||||||
|                 $set->push($exp); |                 $set->push($exp); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -38,6 +38,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface; | |||||||
| use FireflyIII\Repositories\Rule\RuleRepositoryInterface; | use FireflyIII\Repositories\Rule\RuleRepositoryInterface; | ||||||
| use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; | use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; | ||||||
| use FireflyIII\TransactionRules\TransactionMatcher; | use FireflyIII\TransactionRules\TransactionMatcher; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\JsonResponse; | use Illuminate\Http\JsonResponse; | ||||||
| use Illuminate\Http\RedirectResponse; | use Illuminate\Http\RedirectResponse; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| @@ -173,9 +174,9 @@ class RuleController extends Controller | |||||||
|      * |      * | ||||||
|      * @param Rule $rule |      * @param Rule $rule | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Http\RedirectResponse |      * @return RedirectResponse | ||||||
|      */ |      */ | ||||||
|     public function destroy(Rule $rule): \Illuminate\Http\RedirectResponse |     public function destroy(Rule $rule): RedirectResponse | ||||||
|     { |     { | ||||||
|         $title = $rule->title; |         $title = $rule->title; | ||||||
|         $this->ruleRepos->destroy($rule); |         $this->ruleRepos->destroy($rule); | ||||||
| @@ -189,7 +190,7 @@ class RuleController extends Controller | |||||||
|     /** |     /** | ||||||
|      * @param Rule $rule |      * @param Rule $rule | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |      * @return RedirectResponse|\Illuminate\Routing\Redirector | ||||||
|      */ |      */ | ||||||
|     public function down(Rule $rule) |     public function down(Rule $rule) | ||||||
|     { |     { | ||||||
| @@ -262,6 +263,8 @@ class RuleController extends Controller | |||||||
|     public function execute(SelectTransactionsRequest $request, Rule $rule): RedirectResponse |     public function execute(SelectTransactionsRequest $request, Rule $rule): RedirectResponse | ||||||
|     { |     { | ||||||
|         // Get parameters specified by the user |         // Get parameters specified by the user | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         $accounts  = $this->accountRepos->getAccountsById($request->get('accounts')); |         $accounts  = $this->accountRepos->getAccountsById($request->get('accounts')); | ||||||
|         $startDate = new Carbon($request->get('start_date')); |         $startDate = new Carbon($request->get('start_date')); | ||||||
|         $endDate   = new Carbon($request->get('end_date')); |         $endDate   = new Carbon($request->get('end_date')); | ||||||
| @@ -270,7 +273,7 @@ class RuleController extends Controller | |||||||
|         $job = new ExecuteRuleOnExistingTransactions($rule); |         $job = new ExecuteRuleOnExistingTransactions($rule); | ||||||
|  |  | ||||||
|         // Apply parameters to the job |         // Apply parameters to the job | ||||||
|         $job->setUser(auth()->user()); |         $job->setUser($user); | ||||||
|         $job->setAccounts($accounts); |         $job->setAccounts($accounts); | ||||||
|         $job->setStartDate($startDate); |         $job->setStartDate($startDate); | ||||||
|         $job->setEndDate($endDate); |         $job->setEndDate($endDate); | ||||||
| @@ -289,9 +292,11 @@ class RuleController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function index() |     public function index() | ||||||
|     { |     { | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         $this->createDefaultRuleGroup(); |         $this->createDefaultRuleGroup(); | ||||||
|         $this->createDefaultRule(); |         $this->createDefaultRule(); | ||||||
|         $ruleGroups = $this->ruleGroupRepos->getRuleGroupsWithRules(auth()->user()); |         $ruleGroups = $this->ruleGroupRepos->getRuleGroupsWithRules($user); | ||||||
|  |  | ||||||
|         return view('rules.index', compact('ruleGroups')); |         return view('rules.index', compact('ruleGroups')); | ||||||
|     } |     } | ||||||
| @@ -346,7 +351,7 @@ class RuleController extends Controller | |||||||
|     /** |     /** | ||||||
|      * @param RuleFormRequest $request |      * @param RuleFormRequest $request | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |      * @return RedirectResponse|\Illuminate\Routing\Redirector | ||||||
|      */ |      */ | ||||||
|     public function store(RuleFormRequest $request) |     public function store(RuleFormRequest $request) | ||||||
|     { |     { | ||||||
| @@ -505,7 +510,7 @@ class RuleController extends Controller | |||||||
|     /** |     /** | ||||||
|      * @param Rule $rule |      * @param Rule $rule | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |      * @return RedirectResponse|\Illuminate\Routing\Redirector | ||||||
|      */ |      */ | ||||||
|     public function up(Rule $rule) |     public function up(Rule $rule) | ||||||
|     { |     { | ||||||
| @@ -518,7 +523,7 @@ class RuleController extends Controller | |||||||
|      * @param RuleFormRequest $request |      * @param RuleFormRequest $request | ||||||
|      * @param Rule            $rule |      * @param Rule            $rule | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |      * @return RedirectResponse|\Illuminate\Routing\Redirector | ||||||
|      */ |      */ | ||||||
|     public function update(RuleFormRequest $request, Rule $rule) |     public function update(RuleFormRequest $request, Rule $rule) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions; | |||||||
| use FireflyIII\Models\RuleGroup; | use FireflyIII\Models\RuleGroup; | ||||||
| use FireflyIII\Repositories\Account\AccountRepositoryInterface; | use FireflyIII\Repositories\Account\AccountRepositoryInterface; | ||||||
| use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; | use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Http\RedirectResponse; | use Illuminate\Http\RedirectResponse; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
|  |  | ||||||
| @@ -95,8 +96,12 @@ class RuleGroupController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function destroy(Request $request, RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup) |     public function destroy(Request $request, RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup) | ||||||
|     { |     { | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user = auth()->user(); | ||||||
|         $title  = $ruleGroup->title; |         $title  = $ruleGroup->title; | ||||||
|         $moveTo = auth()->user()->ruleGroups()->find((int)$request->get('move_rules_before_delete')); |  | ||||||
|  |         /** @var RuleGroup $moveTo */ | ||||||
|  |         $moveTo = $user->ruleGroups()->find((int)$request->get('move_rules_before_delete')); | ||||||
|  |  | ||||||
|         $repository->destroy($ruleGroup, $moveTo); |         $repository->destroy($ruleGroup, $moveTo); | ||||||
|  |  | ||||||
| @@ -157,6 +162,8 @@ class RuleGroupController extends Controller | |||||||
|     public function execute(SelectTransactionsRequest $request, AccountRepositoryInterface $repository, RuleGroup $ruleGroup): RedirectResponse |     public function execute(SelectTransactionsRequest $request, AccountRepositoryInterface $repository, RuleGroup $ruleGroup): RedirectResponse | ||||||
|     { |     { | ||||||
|         // Get parameters specified by the user |         // Get parameters specified by the user | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         $accounts  = $repository->getAccountsById($request->get('accounts')); |         $accounts  = $repository->getAccountsById($request->get('accounts')); | ||||||
|         $startDate = new Carbon($request->get('start_date')); |         $startDate = new Carbon($request->get('start_date')); | ||||||
|         $endDate   = new Carbon($request->get('end_date')); |         $endDate   = new Carbon($request->get('end_date')); | ||||||
| @@ -165,7 +172,7 @@ class RuleGroupController extends Controller | |||||||
|         $job = new ExecuteRuleGroupOnExistingTransactions($ruleGroup); |         $job = new ExecuteRuleGroupOnExistingTransactions($ruleGroup); | ||||||
|  |  | ||||||
|         // Apply parameters to the job |         // Apply parameters to the job | ||||||
|         $job->setUser(auth()->user()); |         $job->setUser($user); | ||||||
|         $job->setAccounts($accounts); |         $job->setAccounts($accounts); | ||||||
|         $job->setStartDate($startDate); |         $job->setStartDate($startDate); | ||||||
|         $job->setEndDate($endDate); |         $job->setEndDate($endDate); | ||||||
|   | |||||||
| @@ -194,6 +194,7 @@ class TagController extends Controller | |||||||
|         // prep for "specific date" view. |         // prep for "specific date" view. | ||||||
|         if ('all' !== $moment && \strlen($moment) > 0) { |         if ('all' !== $moment && \strlen($moment) > 0) { | ||||||
|             $start    = new Carbon($moment); |             $start    = new Carbon($moment); | ||||||
|  |             /** @var Carbon $end */ | ||||||
|             $end      = app('navigation')->endOfPeriod($start, $range); |             $end      = app('navigation')->endOfPeriod($start, $range); | ||||||
|             $subTitle = trans( |             $subTitle = trans( | ||||||
|                 'firefly.journals_in_period_for_tag', |                 'firefly.journals_in_period_for_tag', | ||||||
| @@ -291,6 +292,7 @@ class TagController extends Controller | |||||||
|     { |     { | ||||||
|         // get first and last tag date from tag: |         // get first and last tag date from tag: | ||||||
|         $range = app('preferences')->get('viewRange', '1M')->data; |         $range = app('preferences')->get('viewRange', '1M')->data; | ||||||
|  |         /** @var Carbon $end */ | ||||||
|         $end   = app('navigation')->endOfX($this->repository->lastUseDate($tag), $range, null); |         $end   = app('navigation')->endOfX($this->repository->lastUseDate($tag), $range, null); | ||||||
|         $start = $this->repository->firstUseDate($tag); |         $start = $this->repository->firstUseDate($tag); | ||||||
|  |  | ||||||
| @@ -322,6 +324,7 @@ class TagController extends Controller | |||||||
|             ]; |             ]; | ||||||
|             $collection->push($arr); |             $collection->push($arr); | ||||||
|  |  | ||||||
|  |             /** @var Carbon $currentEnd */ | ||||||
|             $currentEnd = clone $currentStart; |             $currentEnd = clone $currentStart; | ||||||
|             $currentEnd->subDay(); |             $currentEnd->subDay(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -106,7 +106,14 @@ class LinkController extends Controller | |||||||
|  |  | ||||||
|             return redirect(route('transactions.show', [$journal->id])); |             return redirect(route('transactions.show', [$journal->id])); | ||||||
|         } |         } | ||||||
|         $other         = $this->journalRepository->findNull($linkInfo['transaction_journal_id']); |         $other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']); | ||||||
|  |  | ||||||
|  |         if (null === $other) { | ||||||
|  |             session()->flash('error', trans('firefly.invalid_link_selection')); | ||||||
|  |  | ||||||
|  |             return redirect(route('transactions.show', [$journal->id])); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $alreadyLinked = $this->repository->findLink($journal, $other); |         $alreadyLinked = $this->repository->findLink($journal, $other); | ||||||
|  |  | ||||||
|         if ($other->id === $journal->id) { |         if ($other->id === $journal->id) { | ||||||
|   | |||||||
| @@ -35,6 +35,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; | |||||||
| use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | ||||||
| use FireflyIII\Repositories\Journal\JournalRepositoryInterface; | use FireflyIII\Repositories\Journal\JournalRepositoryInterface; | ||||||
| use FireflyIII\Transformers\TransactionTransformer; | use FireflyIII\Transformers\TransactionTransformer; | ||||||
|  | use FireflyIII\User; | ||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
| use Illuminate\View\View as IlluminateView; | use Illuminate\View\View as IlluminateView; | ||||||
| use Symfony\Component\HttpFoundation\ParameterBag; | use Symfony\Component\HttpFoundation\ParameterBag; | ||||||
| @@ -122,8 +123,11 @@ class MassController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function edit(Collection $journals): IlluminateView |     public function edit(Collection $journals): IlluminateView | ||||||
|     { |     { | ||||||
|  |         /** @var User $user */ | ||||||
|  |         $user      = auth()->user(); | ||||||
|         $subTitle = trans('firefly.mass_edit_journals'); |         $subTitle = trans('firefly.mass_edit_journals'); | ||||||
|  |  | ||||||
|  |  | ||||||
|         /** @var AccountRepositoryInterface $repository */ |         /** @var AccountRepositoryInterface $repository */ | ||||||
|         $repository = app(AccountRepositoryInterface::class); |         $repository = app(AccountRepositoryInterface::class); | ||||||
|         $accounts   = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); |         $accounts   = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); | ||||||
| @@ -140,7 +144,7 @@ class MassController extends Controller | |||||||
|         $transformer = new TransactionTransformer(new ParameterBag); |         $transformer = new TransactionTransformer(new ParameterBag); | ||||||
|         /** @var JournalCollectorInterface $collector */ |         /** @var JournalCollectorInterface $collector */ | ||||||
|         $collector = app(JournalCollectorInterface::class); |         $collector = app(JournalCollectorInterface::class); | ||||||
|         $collector->setUser(auth()->user()); |         $collector->setUser($user); | ||||||
|         $collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation(); |         $collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation(); | ||||||
|         $collector->setJournals($journals); |         $collector->setJournals($journals); | ||||||
|         $collector->addFilter(TransactionViewFilter::class); |         $collector->addFilter(TransactionViewFilter::class); | ||||||
| @@ -220,11 +224,6 @@ class MassController extends Controller | |||||||
|                                                 'foreign_amount'        => $foreignAmount, |                                                 'foreign_amount'        => $foreignAmount, | ||||||
|                                                 'foreign_currency_id'   => $foreignCurrencyId, |                                                 'foreign_currency_id'   => $foreignCurrencyId, | ||||||
|                                                 'foreign_currency_code' => null, |                                                 'foreign_currency_code' => null, | ||||||
|                                                 //'native_amount'            => $amount, |  | ||||||
|                                                 //'source_amount'            => $amount, |  | ||||||
|                                                 //'foreign_amount'           => $foreignAmount, |  | ||||||
|                                                 //'destination_amount'       => $foreignAmount, |  | ||||||
|                                                 //'amount'                   => $foreignAmount, |  | ||||||
|                                             ]], |                                             ]], | ||||||
|                         'currency_id'   => $foreignCurrencyId, |                         'currency_id'   => $foreignCurrencyId, | ||||||
|                         'tags'          => $tags, |                         'tags'          => $tags, | ||||||
|   | |||||||
| @@ -266,6 +266,7 @@ class SplitController extends Controller | |||||||
|  |  | ||||||
|         foreach ($old as $index => $row) { |         foreach ($old as $index => $row) { | ||||||
|             if (isset($array[$index])) { |             if (isset($array[$index])) { | ||||||
|  |                 /** @noinspection SlowArrayOperationsInLoopInspection */ | ||||||
|                 $array[$index] = array_merge($array[$index], $row); |                 $array[$index] = array_merge($array[$index], $row); | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -162,9 +162,10 @@ class TransactionController extends Controller | |||||||
|         foreach ($transactionIds as $transactionId) { |         foreach ($transactionIds as $transactionId) { | ||||||
|             $transactionId = (int)$transactionId; |             $transactionId = (int)$transactionId; | ||||||
|             $transaction   = $this->repository->findTransaction($transactionId); |             $transaction   = $this->repository->findTransaction($transactionId); | ||||||
|             Log::debug(sprintf('Transaction ID is %d', $transaction->id)); |             if (null !== $transaction) { | ||||||
|  |                 Log::debug(sprintf('Transaction ID is %d', $transaction->id)); | ||||||
|             $this->repository->reconcile($transaction); |                 $this->repository->reconcile($transaction); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return response()->json(['ok' => 'reconciled']); |         return response()->json(['ok' => 'reconciled']); | ||||||
| @@ -271,11 +272,13 @@ class TransactionController extends Controller | |||||||
|                 $sums     = $this->sumPerCurrency($journals); |                 $sums     = $this->sumPerCurrency($journals); | ||||||
|                 $dateName = app('navigation')->periodShow($currentDate['start'], $currentDate['period']); |                 $dateName = app('navigation')->periodShow($currentDate['start'], $currentDate['period']); | ||||||
|                 $sum      = $journals->sum('transaction_amount'); |                 $sum      = $journals->sum('transaction_amount'); | ||||||
|  |                 /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|                 $entries->push( |                 $entries->push( | ||||||
|                     [ |                     [ | ||||||
|                         'name'  => $dateName, |                         'name'  => $dateName, | ||||||
|                         'sums'  => $sums, |                         'sums'  => $sums, | ||||||
|                         'sum'   => $sum, |                         'sum'   => $sum, | ||||||
|  |  | ||||||
|                         'start' => $currentDate['start']->format('Y-m-d'), |                         'start' => $currentDate['start']->format('Y-m-d'), | ||||||
|                         'end'   => $currentDate['end']->format('Y-m-d'), |                         'end'   => $currentDate['end']->format('Y-m-d'), | ||||||
|                     ] |                     ] | ||||||
|   | |||||||
| @@ -89,9 +89,11 @@ class Authenticate | |||||||
|         if (empty($guards)) { |         if (empty($guards)) { | ||||||
|             try { |             try { | ||||||
|                 // go for default guard: |                 // go for default guard: | ||||||
|  |                 /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|                 if ($this->auth->check()) { |                 if ($this->auth->check()) { | ||||||
|  |  | ||||||
|                     // do an extra check on user object. |                     // do an extra check on user object. | ||||||
|  |                     /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|                     $user = $this->auth->authenticate(); |                     $user = $this->auth->authenticate(); | ||||||
|                     if (1 === (int)$user->blocked) { |                     if (1 === (int)$user->blocked) { | ||||||
|                         $message = (string)trans('firefly.block_account_logout'); |                         $message = (string)trans('firefly.block_account_logout'); | ||||||
| @@ -99,6 +101,7 @@ class Authenticate | |||||||
|                             $message = (string)trans('firefly.email_changed_logout'); |                             $message = (string)trans('firefly.email_changed_logout'); | ||||||
|                         } |                         } | ||||||
|                         app('session')->flash('logoutMessage', $message); |                         app('session')->flash('logoutMessage', $message); | ||||||
|  |                         /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|                         $this->auth->logout(); |                         $this->auth->logout(); | ||||||
|  |  | ||||||
|                         throw new AuthenticationException('Blocked account.', $guards); |                         throw new AuthenticationException('Blocked account.', $guards); | ||||||
| @@ -114,13 +117,14 @@ class Authenticate | |||||||
|                 ); |                 ); | ||||||
|                 // @codeCoverageIgnoreEnd |                 // @codeCoverageIgnoreEnd | ||||||
|             } |             } | ||||||
|  |             /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|             return $this->auth->authenticate(); |             return $this->auth->authenticate(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreStart |         // @codeCoverageIgnoreStart | ||||||
|         foreach ($guards as $guard) { |         foreach ($guards as $guard) { | ||||||
|             if ($this->auth->guard($guard)->check()) { |             if ($this->auth->guard($guard)->check()) { | ||||||
|  |                 /** @noinspection PhpVoidFunctionResultUsedInspection */ | ||||||
|                 return $this->auth->shouldUse($guard); |                 return $this->auth->shouldUse($guard); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -52,6 +52,7 @@ class AuthenticateTwoFactor | |||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     /** @noinspection PhpUnusedParameterInspection */ | ||||||
|     /** |     /** | ||||||
|      * @param         $request |      * @param         $request | ||||||
|      * @param Closure $next |      * @param Closure $next | ||||||
| @@ -63,6 +64,7 @@ class AuthenticateTwoFactor | |||||||
|      */ |      */ | ||||||
|     public function handle($request, Closure $next, ...$guards) |     public function handle($request, Closure $next, ...$guards) | ||||||
|     { |     { | ||||||
|  |         /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|         if ($this->auth->guest()) { |         if ($this->auth->guest()) { | ||||||
|             return response()->redirectTo(route('login')); |             return response()->redirectTo(route('login')); | ||||||
|         } |         } | ||||||
| @@ -70,6 +72,7 @@ class AuthenticateTwoFactor | |||||||
|  |  | ||||||
|         $is2faEnabled = app('preferences')->get('twoFactorAuthEnabled', false)->data; |         $is2faEnabled = app('preferences')->get('twoFactorAuthEnabled', false)->data; | ||||||
|         $has2faSecret = null !== app('preferences')->get('twoFactorAuthSecret'); |         $has2faSecret = null !== app('preferences')->get('twoFactorAuthSecret'); | ||||||
|  |         /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|         $is2faAuthed  = 'true' === $request->cookie('twoFactorAuthenticated'); |         $is2faAuthed  = 'true' === $request->cookie('twoFactorAuthenticated'); | ||||||
|  |  | ||||||
|         if ($is2faEnabled && $has2faSecret && !$is2faAuthed) { |         if ($is2faEnabled && $has2faSecret && !$is2faAuthed) { | ||||||
|   | |||||||
| @@ -54,6 +54,7 @@ class Binder | |||||||
|         $this->auth    = $auth; |         $this->auth    = $auth; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** @noinspection PhpUnusedParameterInspection */ | ||||||
|     /** |     /** | ||||||
|      * Handle an incoming request. |      * Handle an incoming request. | ||||||
|      * |      * | ||||||
| @@ -63,7 +64,6 @@ class Binder | |||||||
|      * |      * | ||||||
|      * @return mixed |      * @return mixed | ||||||
|      * |      * | ||||||
|  |  | ||||||
|      */ |      */ | ||||||
|     public function handle($request, Closure $next, ...$guards) |     public function handle($request, Closure $next, ...$guards) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ declare(strict_types=1); | |||||||
| namespace FireflyIII\Http\Middleware; | namespace FireflyIII\Http\Middleware; | ||||||
|  |  | ||||||
| use Closure; | use Closure; | ||||||
| use FireflyIII\Exceptions\IsDemoUserException; |  | ||||||
| use FireflyIII\Repositories\User\UserRepositoryInterface; | use FireflyIII\Repositories\User\UserRepositoryInterface; | ||||||
| use FireflyIII\User; | use FireflyIII\User; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
|   | |||||||
| @@ -78,6 +78,7 @@ class Range | |||||||
|     private function configureView(): void |     private function configureView(): void | ||||||
|     { |     { | ||||||
|         $pref = Preferences::get('language', config('firefly.default_language', 'en_US')); |         $pref = Preferences::get('language', config('firefly.default_language', 'en_US')); | ||||||
|  |         /** @noinspection NullPointerExceptionInspection */ | ||||||
|         $lang = $pref->data; |         $lang = $pref->data; | ||||||
|         App::setLocale($lang); |         App::setLocale($lang); | ||||||
|         Carbon::setLocale(substr($lang, 0, 2)); |         Carbon::setLocale(substr($lang, 0, 2)); | ||||||
|   | |||||||
| @@ -74,6 +74,7 @@ class Sandstorm | |||||||
|             if (1 === $count && \strlen($userId) > 0) { |             if (1 === $count && \strlen($userId) > 0) { | ||||||
|                 // login as first user user. |                 // login as first user user. | ||||||
|                 $user = $repository->first(); |                 $user = $repository->first(); | ||||||
|  |                 /** @noinspection NullPointerExceptionInspection */ | ||||||
|                 Auth::guard($guard)->login($user); |                 Auth::guard($guard)->login($user); | ||||||
|                 View::share('SANDSTORM_ANON', false); |                 View::share('SANDSTORM_ANON', false); | ||||||
|  |  | ||||||
| @@ -83,6 +84,7 @@ class Sandstorm | |||||||
|             if (1 === $count && '' === $userId) { |             if (1 === $count && '' === $userId) { | ||||||
|                 // login but indicate anonymous |                 // login but indicate anonymous | ||||||
|                 $user = User::first(); |                 $user = User::first(); | ||||||
|  |                 /** @noinspection NullPointerExceptionInspection */ | ||||||
|                 Auth::guard($guard)->login($user); |                 Auth::guard($guard)->login($user); | ||||||
|                 View::share('SANDSTORM_ANON', true); |                 View::share('SANDSTORM_ANON', true); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ class ConfigurationRequest extends Request | |||||||
|     public function authorize(): bool |     public function authorize(): bool | ||||||
|     { |     { | ||||||
|         // Only allow logged in users and admins |         // Only allow logged in users and admins | ||||||
|         return auth()->check() && auth()->user()->hasRole('owner'); |         return auth()->check(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -33,7 +33,7 @@ class LinkTypeFormRequest extends Request | |||||||
|     public function authorize(): bool |     public function authorize(): bool | ||||||
|     { |     { | ||||||
|         // Only allow logged and admins |         // Only allow logged and admins | ||||||
|         return auth()->check() && auth()->user()->hasRole('owner'); |         return auth()->check(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -73,9 +73,9 @@ class FakeJobConfiguration implements JobConfigurationInterface | |||||||
|         $artist        = strtolower($data['artist'] ?? ''); |         $artist        = strtolower($data['artist'] ?? ''); | ||||||
|         $song          = strtolower($data['song'] ?? ''); |         $song          = strtolower($data['song'] ?? ''); | ||||||
|         $album         = strtolower($data['album'] ?? ''); |         $album         = strtolower($data['album'] ?? ''); | ||||||
|         $applyRules    = isset($data['apply_rules']) ? (int)$data['apply_rules'] === 1 : null; |         $applyRules    = isset($data['apply_rules']) ? 1 === (int)$data['apply_rules'] : null; | ||||||
|         $configuration = $this->importJob->configuration; |         $configuration = $this->importJob->configuration; | ||||||
|         if ($artist === 'david bowie') { |         if ('david bowie' === $artist) { | ||||||
|             // store artist |             // store artist | ||||||
|             $configuration['artist'] = $artist; |             $configuration['artist'] = $artist; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -45,6 +45,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * @property bool        $active |  * @property bool        $active | ||||||
|  * @property string      $virtual_balance |  * @property string      $virtual_balance | ||||||
|  * @property User        $user |  * @property User        $user | ||||||
|  |  * @property mixed|null  startBalance | ||||||
|  |  * @property mixed|null  endBalance | ||||||
|  |  * @property string      difference | ||||||
|  |  * @property mixed|null  endBalance | ||||||
|  |  * @property mixed|null  startBalance | ||||||
|  |  * @property mixed|null  lastActivityDate | ||||||
|  */ |  */ | ||||||
| class Account extends Model | class Account extends Model | ||||||
| { | { | ||||||
|   | |||||||
| @@ -47,6 +47,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * @property int    $size |  * @property int    $size | ||||||
|  * @property User   $user |  * @property User   $user | ||||||
|  * @property bool   $uploaded |  * @property bool   $uploaded | ||||||
|  |  * @property bool   file_exists | ||||||
|  */ |  */ | ||||||
| class Attachment extends Model | class Attachment extends Model | ||||||
| { | { | ||||||
|   | |||||||
| @@ -37,6 +37,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * @property Carbon $start_date |  * @property Carbon $start_date | ||||||
|  * @property Carbon $end_date |  * @property Carbon $end_date | ||||||
|  * @property string $amount |  * @property string $amount | ||||||
|  |  * @property int    $budget_id | ||||||
|  |  * @property string spent | ||||||
|  */ |  */ | ||||||
| class BudgetLimit extends Model | class BudgetLimit extends Model | ||||||
| { | { | ||||||
| @@ -46,7 +48,7 @@ class BudgetLimit extends Model | |||||||
|      * @var array |      * @var array | ||||||
|      */ |      */ | ||||||
|     protected $casts |     protected $casts | ||||||
|         = [ |                         = [ | ||||||
|             'created_at' => 'datetime', |             'created_at' => 'datetime', | ||||||
|             'updated_at' => 'datetime', |             'updated_at' => 'datetime', | ||||||
|             'start_date' => 'date', |             'start_date' => 'date', | ||||||
|   | |||||||
| @@ -32,9 +32,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
| /** | /** | ||||||
|  * Class Category. |  * Class Category. | ||||||
|  * |  * | ||||||
|  * @property string $name |  * @property string      $name | ||||||
|  * @property int    $id |  * @property int         $id | ||||||
|  * @property float  $spent // used in category reports |  * @property float       $spent // used in category reports | ||||||
|  |  * @property Carbon|null lastActivity | ||||||
|  */ |  */ | ||||||
| class Category extends Model | class Category extends Model | ||||||
| { | { | ||||||
|   | |||||||
| @@ -32,6 +32,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * @property User   $user |  * @property User   $user | ||||||
|  * @property string $key |  * @property string $key | ||||||
|  * @property int    $user_id |  * @property int    $user_id | ||||||
|  |  * @property mixed  status | ||||||
|  */ |  */ | ||||||
| class ExportJob extends Model | class ExportJob extends Model | ||||||
| { | { | ||||||
|   | |||||||
| @@ -31,6 +31,7 @@ use Illuminate\Database\Eloquent\Model; | |||||||
|  * @property int       $transaction_journal_id |  * @property int       $transaction_journal_id | ||||||
|  * @property int       $piggy_bank_id |  * @property int       $piggy_bank_id | ||||||
|  * @property int       $id |  * @property int       $id | ||||||
|  |  * @property mixed     date | ||||||
|  */ |  */ | ||||||
| class PiggyBankEvent extends Model | class PiggyBankEvent extends Model | ||||||
| { | { | ||||||
|   | |||||||
| @@ -40,6 +40,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * @property Carbon $updated_at |  * @property Carbon $updated_at | ||||||
|  * @property Carbon $created_at |  * @property Carbon $created_at | ||||||
|  * @property int    $id |  * @property int    $id | ||||||
|  |  * @property mixed  user | ||||||
|  |  * @property mixed  user | ||||||
|  */ |  */ | ||||||
| class Preference extends Model | class Preference extends Model | ||||||
| { | { | ||||||
|   | |||||||
| @@ -33,6 +33,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * @property string $symbol |  * @property string $symbol | ||||||
|  * @property int    $decimal_places |  * @property int    $decimal_places | ||||||
|  * @property int    $id |  * @property int    $id | ||||||
|  |  * @property mixed  name | ||||||
|  |  * @property mixed  name | ||||||
|  |  * @property mixed  name | ||||||
|  |  * @property mixed  name | ||||||
|  |  * @property mixed  name | ||||||
|  |  * @property mixed  name | ||||||
|  |  * @property mixed  name | ||||||
|  |  * @property mixed  name | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| class TransactionCurrency extends Model | class TransactionCurrency extends Model | ||||||
|   | |||||||
| @@ -49,6 +49,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * @property int                 transaction_currency_id |  * @property int                 transaction_currency_id | ||||||
|  * @property TransactionCurrency $transactionCurrency |  * @property TransactionCurrency $transactionCurrency | ||||||
|  * @property Collection          $tags |  * @property Collection          $tags | ||||||
|  |  * @property mixed               user_id | ||||||
|  |  * @property mixed               transactions | ||||||
|  |  * @property int                 transaction_count | ||||||
|  |  * @property Carbon              interest_date | ||||||
|  |  * @property Carbon              book_date | ||||||
|  |  * @property Carbon              process_date | ||||||
|  */ |  */ | ||||||
| class TransactionJournal extends Model | class TransactionJournal extends Model | ||||||
| { | { | ||||||
|   | |||||||
| @@ -59,9 +59,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||||
|  * |  * | ||||||
|  * @property int    $id |  * @property int    $id | ||||||
|  * @property string $email |  * @property string $email | ||||||
|  * @property bool $isAdmin used in admin user controller. |  * @property bool   $isAdmin used in admin user controller. | ||||||
|  * @property bool $has2FA used in admin user controller. |  * @property bool   $has2FA used in admin user controller. | ||||||
|  * @property array $prefs used in admin user controller. |  * @property array  $prefs used in admin user controller. | ||||||
|  |  * @property mixed  password | ||||||
|  */ |  */ | ||||||
| class User extends Authenticatable | class User extends Authenticatable | ||||||
| { | { | ||||||
|   | |||||||
| @@ -607,6 +607,7 @@ return [ | |||||||
|     'cannot_delete_currency'                  => 'Cannot delete :name because it is still in use.', |     'cannot_delete_currency'                  => 'Cannot delete :name because it is still in use.', | ||||||
|     'deleted_currency'                        => 'Currency :name deleted', |     'deleted_currency'                        => 'Currency :name deleted', | ||||||
|     'created_currency'                        => 'Currency :name created', |     'created_currency'                        => 'Currency :name created', | ||||||
|  |     'could_not_store_currency'                => 'Could not store the new currency.', | ||||||
|     'updated_currency'                        => 'Currency :name updated', |     'updated_currency'                        => 'Currency :name updated', | ||||||
|     'ask_site_owner'                          => 'Please ask :owner to add, remove or edit currencies.', |     'ask_site_owner'                          => 'Please ask :owner to add, remove or edit currencies.', | ||||||
|     'currencies_intro'                        => 'Firefly III supports various currencies which you can set and enable here.', |     'currencies_intro'                        => 'Firefly III supports various currencies which you can set and enable here.', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user