mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Various code cleanup.
This commit is contained in:
		| @@ -86,12 +86,12 @@ class AccountController extends Controller | |||||||
|         $defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray(); |         $defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray(); | ||||||
|         $frontPage  = app('preferences')->get('frontPageAccounts', $defaultSet); |         $frontPage  = app('preferences')->get('frontPageAccounts', $defaultSet); | ||||||
|         $default    = app('amount')->getDefaultCurrency(); |         $default    = app('amount')->getDefaultCurrency(); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if (0 === count($frontPage->data)) { |         if (0 === count($frontPage->data)) { | ||||||
|             $frontPage->data = $defaultSet; |             $frontPage->data = $defaultSet; | ||||||
|             $frontPage->save(); |             $frontPage->save(); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         // get accounts: |         // get accounts: | ||||||
|         $accounts  = $this->repository->getAccountsById($frontPage->data); |         $accounts  = $this->repository->getAccountsById($frontPage->data); | ||||||
| @@ -100,7 +100,7 @@ class AccountController extends Controller | |||||||
|         foreach ($accounts as $account) { |         foreach ($accounts as $account) { | ||||||
|             $currency = $this->repository->getAccountCurrency($account); |             $currency = $this->repository->getAccountCurrency($account); | ||||||
|             if (null === $currency) { |             if (null === $currency) { | ||||||
|                 $currency = $default; // @codeCoverageIgnore |                 $currency = $default;  | ||||||
|             } |             } | ||||||
|             $currentSet = [ |             $currentSet = [ | ||||||
|                 'label'                   => $account->name, |                 'label'                   => $account->name, | ||||||
|   | |||||||
| @@ -96,7 +96,7 @@ class UpdateController extends Controller | |||||||
|  |  | ||||||
|         $selectedGroup = $collector->getGroups()->first(); |         $selectedGroup = $collector->getGroups()->first(); | ||||||
|         if (null === $selectedGroup) { |         if (null === $selectedGroup) { | ||||||
|             throw new NotFoundHttpException(); // @codeCoverageIgnore |             throw new NotFoundHttpException();  | ||||||
|         } |         } | ||||||
|         /** @var TransactionGroupTransformer $transformer */ |         /** @var TransactionGroupTransformer $transformer */ | ||||||
|         $transformer = app(TransactionGroupTransformer::class); |         $transformer = app(TransactionGroupTransformer::class); | ||||||
|   | |||||||
| @@ -75,13 +75,13 @@ class DestroyController extends Controller | |||||||
|  |  | ||||||
|         if (!$this->userRepository->hasRole($admin, 'owner')) { |         if (!$this->userRepository->hasRole($admin, 'owner')) { | ||||||
|             // access denied: |             // access denied: | ||||||
|             throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore |             throw new FireflyException('200005: You need the "owner" role to do this.');  | ||||||
|         } |         } | ||||||
|         if ($this->repository->currencyInUse($currency)) { |         if ($this->repository->currencyInUse($currency)) { | ||||||
|             throw new FireflyException('200006: Currency in use.'); // @codeCoverageIgnore |             throw new FireflyException('200006: Currency in use.');  | ||||||
|         } |         } | ||||||
|         if ($this->repository->isFallbackCurrency($currency)) { |         if ($this->repository->isFallbackCurrency($currency)) { | ||||||
|             throw new FireflyException('200026: Currency is fallback.'); // @codeCoverageIgnore |             throw new FireflyException('200026: Currency is fallback.');  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $this->repository->destroy($currency); |         $this->repository->destroy($currency); | ||||||
|   | |||||||
| @@ -80,7 +80,7 @@ class StoreController extends Controller | |||||||
|         $admin = auth()->user(); |         $admin = auth()->user(); | ||||||
|  |  | ||||||
|         if (!$this->userRepository->hasRole($admin, 'owner')) { |         if (!$this->userRepository->hasRole($admin, 'owner')) { | ||||||
|             throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore |             throw new FireflyException('200005: You need the "owner" role to do this.');  | ||||||
|         } |         } | ||||||
|         $data = $request->getAll(); |         $data = $request->getAll(); | ||||||
|         // if currency ID is 0, find the currency by the code: |         // if currency ID is 0, find the currency by the code: | ||||||
|   | |||||||
| @@ -86,7 +86,7 @@ class UpdateController extends Controller | |||||||
|         $admin = auth()->user(); |         $admin = auth()->user(); | ||||||
|  |  | ||||||
|         if (!$this->userRepository->hasRole($admin, 'owner')) { |         if (!$this->userRepository->hasRole($admin, 'owner')) { | ||||||
|             throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore |             throw new FireflyException('200005: You need the "owner" role to do this.');  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $data = $request->getAll(); |         $data = $request->getAll(); | ||||||
|   | |||||||
| @@ -161,7 +161,7 @@ class ConfigurationController extends Controller | |||||||
|     public function update(UpdateRequest $request, string $name): JsonResponse |     public function update(UpdateRequest $request, string $name): JsonResponse | ||||||
|     { |     { | ||||||
|         if (!$this->repository->hasRole(auth()->user(), 'owner')) { |         if (!$this->repository->hasRole(auth()->user(), 'owner')) { | ||||||
|             throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore |             throw new FireflyException('200005: You need the "owner" role to do this.');  | ||||||
|         } |         } | ||||||
|         $data      = $request->getAll(); |         $data      = $request->getAll(); | ||||||
|         $shortName = str_replace('configuration.', '', $name); |         $shortName = str_replace('configuration.', '', $name); | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ class UserController extends Controller | |||||||
|  |  | ||||||
|             return response()->json([], 204); |             return response()->json([], 204); | ||||||
|         } |         } | ||||||
|         throw new FireflyException('200025: No access to function.'); // @codeCoverageIgnore |         throw new FireflyException('200025: No access to function.');  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -57,7 +57,7 @@ class UpdateRequest extends FormRequest | |||||||
|                 return ['value' => $this->integer('value')]; |                 return ['value' => $this->integer('value')]; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return ['value' => $this->string('value')]; // @codeCoverageIgnore |         return ['value' => $this->string('value')];  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -80,6 +80,6 @@ class UpdateRequest extends FormRequest | |||||||
|                 return ['value' => 'required|numeric|min:464272080']; |                 return ['value' => 'required|numeric|min:464272080']; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return ['value' => 'required']; // @codeCoverageIgnore |         return ['value' => 'required'];  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -77,11 +77,11 @@ class DeleteEmptyJournals extends Command | |||||||
|                 // uneven number, delete journal and transactions: |                 // uneven number, delete journal and transactions: | ||||||
|                 try { |                 try { | ||||||
|                     TransactionJournal::find((int)$row->transaction_journal_id)->delete(); |                     TransactionJournal::find((int)$row->transaction_journal_id)->delete(); | ||||||
|                     // @codeCoverageIgnoreStart |  | ||||||
|                 } catch (Exception $e) { |                 } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                     Log::info(sprintf('Could not delete journal: %s', $e->getMessage())); |                     Log::info(sprintf('Could not delete journal: %s', $e->getMessage())); | ||||||
|                 } |                 } | ||||||
|                 // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|                 Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete(); |                 Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete(); | ||||||
|                 $this->info(sprintf('Deleted transaction journal #%d because it had an uneven number of transactions.', $row->transaction_journal_id)); |                 $this->info(sprintf('Deleted transaction journal #%d because it had an uneven number of transactions.', $row->transaction_journal_id)); | ||||||
| @@ -105,11 +105,11 @@ class DeleteEmptyJournals extends Command | |||||||
|         foreach ($set as $entry) { |         foreach ($set as $entry) { | ||||||
|             try { |             try { | ||||||
|                 TransactionJournal::find($entry->id)->delete(); |                 TransactionJournal::find($entry->id)->delete(); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::info(sprintf('Could not delete entry: %s', $e->getMessage())); |                 Log::info(sprintf('Could not delete entry: %s', $e->getMessage())); | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|             $this->info(sprintf('Deleted empty transaction journal #%d', $entry->id)); |             $this->info(sprintf('Deleted empty transaction journal #%d', $entry->id)); | ||||||
|             ++$count; |             ++$count; | ||||||
|   | |||||||
| @@ -118,11 +118,11 @@ class DeleteOrphanedTransactions extends Command | |||||||
|             if ($journal) { |             if ($journal) { | ||||||
|                 try { |                 try { | ||||||
|                     $journal->delete(); |                     $journal->delete(); | ||||||
|                     // @codeCoverageIgnoreStart |  | ||||||
|                 } catch (Exception $e) { |                 } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                     Log::info(sprintf('Could not delete journal %s', $e->getMessage())); |                     Log::info(sprintf('Could not delete journal %s', $e->getMessage())); | ||||||
|                 } |                 } | ||||||
|                 // @codeCoverageIgnoreEnd |  | ||||||
|             } |             } | ||||||
|             Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete(); |             Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete(); | ||||||
|             $this->line( |             $this->line( | ||||||
|   | |||||||
| @@ -64,11 +64,11 @@ class DeleteZeroAmount extends Command | |||||||
|             $this->info(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id)); |             $this->info(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id)); | ||||||
|             try { |             try { | ||||||
|                 $journal->delete(); |                 $journal->delete(); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 $this->line($e->getMessage()); |                 $this->line($e->getMessage()); | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|             Transaction::where('transaction_journal_id', $journal->id)->delete(); |             Transaction::where('transaction_journal_id', $journal->id)->delete(); | ||||||
|         } |         } | ||||||
|         if (0 === $journals->count()) { |         if (0 === $journals->count()) { | ||||||
|   | |||||||
| @@ -121,12 +121,12 @@ class FixAccountTypes extends Command | |||||||
|         $destAccountType   = $destAccount->accountType->type; |         $destAccountType   = $destAccount->accountType->type; | ||||||
|  |  | ||||||
|         if (!array_key_exists($type, $this->expected)) { |         if (!array_key_exists($type, $this->expected)) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             Log::info(sprintf('No source/destination info for transaction type %s.', $type)); |             Log::info(sprintf('No source/destination info for transaction type %s.', $type)); | ||||||
|             $this->info(sprintf('No source/destination info for transaction type %s.', $type)); |             $this->info(sprintf('No source/destination info for transaction type %s.', $type)); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         if (!array_key_exists($sourceAccountType, $this->expected[$type])) { |         if (!array_key_exists($sourceAccountType, $this->expected[$type])) { | ||||||
|             Log::debug(sprintf('Going to fix journal #%d', $journal->id)); |             Log::debug(sprintf('Going to fix journal #%d', $journal->id)); | ||||||
|   | |||||||
| @@ -70,14 +70,14 @@ class FixPiggies extends Command | |||||||
|             } |             } | ||||||
|             /** @var TransactionJournal $journal */ |             /** @var TransactionJournal $journal */ | ||||||
|             $journal = $event->transactionJournal; |             $journal = $event->transactionJournal; | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             if (null === $journal) { |             if (null === $journal) { | ||||||
|                 $event->transaction_journal_id = null; |                 $event->transaction_journal_id = null; | ||||||
|                 $event->save(); |                 $event->save(); | ||||||
|                 $this->count++; |                 $this->count++; | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|             $type = $journal->transactionType->type; |             $type = $journal->transactionType->type; | ||||||
|             if (TransactionType::TRANSFER !== $type) { |             if (TransactionType::TRANSFER !== $type) { | ||||||
|   | |||||||
| @@ -91,7 +91,7 @@ class FixUnevenAmount extends Command | |||||||
|         // one of the transactions is bad. |         // one of the transactions is bad. | ||||||
|         $journal = TransactionJournal::find($param); |         $journal = TransactionJournal::find($param); | ||||||
|         if (!$journal) { |         if (!$journal) { | ||||||
|             return; // @codeCoverageIgnore |             return;  | ||||||
|         } |         } | ||||||
|         /** @var Transaction $source */ |         /** @var Transaction $source */ | ||||||
|         $source = $journal->transactions()->where('amount', '<', 0)->first(); |         $source = $journal->transactions()->where('amount', '<', 0)->first(); | ||||||
|   | |||||||
| @@ -188,7 +188,7 @@ class DecryptDatabase extends Command | |||||||
|             $value = Crypt::decrypt($value); |             $value = Crypt::decrypt($value); | ||||||
|         } catch (DecryptException $e) { |         } catch (DecryptException $e) { | ||||||
|             if ('The MAC is invalid.' === $e->getMessage()) { |             if ('The MAC is invalid.' === $e->getMessage()) { | ||||||
|                 throw new FireflyException($e->getMessage()); // @codeCoverageIgnore |                 throw new FireflyException($e->getMessage(), 0, $e); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -124,11 +124,11 @@ class ExportData extends Command | |||||||
|         $exporter->setExportBills($options['export']['bills']); |         $exporter->setExportBills($options['export']['bills']); | ||||||
|         $exporter->setExportPiggies($options['export']['piggies']); |         $exporter->setExportPiggies($options['export']['piggies']); | ||||||
|         $data = $exporter->export(); |         $data = $exporter->export(); | ||||||
|         if (empty($data)) { |         if (0===count($data)) { | ||||||
|             $this->error('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org'); |             $this->error('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org'); | ||||||
|         } |         } | ||||||
|         $returnCode = 0; |         $returnCode = 0; | ||||||
|         if (!empty($data)) { |         if (0!== count($data)) { | ||||||
|             try { |             try { | ||||||
|                 $this->exportData($options, $data); |                 $this->exportData($options, $data); | ||||||
|                 app('telemetry')->feature('system.command.executed', $this->signature); |                 app('telemetry')->feature('system.command.executed', $this->signature); | ||||||
|   | |||||||
| @@ -114,7 +114,7 @@ class AccountCurrencies extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ class BackToJournals extends Command | |||||||
|      */ |      */ | ||||||
|     public function handle(): int |     public function handle(): int | ||||||
|     { |     { | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         if (!$this->isMigrated()) { |         if (!$this->isMigrated()) { | ||||||
|             $this->error('Please run firefly-iii:migrate-to-groups first.'); |             $this->error('Please run firefly-iii:migrate-to-groups first.'); | ||||||
| @@ -71,7 +71,7 @@ class BackToJournals extends Command | |||||||
|         if (true === $this->option('force')) { |         if (true === $this->option('force')) { | ||||||
|             $this->warn('Forcing the command.'); |             $this->warn('Forcing the command.'); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $this->migrateAll(); |         $this->migrateAll(); | ||||||
|         $end = round(microtime(true) - $start, 2); |         $end = round(microtime(true) - $start, 2); | ||||||
| @@ -87,7 +87,8 @@ class BackToJournals extends Command | |||||||
|     private function isMigrated(): bool |     private function isMigrated(): bool | ||||||
|     { |     { | ||||||
|         $configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false); |         $configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false); | ||||||
|             return (bool)$configVar->data; |  | ||||||
|  |         return (bool)$configVar->data; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -96,7 +97,8 @@ class BackToJournals extends Command | |||||||
|     private function isExecuted(): bool |     private function isExecuted(): bool | ||||||
|     { |     { | ||||||
|         $configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false); |         $configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false); | ||||||
|             return (bool)$configVar->data; |  | ||||||
|  |         return (bool)$configVar->data; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -137,15 +139,13 @@ class BackToJournals extends Command | |||||||
|      */ |      */ | ||||||
|     private function getIdsForBudgets(): array |     private function getIdsForBudgets(): array | ||||||
|     { |     { | ||||||
|         $transactions = DB::table('budget_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray(); |         $transactions = DB::table('budget_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray(); // @phpstan-ignore-line | ||||||
|         $array        = []; |         $array        = []; | ||||||
|         $chunks       = array_chunk($transactions, 500); |         $chunks       = array_chunk($transactions, 500); | ||||||
|  |  | ||||||
|         foreach ($chunks as $chunk) { |         foreach ($chunks as $chunk) { | ||||||
|             $set = DB::table('transactions') |             $set = DB::table('transactions')->whereIn('transactions.id', $chunk) | ||||||
|                      ->whereIn('transactions.id', $chunk) |  | ||||||
|                      ->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); |                      ->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); | ||||||
|             /** @noinspection SlowArrayOperationsInLoopInspection */ |  | ||||||
|             $array = array_merge($array, $set); |             $array = array_merge($array, $set); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -162,11 +162,11 @@ class BackToJournals extends Command | |||||||
|         /** @var Transaction $transaction */ |         /** @var Transaction $transaction */ | ||||||
|         $transaction = $journal->transactions->first(); |         $transaction = $journal->transactions->first(); | ||||||
|         if (null === $transaction) { |         if (null === $transaction) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id)); |             $this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id)); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         /** @var Budget $budget */ |         /** @var Budget $budget */ | ||||||
|         $budget = $transaction->budgets->first(); |         $budget = $transaction->budgets->first(); | ||||||
| @@ -217,12 +217,12 @@ class BackToJournals extends Command | |||||||
|      */ |      */ | ||||||
|     private function getIdsForCategories(): array |     private function getIdsForCategories(): array | ||||||
|     { |     { | ||||||
|         $transactions = DB::table('category_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray(); |         $transactions = DB::table('category_transaction')->distinct()->get(['transaction_id'])->pluck('transaction_id')->toArray(); // @phpstan-ignore-line | ||||||
|         $array        = []; |         $array        = []; | ||||||
|         $chunks       = array_chunk($transactions, 500); |         $chunks       = array_chunk($transactions, 500); | ||||||
|  |  | ||||||
|         foreach ($chunks as $chunk) { |         foreach ($chunks as $chunk) { | ||||||
|             $set = DB::table('transactions') |             $set = DB::table('transactions') // @phpstan-ignore-line | ||||||
|                      ->whereIn('transactions.id', $chunk) |                      ->whereIn('transactions.id', $chunk) | ||||||
|                      ->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); |                      ->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); | ||||||
|             /** @noinspection SlowArrayOperationsInLoopInspection */ |             /** @noinspection SlowArrayOperationsInLoopInspection */ | ||||||
| @@ -241,11 +241,11 @@ class BackToJournals extends Command | |||||||
|         /** @var Transaction $transaction */ |         /** @var Transaction $transaction */ | ||||||
|         $transaction = $journal->transactions->first(); |         $transaction = $journal->transactions->first(); | ||||||
|         if (null === $transaction) { |         if (null === $transaction) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id)); |             $this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id)); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         /** @var Category $category */ |         /** @var Category $category */ | ||||||
|         $category = $transaction->categories->first(); |         $category = $transaction->categories->first(); | ||||||
|   | |||||||
| @@ -54,13 +54,13 @@ class BudgetLimitCurrency extends Command | |||||||
|     public function handle(): int |     public function handle(): int | ||||||
|     { |     { | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $count        = 0; |         $count        = 0; | ||||||
|         $budgetLimits = BudgetLimit::get(); |         $budgetLimits = BudgetLimit::get(); | ||||||
| @@ -104,7 +104,7 @@ class BudgetLimitCurrency extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -56,13 +56,13 @@ class CCLiabilities extends Command | |||||||
|     { |     { | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $ccType   = AccountType::where('type', AccountType::CREDITCARD)->first(); |         $ccType   = AccountType::where('type', AccountType::CREDITCARD)->first(); | ||||||
|         $debtType = AccountType::where('type', AccountType::DEBT)->first(); |         $debtType = AccountType::where('type', AccountType::DEBT)->first(); | ||||||
| @@ -101,7 +101,7 @@ class CCLiabilities extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -54,14 +54,14 @@ class MigrateAttachments extends Command | |||||||
|      */ |      */ | ||||||
|     public function handle(): int |     public function handle(): int | ||||||
|     { |     { | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $attachments = Attachment::get(); |         $attachments = Attachment::get(); | ||||||
|         $count       = 0; |         $count       = 0; | ||||||
| @@ -113,7 +113,7 @@ class MigrateAttachments extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -56,13 +56,13 @@ class MigrateJournalNotes extends Command | |||||||
|     public function handle(): int |     public function handle(): int | ||||||
|     { |     { | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         $count = 0; |         $count = 0; | ||||||
|         /** @noinspection PhpUndefinedMethodInspection */ |         /** @noinspection PhpUndefinedMethodInspection */ | ||||||
|         $set = TransactionJournalMeta::whereName('notes')->get(); |         $set = TransactionJournalMeta::whereName('notes')->get(); | ||||||
| @@ -80,11 +80,11 @@ class MigrateJournalNotes extends Command | |||||||
|             Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id)); |             Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id)); | ||||||
|             try { |             try { | ||||||
|                 $meta->delete(); |                 $meta->delete(); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage())); |                 Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage())); | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|             $count++; |             $count++; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -112,7 +112,7 @@ class MigrateJournalNotes extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -87,7 +87,7 @@ class MigrateRecurrenceMeta extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ class MigrateRecurrenceType extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -80,7 +80,7 @@ class MigrateTagLocations extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private function migrateTagLocations(): void |     private function migrateTagLocations(): void | ||||||
|   | |||||||
| @@ -75,7 +75,7 @@ class MigrateToGroups extends Command | |||||||
|     { |     { | ||||||
|         $this->stupidLaravel(); |         $this->stupidLaravel(); | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isMigrated() && true !== $this->option('force')) { |         if ($this->isMigrated() && true !== $this->option('force')) { | ||||||
|             $this->info('Database already seems to be migrated.'); |             $this->info('Database already seems to be migrated.'); | ||||||
|  |  | ||||||
| @@ -85,7 +85,7 @@ class MigrateToGroups extends Command | |||||||
|         if (true === $this->option('force')) { |         if (true === $this->option('force')) { | ||||||
|             $this->warn('Forcing the migration.'); |             $this->warn('Forcing the migration.'); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         Log::debug('---- start group migration ----'); |         Log::debug('---- start group migration ----'); | ||||||
|         $this->makeGroupsFromSplitJournals(); |         $this->makeGroupsFromSplitJournals(); | ||||||
| @@ -135,7 +135,7 @@ class MigrateToGroups extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -165,11 +165,11 @@ class MigrateToGroups extends Command | |||||||
|     { |     { | ||||||
|         // double check transaction count. |         // double check transaction count. | ||||||
|         if ($journal->transactions->count() <= 2) { |         if ($journal->transactions->count() <= 2) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or less transactions.', $journal->id)); |             Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or less transactions.', $journal->id)); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         Log::debug(sprintf('Will now try to convert journal #%d', $journal->id)); |         Log::debug(sprintf('Will now try to convert journal #%d', $journal->id)); | ||||||
|  |  | ||||||
| @@ -217,7 +217,7 @@ class MigrateToGroups extends Command | |||||||
|             $opposingTr = $this->findOpposingTransaction($journal, $transaction); |             $opposingTr = $this->findOpposingTransaction($journal, $transaction); | ||||||
|  |  | ||||||
|             if (null === $opposingTr) { |             if (null === $opposingTr) { | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|                 $this->error( |                 $this->error( | ||||||
|                     sprintf( |                     sprintf( | ||||||
|                         'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.', |                         'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.', | ||||||
| @@ -226,7 +226,7 @@ class MigrateToGroups extends Command | |||||||
|                     ) |                     ) | ||||||
|                 ); |                 ); | ||||||
|                 continue; |                 continue; | ||||||
|                 // @codeCoverageIgnoreEnd |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             // overrule journal category with transaction category. |             // overrule journal category with transaction category. | ||||||
|   | |||||||
| @@ -73,13 +73,13 @@ class MigrateToRules extends Command | |||||||
|         $this->stupidLaravel(); |         $this->stupidLaravel(); | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $users = $this->userRepository->all(); |         $users = $this->userRepository->all(); | ||||||
|         /** @var User $user */ |         /** @var User $user */ | ||||||
| @@ -127,7 +127,7 @@ class MigrateToRules extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -75,13 +75,13 @@ class OtherCurrenciesCorrections extends Command | |||||||
|     { |     { | ||||||
|         $this->stupidLaravel(); |         $this->stupidLaravel(); | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $this->updateOtherJournalsCurrencies(); |         $this->updateOtherJournalsCurrencies(); | ||||||
|         $this->markAsExecuted(); |         $this->markAsExecuted(); | ||||||
| @@ -120,7 +120,7 @@ class OtherCurrenciesCorrections extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -154,18 +154,18 @@ class OtherCurrenciesCorrections extends Command | |||||||
|         $leadTransaction = $this->getLeadTransaction($journal); |         $leadTransaction = $this->getLeadTransaction($journal); | ||||||
|  |  | ||||||
|         if (null === $leadTransaction) { |         if (null === $leadTransaction) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $this->error(sprintf('Could not reliably determine which transaction is in the lead for transaction journal #%d.', $journal->id)); |             $this->error(sprintf('Could not reliably determine which transaction is in the lead for transaction journal #%d.', $journal->id)); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /** @var Account $account */ |         /** @var Account $account */ | ||||||
|         $account  = $leadTransaction->account; |         $account  = $leadTransaction->account; | ||||||
|         $currency = $this->getCurrency($account); |         $currency = $this->getCurrency($account); | ||||||
|         if (null === $currency) { |         if (null === $currency) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $this->error( |             $this->error( | ||||||
|                 sprintf( |                 sprintf( | ||||||
|                     'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected', $account->id, $account->name, $journal->id |                     'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected', $account->id, $account->name, $journal->id | ||||||
| @@ -174,7 +174,7 @@ class OtherCurrenciesCorrections extends Command | |||||||
|             $this->count++; |             $this->count++; | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         // fix each transaction: |         // fix each transaction: | ||||||
|         $journal->transactions->each( |         $journal->transactions->each( | ||||||
| @@ -246,18 +246,18 @@ class OtherCurrenciesCorrections extends Command | |||||||
|     { |     { | ||||||
|         $accountId = $account->id; |         $accountId = $account->id; | ||||||
|         if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) { |         if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) { | ||||||
|             return null; // @codeCoverageIgnore |             return null;  | ||||||
|         } |         } | ||||||
|         if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { |         if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { | ||||||
|             return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore |             return $this->accountCurrencies[$accountId];  | ||||||
|         } |         } | ||||||
|         $currency = $this->accountRepos->getAccountCurrency($account); |         $currency = $this->accountRepos->getAccountCurrency($account); | ||||||
|         if (null === $currency) { |         if (null === $currency) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $this->accountCurrencies[$accountId] = 0; |             $this->accountCurrencies[$accountId] = 0; | ||||||
|  |  | ||||||
|             return null; |             return null; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         $this->accountCurrencies[$accountId] = $currency; |         $this->accountCurrencies[$accountId] = $currency; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -53,13 +53,13 @@ class RenameAccountMeta extends Command | |||||||
|     public function handle(): int |     public function handle(): int | ||||||
|     { |     { | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         $array = [ |         $array = [ | ||||||
|             'accountRole'          => 'account_role', |             'accountRole'          => 'account_role', | ||||||
|             'ccType'               => 'cc_type', |             'ccType'               => 'cc_type', | ||||||
| @@ -104,7 +104,7 @@ class RenameAccountMeta extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ class TransactionIdentifier extends Command | |||||||
|     { |     { | ||||||
|         $this->stupidLaravel(); |         $this->stupidLaravel(); | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
| @@ -83,7 +83,7 @@ class TransactionIdentifier extends Command | |||||||
|         if (!Schema::hasTable('transaction_journals')) { |         if (!Schema::hasTable('transaction_journals')) { | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         $journals = $this->cliRepository->getSplitJournals(); |         $journals = $this->cliRepository->getSplitJournals(); | ||||||
|         /** @var TransactionJournal $journal */ |         /** @var TransactionJournal $journal */ | ||||||
|         foreach ($journals as $journal) { |         foreach ($journals as $journal) { | ||||||
| @@ -128,7 +128,7 @@ class TransactionIdentifier extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -178,7 +178,7 @@ class TransactionIdentifier extends Command | |||||||
|                                    ->where('amount', $amount)->where('identifier', '=', 0) |                                    ->where('amount', $amount)->where('identifier', '=', 0) | ||||||
|                                    ->whereNotIn('id', $exclude) |                                    ->whereNotIn('id', $exclude) | ||||||
|                                    ->first(); |                                    ->first(); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (QueryException $e) { |         } catch (QueryException $e) { | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             $this->error('Firefly III could not find the "identifier" field in the "transactions" table.'); |             $this->error('Firefly III could not find the "identifier" field in the "transactions" table.'); | ||||||
| @@ -189,7 +189,7 @@ class TransactionIdentifier extends Command | |||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         return $opposing; |         return $opposing; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -72,13 +72,13 @@ class TransferCurrenciesCorrections extends Command | |||||||
|     { |     { | ||||||
|         $this->stupidLaravel(); |         $this->stupidLaravel(); | ||||||
|         $start = microtime(true); |         $start = microtime(true); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isExecuted() && true !== $this->option('force')) { |         if ($this->isExecuted() && true !== $this->option('force')) { | ||||||
|             $this->warn('This command has already been executed.'); |             $this->warn('This command has already been executed.'); | ||||||
|  |  | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $this->startUpdateRoutine(); |         $this->startUpdateRoutine(); | ||||||
|         $this->markAsExecuted(); |         $this->markAsExecuted(); | ||||||
| @@ -140,7 +140,7 @@ class TransferCurrenciesCorrections extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false;  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -167,27 +167,27 @@ class TransferCurrenciesCorrections extends Command | |||||||
|     { |     { | ||||||
|         $this->resetInformation(); |         $this->resetInformation(); | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isSplitJournal($transfer)) { |         if ($this->isSplitJournal($transfer)) { | ||||||
|             $this->line(sprintf(sprintf('Transaction journal #%d is a split journal. Cannot continue.', $transfer->id))); |             $this->line(sprintf(sprintf('Transaction journal #%d is a split journal. Cannot continue.', $transfer->id))); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $this->getSourceInformation($transfer); |         $this->getSourceInformation($transfer); | ||||||
|         $this->getDestinationInformation($transfer); |         $this->getDestinationInformation($transfer); | ||||||
|  |  | ||||||
|         // unexpectedly, either one is null: |         // unexpectedly, either one is null: | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isEmptyTransactions()) { |         if ($this->isEmptyTransactions()) { | ||||||
|             $this->error(sprintf('Source or destination information for transaction journal #%d is null. Cannot fix this one.', $transfer->id)); |             $this->error(sprintf('Source or destination information for transaction journal #%d is null. Cannot fix this one.', $transfer->id)); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         // both accounts must have currency preference: |         // both accounts must have currency preference: | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($this->isNoCurrencyPresent()) { |         if ($this->isNoCurrencyPresent()) { | ||||||
|             $this->error( |             $this->error( | ||||||
|                 sprintf('Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.', $transfer->id) |                 sprintf('Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.', $transfer->id) | ||||||
| @@ -195,7 +195,7 @@ class TransferCurrenciesCorrections extends Command | |||||||
|  |  | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         // fix source transaction having no currency. |         // fix source transaction having no currency. | ||||||
|         $this->fixSourceNoCurrency(); |         $this->fixSourceNoCurrency(); | ||||||
| @@ -270,18 +270,18 @@ class TransferCurrenciesCorrections extends Command | |||||||
|     { |     { | ||||||
|         $accountId = $account->id; |         $accountId = $account->id; | ||||||
|         if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) { |         if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) { | ||||||
|             return null; // @codeCoverageIgnore |             return null;  | ||||||
|         } |         } | ||||||
|         if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { |         if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { | ||||||
|             return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore |             return $this->accountCurrencies[$accountId];  | ||||||
|         } |         } | ||||||
|         $currency = $this->accountRepos->getAccountCurrency($account); |         $currency = $this->accountRepos->getAccountCurrency($account); | ||||||
|         if (null === $currency) { |         if (null === $currency) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $this->accountCurrencies[$accountId] = 0; |             $this->accountCurrencies[$accountId] = 0; | ||||||
|  |  | ||||||
|             return null; |             return null; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         $this->accountCurrencies[$accountId] = $currency; |         $this->accountCurrencies[$accountId] = $currency; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -56,7 +56,7 @@ class UpgradeSkeleton extends Command | |||||||
|             return (bool)$configVar->data; |             return (bool)$configVar->data; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return false; // @codeCoverageIgnore |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -73,7 +73,7 @@ class UpgradeFireflyInstructions extends Command | |||||||
|         try { |         try { | ||||||
|             app('telemetry')->feature('system.users.count', (string)User::count()); |             app('telemetry')->feature('system.users.count', (string)User::count()); | ||||||
|         } catch (QueryException $e) { |         } catch (QueryException $e) { | ||||||
|             // ignore error. |             // @ignoreException | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return 0; |         return 0; | ||||||
|   | |||||||
| @@ -31,6 +31,7 @@ use FireflyIII\Jobs\MailError; | |||||||
| use Illuminate\Auth\AuthenticationException; | use Illuminate\Auth\AuthenticationException; | ||||||
| use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
|  | use Illuminate\Session\TokenMismatchException; | ||||||
| use Illuminate\Support\Arr; | use Illuminate\Support\Arr; | ||||||
| use Illuminate\Validation\ValidationException as LaravelValidationException; | use Illuminate\Validation\ValidationException as LaravelValidationException; | ||||||
| use League\OAuth2\Server\Exception\OAuthServerException; | use League\OAuth2\Server\Exception\OAuthServerException; | ||||||
| @@ -52,7 +53,8 @@ class Handler extends ExceptionHandler | |||||||
|             AuthenticationException::class, |             AuthenticationException::class, | ||||||
|             LaravelValidationException::class, |             LaravelValidationException::class, | ||||||
|             NotFoundHttpException::class, |             NotFoundHttpException::class, | ||||||
|             OAuthServerException::class |             OAuthServerException::class, | ||||||
|  |             TokenMismatchException::class, | ||||||
|         ]; |         ]; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -257,7 +257,7 @@ class AccountFactory | |||||||
|             $fields = $this->validAssetFields; |             $fields = $this->validAssetFields; | ||||||
|         } |         } | ||||||
|         if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) { |         if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) { | ||||||
|             $fields = $this->validCCFields; // @codeCoverageIgnore |             $fields = $this->validCCFields;  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /** @var AccountMetaFactory $factory */ |         /** @var AccountMetaFactory $factory */ | ||||||
| @@ -265,14 +265,14 @@ class AccountFactory | |||||||
|         foreach ($fields as $field) { |         foreach ($fields as $field) { | ||||||
|             // if the field is set but NULL, skip it. |             // if the field is set but NULL, skip it. | ||||||
|             // if the field is set but "", update it. |             // if the field is set but "", update it. | ||||||
|             if (isset($data[$field]) && null !== $data[$field]) { |             if (array_key_exists($field, $data) && null !== $data[$field]) { | ||||||
|  |  | ||||||
|                 // convert boolean value: |                 // convert boolean value: | ||||||
|                 if (is_bool($data[$field]) && false === $data[$field]) { |                 if (is_bool($data[$field]) && false === $data[$field]) { | ||||||
|                     $data[$field] = 0; // @codeCoverageIgnore |                     $data[$field] = 0;  | ||||||
|                 } |                 } | ||||||
|                 if (is_bool($data[$field]) && true === $data[$field]) { |                 if (is_bool($data[$field]) && true === $data[$field]) { | ||||||
|                     $data[$field] = 1; // @codeCoverageIgnore |                     $data[$field] = 1;  | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 $factory->crud($account, $field, (string)$data[$field]); |                 $factory->crud($account, $field, (string)$data[$field]); | ||||||
|   | |||||||
| @@ -67,8 +67,8 @@ class AccountMetaFactory | |||||||
|         if ('' === $value && null !== $entry) { |         if ('' === $value && null !== $entry) { | ||||||
|             try { |             try { | ||||||
|                 $entry->delete(); |                 $entry->delete(); | ||||||
|             } catch (Exception $e) { // @codeCoverageIgnore |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::debug(sprintf('Could not delete entry: %s', $e->getMessage())); // @codeCoverageIgnore |                 Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             return null; |             return null; | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ class AttachmentFactory | |||||||
|             /** @var Transaction $transaction */ |             /** @var Transaction $transaction */ | ||||||
|             $transaction = $this->user->transactions()->find((int)$data['attachable_id']); |             $transaction = $this->user->transactions()->find((int)$data['attachable_id']); | ||||||
|             if (null === $transaction) { |             if (null === $transaction) { | ||||||
|                 throw new FireflyException('Unexpectedly could not find transaction'); // @codeCoverageIgnore |                 throw new FireflyException('Unexpectedly could not find transaction');  | ||||||
|             } |             } | ||||||
|             $data['attachable_id'] = $transaction->transaction_journal_id; |             $data['attachable_id'] = $transaction->transaction_journal_id; | ||||||
|             $model                 = TransactionJournal::class; |             $model                 = TransactionJournal::class; | ||||||
|   | |||||||
| @@ -76,7 +76,7 @@ class BillFactory | |||||||
|         } catch (QueryException $e) { |         } catch (QueryException $e) { | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|             throw new FireflyException('400000: Could not store bill.'); |             throw new FireflyException('400000: Could not store bill.', 0, $e); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (array_key_exists('notes', $data)) { |         if (array_key_exists('notes', $data)) { | ||||||
|   | |||||||
| @@ -76,7 +76,7 @@ class CategoryFactory | |||||||
|                 ); |                 ); | ||||||
|             } catch (QueryException $e) { |             } catch (QueryException $e) { | ||||||
|                 Log::error($e->getMessage()); |                 Log::error($e->getMessage()); | ||||||
|                 throw new FireflyException('400003: Could not store new category.'); |                 throw new FireflyException('400003: Could not store new category.', 0, $e); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -69,7 +69,7 @@ class RecurrenceFactory | |||||||
|             Log::error($message); |             Log::error($message); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|  |  | ||||||
|             throw new FireflyException($message); |             throw new FireflyException($message, 0, $e); | ||||||
|         } |         } | ||||||
|         $firstDate         = null; |         $firstDate         = null; | ||||||
|         $repeatUntil       = null; |         $repeatUntil       = null; | ||||||
| @@ -129,17 +129,16 @@ class RecurrenceFactory | |||||||
|         $this->createRepetitions($recurrence, $data['repetitions'] ?? []); |         $this->createRepetitions($recurrence, $data['repetitions'] ?? []); | ||||||
|         try { |         try { | ||||||
|             $this->createTransactions($recurrence, $data['transactions'] ?? []); |             $this->createTransactions($recurrence, $data['transactions'] ?? []); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (FireflyException $e) { |         } catch (FireflyException $e) { | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             $recurrence->forceDelete(); |             $recurrence->forceDelete(); | ||||||
|             $message = sprintf('Could not create recurring transaction: %s', $e->getMessage()); |             $message = sprintf('Could not create recurring transaction: %s', $e->getMessage()); | ||||||
|             $this->errors->add('store', $message); |             $this->errors->add('store', $message); | ||||||
|             throw new FireflyException($message); |             throw new FireflyException($message, 0, $e); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         return $recurrence; |         return $recurrence; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -59,7 +59,7 @@ class TransactionCurrencyFactory | |||||||
|         } catch (QueryException $e) { |         } catch (QueryException $e) { | ||||||
|             $result = null; |             $result = null; | ||||||
|             Log::error(sprintf('Could not create new currency: %s', $e->getMessage())); |             Log::error(sprintf('Could not create new currency: %s', $e->getMessage())); | ||||||
|             throw new FireflyException('400004: Could not store new currency.'); |             throw new FireflyException('400004: Could not store new currency.', 0, $e); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $result; |         return $result; | ||||||
|   | |||||||
| @@ -102,17 +102,17 @@ class TransactionFactory | |||||||
|         ]; |         ]; | ||||||
|         try { |         try { | ||||||
|             $result = Transaction::create($data); |             $result = Transaction::create($data); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (QueryException $e) { |         } catch (QueryException $e) { | ||||||
|             Log::error(sprintf('Could not create transaction: %s', $e->getMessage()), $data); |             Log::error(sprintf('Could not create transaction: %s', $e->getMessage()), $data); | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|             throw new FireflyException('Query exception when creating transaction.'); |             throw new FireflyException('Query exception when creating transaction.', 0, $e); | ||||||
|         } |         } | ||||||
|         if (null === $result) { |         if (null === $result) { | ||||||
|             throw new FireflyException('Transaction is NULL.'); |             throw new FireflyException('Transaction is NULL.'); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         if (null !== $result) { |         if (null !== $result) { | ||||||
|             Log::debug( |             Log::debug( | ||||||
|                 sprintf( |                 sprintf( | ||||||
|   | |||||||
| @@ -66,7 +66,7 @@ class TransactionGroupFactory | |||||||
|             $collection = $this->journalFactory->create($data); |             $collection = $this->journalFactory->create($data); | ||||||
|         } catch (DuplicateTransactionException $e) { |         } catch (DuplicateTransactionException $e) { | ||||||
|             Log::warning('GroupFactory::create() caught journalFactory::create() with a duplicate!'); |             Log::warning('GroupFactory::create() caught journalFactory::create() with a duplicate!'); | ||||||
|             throw new DuplicateTransactionException($e->getMessage()); |             throw new DuplicateTransactionException($e->getMessage(), 0, $e); | ||||||
|         } |         } | ||||||
|         $title = $data['group_title'] ?? null; |         $title = $data['group_title'] ?? null; | ||||||
|         $title = '' === $title ? null : $title; |         $title = '' === $title ? null : $title; | ||||||
|   | |||||||
| @@ -128,13 +128,13 @@ class TransactionJournalFactory | |||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|             $this->forceDeleteOnError($collection); |             $this->forceDeleteOnError($collection); | ||||||
|             throw new DuplicateTransactionException($e->getMessage()); |             throw new DuplicateTransactionException($e->getMessage(), 0, $e); | ||||||
|         } catch (FireflyException $e) { |         } catch (FireflyException $e) { | ||||||
|             Log::warning('TransactionJournalFactory::create() caught an exception.'); |             Log::warning('TransactionJournalFactory::create() caught an exception.'); | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|             $this->forceDeleteOnError($collection); |             $this->forceDeleteOnError($collection); | ||||||
|             throw new FireflyException($e->getMessage()); |             throw new FireflyException($e->getMessage(), 0, $e); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $collection; |         return $collection; | ||||||
| @@ -240,7 +240,7 @@ class TransactionJournalFactory | |||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|             $this->forceDeleteOnError(new Collection([$journal])); |             $this->forceDeleteOnError(new Collection([$journal])); | ||||||
|             throw new FireflyException($e->getMessage()); |             throw new FireflyException($e->getMessage(), 0, $e); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // and the destination one: |         // and the destination one: | ||||||
| @@ -261,7 +261,7 @@ class TransactionJournalFactory | |||||||
|             Log::warning('Delete negative transaction.'); |             Log::warning('Delete negative transaction.'); | ||||||
|             $this->forceTrDelete($negative); |             $this->forceTrDelete($negative); | ||||||
|             $this->forceDeleteOnError(new Collection([$journal])); |             $this->forceDeleteOnError(new Collection([$journal])); | ||||||
|             throw new FireflyException($e->getMessage()); |             throw new FireflyException($e->getMessage(), 0, $e); | ||||||
|         } |         } | ||||||
|         // verify that journal has two transactions. Otherwise, delete and cancel. |         // verify that journal has two transactions. Otherwise, delete and cancel. | ||||||
|         $journal->completed = true; |         $journal->completed = true; | ||||||
| @@ -302,10 +302,10 @@ class TransactionJournalFactory | |||||||
|         unset($dataRow['import_hash_v2'], $dataRow['original_source']); |         unset($dataRow['import_hash_v2'], $dataRow['original_source']); | ||||||
|         $json = json_encode($dataRow, JSON_THROW_ON_ERROR, 512); |         $json = json_encode($dataRow, JSON_THROW_ON_ERROR, 512); | ||||||
|         if (false === $json) { |         if (false === $json) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $json = json_encode((string)microtime(), JSON_THROW_ON_ERROR, 512); |             $json = json_encode((string)microtime(), JSON_THROW_ON_ERROR, 512); | ||||||
|             Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow); |             Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         $hash = hash('sha256', $json); |         $hash = hash('sha256', $json); | ||||||
|         Log::debug(sprintf('The hash is: %s', $hash), $dataRow); |         Log::debug(sprintf('The hash is: %s', $hash), $dataRow); | ||||||
| @@ -358,7 +358,7 @@ class TransactionJournalFactory | |||||||
|  |  | ||||||
|         // do something with result: |         // do something with result: | ||||||
|         if (false === $validSource) { |         if (false === $validSource) { | ||||||
|             throw new FireflyException(sprintf('Source: %s', $this->accountValidator->sourceError)); // @codeCoverageIgnore |             throw new FireflyException(sprintf('Source: %s', $this->accountValidator->sourceError)); | ||||||
|         } |         } | ||||||
|         Log::debug('Source seems valid.'); |         Log::debug('Source seems valid.'); | ||||||
|         // validate destination account |         // validate destination account | ||||||
| @@ -367,7 +367,7 @@ class TransactionJournalFactory | |||||||
|         $validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null); |         $validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null); | ||||||
|         // do something with result: |         // do something with result: | ||||||
|         if (false === $validDestination) { |         if (false === $validDestination) { | ||||||
|             throw new FireflyException(sprintf('Destination: %s', $this->accountValidator->destError)); // @codeCoverageIgnore |             throw new FireflyException(sprintf('Destination: %s', $this->accountValidator->destError)); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -485,7 +485,7 @@ class TransactionJournalFactory | |||||||
|     { |     { | ||||||
|         try { |         try { | ||||||
|             $transaction->delete(); |             $transaction->delete(); | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|             Log::error('Could not delete negative transaction.'); |             Log::error('Could not delete negative transaction.'); | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ class TransactionJournalMetaFactory | |||||||
|             Log::debug('Value is empty, delete meta value.'); |             Log::debug('Value is empty, delete meta value.'); | ||||||
|             try { |             try { | ||||||
|                 $entry->delete(); |                 $entry->delete(); | ||||||
|             } catch (Exception $e) { // @codeCoverageIgnore |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); // @codeCoverageIgnore |                 Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             return null; |             return null; | ||||||
| @@ -67,8 +67,8 @@ class TransactionJournalMetaFactory | |||||||
|                 Log::debug('Will not store empty strings, delete meta value'); |                 Log::debug('Will not store empty strings, delete meta value'); | ||||||
|                 try { |                 try { | ||||||
|                     $entry->delete(); |                     $entry->delete(); | ||||||
|                 } catch (Exception $e) { // @codeCoverageIgnore |                 } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                     Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); // @codeCoverageIgnore |                     Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -56,7 +56,7 @@ class MonthReportGenerator implements ReportGeneratorInterface | |||||||
|                 ->with('start', $this->start)->with('end', $this->end) |                 ->with('start', $this->start)->with('end', $this->end) | ||||||
|                 ->with('doubles', $this->expense) |                 ->with('doubles', $this->expense) | ||||||
|                 ->render(); |                 ->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.double.report: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.double.report: %s', $e->getMessage())); | ||||||
|             $result = sprintf('Could not render report view: %s', $e->getMessage()); |             $result = sprintf('Could not render report view: %s', $e->getMessage()); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ class MonthReportGenerator implements ReportGeneratorInterface | |||||||
|             $result = prefixView('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow')) |             $result = prefixView('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow')) | ||||||
|                 ->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts) |                 ->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts) | ||||||
|                 ->render(); |                 ->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.audit.report: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.audit.report: %s', $e->getMessage())); | ||||||
|             Log::error($e->getTraceAsString()); |             Log::error($e->getTraceAsString()); | ||||||
|             $result = sprintf('Could not render report view: %s', $e->getMessage()); |             $result = sprintf('Could not render report view: %s', $e->getMessage()); | ||||||
| @@ -254,7 +254,7 @@ class MonthReportGenerator implements ReportGeneratorInterface | |||||||
|         return [ |         return [ | ||||||
|             'journals'         => $journals, |             'journals'         => $journals, | ||||||
|             'currency'         => $currency, |             'currency'         => $currency, | ||||||
|             'exists'           => !empty($journals), |             'exists'           => 0!==count($journals), | ||||||
|             'end'              => $this->end->formatLocalized((string)trans('config.month_and_day', [], $locale)), |             'end'              => $this->end->formatLocalized((string)trans('config.month_and_day', [], $locale)), | ||||||
|             'endBalance'       => app('steam')->balance($account, $this->end), |             'endBalance'       => app('steam')->balance($account, $this->end), | ||||||
|             'dayBefore'        => $date->formatLocalized((string)trans('config.month_and_day', [], $locale)), |             'dayBefore'        => $date->formatLocalized((string)trans('config.month_and_day', [], $locale)), | ||||||
|   | |||||||
| @@ -73,7 +73,7 @@ class MonthReportGenerator implements ReportGeneratorInterface | |||||||
|                 ->with('budgets', $this->budgets) |                 ->with('budgets', $this->budgets) | ||||||
|                 ->with('accounts', $this->accounts) |                 ->with('accounts', $this->accounts) | ||||||
|                 ->render(); |                 ->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage())); | ||||||
|             $result = sprintf('Could not render report view: %s', $e->getMessage()); |             $result = sprintf('Could not render report view: %s', $e->getMessage()); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ class MonthReportGenerator implements ReportGeneratorInterface | |||||||
|                 ->with('categories', $this->categories) |                 ->with('categories', $this->categories) | ||||||
|                 ->with('accounts', $this->accounts) |                 ->with('accounts', $this->accounts) | ||||||
|                 ->render(); |                 ->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage())); | ||||||
|             $result = sprintf('Could not render report view: %s', $e->getMessage()); |             $result = sprintf('Could not render report view: %s', $e->getMessage()); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ class MonthReportGenerator implements ReportGeneratorInterface | |||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             return prefixView('reports.default.month', compact('accountIds', 'reportType'))->with('start', $this->start)->with('end', $this->end)->render(); |             return prefixView('reports.default.month', compact('accountIds', 'reportType'))->with('start', $this->start)->with('end', $this->end)->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage())); | ||||||
|             $result = 'Could not render report view.'; |             $result = 'Could not render report view.'; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface | |||||||
|                 'reports.default.multi-year', |                 'reports.default.multi-year', | ||||||
|                 compact('accountIds', 'reportType') |                 compact('accountIds', 'reportType') | ||||||
|             )->with('start', $this->start)->with('end', $this->end)->render(); |             )->with('start', $this->start)->with('end', $this->end)->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.default.multi-year: %s', $e->getMessage())); | ||||||
|             $result = sprintf('Could not render report view: %s', $e->getMessage()); |             $result = sprintf('Could not render report view: %s', $e->getMessage()); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ class YearReportGenerator implements ReportGeneratorInterface | |||||||
|                 'reports.default.year', |                 'reports.default.year', | ||||||
|                 compact('accountIds', 'reportType') |                 compact('accountIds', 'reportType') | ||||||
|             )->with('start', $this->start)->with('end', $this->end)->render(); |             )->with('start', $this->start)->with('end', $this->end)->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage())); | ||||||
|             $result = 'Could not render report view.'; |             $result = 'Could not render report view.'; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -79,7 +79,7 @@ class MonthReportGenerator implements ReportGeneratorInterface | |||||||
|                 'reports.tag.month', |                 'reports.tag.month', | ||||||
|                 compact('accountIds', 'reportType', 'tagIds') |                 compact('accountIds', 'reportType', 'tagIds') | ||||||
|             )->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render(); |             )->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage())); | ||||||
|             $result = sprintf('Could not render report view: %s', $e->getMessage()); |             $result = sprintf('Could not render report view: %s', $e->getMessage()); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -69,14 +69,14 @@ class APIEventHandler | |||||||
|             try { |             try { | ||||||
|                 Log::debug('Trying to send message...'); |                 Log::debug('Trying to send message...'); | ||||||
|                 Mail::to($email)->send(new AccessTokenCreatedMail($email, $ipAddress)); |                 Mail::to($email)->send(new AccessTokenCreatedMail($email, $ipAddress)); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::debug('Send message failed! :('); |                 Log::debug('Send message failed! :('); | ||||||
|                 Log::error($e->getMessage()); |                 Log::error($e->getMessage()); | ||||||
|                 Log::error($e->getTraceAsString()); |                 Log::error($e->getTraceAsString()); | ||||||
|                 Session::flash('error', 'Possible email error: ' . $e->getMessage()); |                 Session::flash('error', 'Possible email error: ' . $e->getMessage()); | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|             Log::debug('If no error above this line, message was sent.'); |             Log::debug('If no error above this line, message was sent.'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -67,15 +67,15 @@ class AdminEventHandler | |||||||
|             try { |             try { | ||||||
|                 Log::debug('Trying to send message...'); |                 Log::debug('Trying to send message...'); | ||||||
|                 Mail::to($email)->send(new AdminTestMail($email, $ipAddress)); |                 Mail::to($email)->send(new AdminTestMail($email, $ipAddress)); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|                 // Laravel cannot pretend this process failed during testing. |                 // Laravel cannot pretend this process failed during testing. | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::debug('Send message failed! :('); |                 Log::debug('Send message failed! :('); | ||||||
|                 Log::error($e->getMessage()); |                 Log::error($e->getMessage()); | ||||||
|                 Log::error($e->getTraceAsString()); |                 Log::error($e->getTraceAsString()); | ||||||
|                 Session::flash('error', 'Possible email error: ' . $e->getMessage()); |                 Session::flash('error', 'Possible email error: ' . $e->getMessage()); | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|             Log::debug('If no error above this line, message was sent.'); |             Log::debug('If no error above this line, message was sent.'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ class AutomationHandler | |||||||
|         $sendReport = config('firefly.send_report_journals'); |         $sendReport = config('firefly.send_report_journals'); | ||||||
|  |  | ||||||
|         if (false === $sendReport) { |         if (false === $sendReport) { | ||||||
|             return true; // @codeCoverageIgnore |             return true;  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Log::debug('In reportJournals.'); |         Log::debug('In reportJournals.'); | ||||||
| @@ -73,13 +73,13 @@ class AutomationHandler | |||||||
|             try { |             try { | ||||||
|                 Log::debug('Trying to mail...'); |                 Log::debug('Trying to mail...'); | ||||||
|                 Mail::to($user->email)->send(new ReportNewJournalsMail($email, '127.0.0.1', $event->groups)); |                 Mail::to($user->email)->send(new ReportNewJournalsMail($email, '127.0.0.1', $event->groups)); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::debug('Send message failed! :('); |                 Log::debug('Send message failed! :('); | ||||||
|                 Log::error($e->getMessage()); |                 Log::error($e->getMessage()); | ||||||
|                 Log::error($e->getTraceAsString()); |                 Log::error($e->getTraceAsString()); | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|             Log::debug('Done!'); |             Log::debug('Done!'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -154,8 +154,8 @@ class UserEventHandler | |||||||
|             if (false === $entry['notified']) { |             if (false === $entry['notified']) { | ||||||
|                 try { |                 try { | ||||||
|                     Mail::to($email)->send(new NewIPAddressWarningMail($ipAddress)); |                     Mail::to($email)->send(new NewIPAddressWarningMail($ipAddress)); | ||||||
|                     // @codeCoverageIgnoreStart |  | ||||||
|                 } catch (Exception $e) { |                 } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                     Log::error($e->getMessage()); |                     Log::error($e->getMessage()); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -182,12 +182,12 @@ class UserEventHandler | |||||||
|         $uri       = route('profile.confirm-email-change', [$token->data]); |         $uri       = route('profile.confirm-email-change', [$token->data]); | ||||||
|         try { |         try { | ||||||
|             Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); |             Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| @@ -210,12 +210,12 @@ class UserEventHandler | |||||||
|         $uri       = route('profile.undo-email-change', [$token->data, $hashed]); |         $uri       = route('profile.undo-email-change', [$token->data, $hashed]); | ||||||
|         try { |         try { | ||||||
|             Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); |             Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| @@ -238,12 +238,12 @@ class UserEventHandler | |||||||
|         // send email. |         // send email. | ||||||
|         try { |         try { | ||||||
|             Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress)); |             Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress)); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| @@ -274,11 +274,11 @@ class UserEventHandler | |||||||
|             // send email. |             // send email. | ||||||
|             try { |             try { | ||||||
|                 Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress)); |                 Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress)); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|             } catch (Exception $e) { |             } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                 Log::error($e->getMessage()); |                 Log::error($e->getMessage()); | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return true; |         return true; | ||||||
|   | |||||||
| @@ -156,11 +156,11 @@ class AttachmentHelper implements AttachmentHelperInterface | |||||||
|     { |     { | ||||||
|         $resource = tmpfile(); |         $resource = tmpfile(); | ||||||
|         if (false === $resource) { |         if (false === $resource) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             Log::error('Cannot create temp-file for file upload.'); |             Log::error('Cannot create temp-file for file upload.'); | ||||||
|  |  | ||||||
|             return false; |             return false; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ('' === $content) { |         if ('' === $content) { | ||||||
| @@ -204,7 +204,7 @@ class AttachmentHelper implements AttachmentHelperInterface | |||||||
|     public function saveAttachmentsForModel(object $model, ?array $files): bool |     public function saveAttachmentsForModel(object $model, ?array $files): bool | ||||||
|     { |     { | ||||||
|         if (!($model instanceof Model)) { |         if (!($model instanceof Model)) { | ||||||
|             return false; // @codeCoverageIgnore |             return false;  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', get_class($model))); |         Log::debug(sprintf('Now in saveAttachmentsForModel for model %s', get_class($model))); | ||||||
| @@ -218,7 +218,7 @@ class AttachmentHelper implements AttachmentHelperInterface | |||||||
|             } |             } | ||||||
|             Log::debug('Done processing uploads.'); |             Log::debug('Done processing uploads.'); | ||||||
|         } |         } | ||||||
|         if (!is_array($files) || empty($files)) { |         if (!is_array($files)) { | ||||||
|             Log::debug('Array of files is not an array. Probably nothing uploaded. Will not store attachments.'); |             Log::debug('Array of files is not an array. Probably nothing uploaded. Will not store attachments.'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -263,7 +263,7 @@ class AttachmentHelper implements AttachmentHelperInterface | |||||||
|             $fileObject->rewind(); |             $fileObject->rewind(); | ||||||
|  |  | ||||||
|             if (0 === $file->getSize()) { |             if (0 === $file->getSize()) { | ||||||
|                 throw new FireflyException('Cannot upload empty or non-existent file.'); // @codeCoverageIgnore |                 throw new FireflyException('Cannot upload empty or non-existent file.');  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             $content = $fileObject->fread($file->getSize()); |             $content = $fileObject->fread($file->getSize()); | ||||||
| @@ -303,12 +303,12 @@ class AttachmentHelper implements AttachmentHelperInterface | |||||||
|             $result = false; |             $result = false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         // can't seem to reach this point. |         // can't seem to reach this point. | ||||||
|         if (true === $result && !$this->validSize($file)) { |         if (true === $result && !$this->validSize($file)) { | ||||||
|             $result = false; |             $result = false; | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         if (true === $result && $this->hasFile($file, $model)) { |         if (true === $result && $this->hasFile($file, $model)) { | ||||||
|             $result = false; |             $result = false; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -338,7 +338,7 @@ class GroupCollector implements GroupCollectorInterface | |||||||
|      */ |      */ | ||||||
|     public function setJournalIds(array $journalIds): GroupCollectorInterface |     public function setJournalIds(array $journalIds): GroupCollectorInterface | ||||||
|     { |     { | ||||||
|         if (!empty($journalIds)) { |         if (0!==count($journalIds)) { | ||||||
|             $this->query->whereIn('transaction_journals.id', $journalIds); |             $this->query->whereIn('transaction_journals.id', $journalIds); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -691,7 +691,7 @@ class GroupCollector implements GroupCollectorInterface | |||||||
|             $result['date']->setTimezone(config('app.timezone')); |             $result['date']->setTimezone(config('app.timezone')); | ||||||
|             $result['created_at']->setTimezone(config('app.timezone')); |             $result['created_at']->setTimezone(config('app.timezone')); | ||||||
|             $result['updated_at']->setTimezone(config('app.timezone')); |             $result['updated_at']->setTimezone(config('app.timezone')); | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             Log::error($e->getMessage()); |             Log::error($e->getMessage()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -699,7 +699,7 @@ class GroupCollector implements GroupCollectorInterface | |||||||
|         $result = $this->convertToInteger($result); |         $result = $this->convertToInteger($result); | ||||||
|  |  | ||||||
|         $result['reconciled'] = 1 === (int)$result['reconciled']; |         $result['reconciled'] = 1 === (int)$result['reconciled']; | ||||||
|         if (isset($augumentedJournal['tag_id'])) { // assume the other fields are present as well. |         if (array_key_exists('tag_id', $result)) { // assume the other fields are present as well. | ||||||
|             $tagId   = (int)$augumentedJournal['tag_id']; |             $tagId   = (int)$augumentedJournal['tag_id']; | ||||||
|             $tagDate = null; |             $tagDate = null; | ||||||
|             try { |             try { | ||||||
| @@ -717,7 +717,7 @@ class GroupCollector implements GroupCollectorInterface | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // also merge attachments: |         // also merge attachments: | ||||||
|         if (isset($augumentedJournal['attachment_id'])) { |         if (array_key_exists('attachment_id', $result)) { | ||||||
|             $attachmentId                         = (int)$augumentedJournal['attachment_id']; |             $attachmentId                         = (int)$augumentedJournal['attachment_id']; | ||||||
|             $result['attachments'][$attachmentId] = [ |             $result['attachments'][$attachmentId] = [ | ||||||
|                 'id' => $attachmentId, |                 'id' => $attachmentId, | ||||||
| @@ -744,7 +744,7 @@ class GroupCollector implements GroupCollectorInterface | |||||||
|                 $currencyId = (int)$transaction['currency_id']; |                 $currencyId = (int)$transaction['currency_id']; | ||||||
|  |  | ||||||
|                 // set default: |                 // set default: | ||||||
|                 if (!isset($groups[$groudId]['sums'][$currencyId])) { |                 if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) { | ||||||
|                     $groups[$groudId]['sums'][$currencyId]['currency_id']             = $currencyId; |                     $groups[$groudId]['sums'][$currencyId]['currency_id']             = $currencyId; | ||||||
|                     $groups[$groudId]['sums'][$currencyId]['currency_code']           = $transaction['currency_code']; |                     $groups[$groudId]['sums'][$currencyId]['currency_code']           = $transaction['currency_code']; | ||||||
|                     $groups[$groudId]['sums'][$currencyId]['currency_symbol']         = $transaction['currency_symbol']; |                     $groups[$groudId]['sums'][$currencyId]['currency_symbol']         = $transaction['currency_symbol']; | ||||||
| @@ -757,7 +757,7 @@ class GroupCollector implements GroupCollectorInterface | |||||||
|                     $currencyId = (int)$transaction['foreign_currency_id']; |                     $currencyId = (int)$transaction['foreign_currency_id']; | ||||||
|  |  | ||||||
|                     // set default: |                     // set default: | ||||||
|                     if (!isset($groups[$groudId]['sums'][$currencyId])) { |                     if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) { | ||||||
|                         $groups[$groudId]['sums'][$currencyId]['currency_id']             = $currencyId; |                         $groups[$groudId]['sums'][$currencyId]['currency_id']             = $currencyId; | ||||||
|                         $groups[$groudId]['sums'][$currencyId]['currency_code']           = $transaction['foreign_currency_code']; |                         $groups[$groudId]['sums'][$currencyId]['currency_code']           = $transaction['foreign_currency_code']; | ||||||
|                         $groups[$groudId]['sums'][$currencyId]['currency_symbol']         = $transaction['foreign_currency_symbol']; |                         $groups[$groudId]['sums'][$currencyId]['currency_symbol']         = $transaction['foreign_currency_symbol']; | ||||||
|   | |||||||
| @@ -84,7 +84,7 @@ class Help implements HelpInterface | |||||||
|             $res        = $client->request('GET', $uri, $opt); |             $res        = $client->request('GET', $uri, $opt); | ||||||
|             $statusCode = $res->getStatusCode(); |             $statusCode = $res->getStatusCode(); | ||||||
|             $content    = trim($res->getBody()->getContents()); |             $content    = trim($res->getBody()->getContents()); | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             Log::info($e->getMessage()); |             Log::info($e->getMessage()); | ||||||
|             Log::info($e->getTraceAsString()); |             Log::info($e->getTraceAsString()); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ class NetWorth implements NetWorthInterface | |||||||
|         $cache->addProperty('net-worth-by-currency'); |         $cache->addProperty('net-worth-by-currency'); | ||||||
|         $cache->addProperty(implode(',', $accounts->pluck('id')->toArray())); |         $cache->addProperty(implode(',', $accounts->pluck('id')->toArray())); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return $cache->get(); // @codeCoverageIgnore |             return $cache->get();  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $netWorth = []; |         $netWorth = []; | ||||||
|   | |||||||
| @@ -128,7 +128,7 @@ class ReportHelper implements ReportHelperInterface | |||||||
|  |  | ||||||
|         while ($start <= $end) { |         while ($start <= $end) { | ||||||
|             $year = $fiscalHelper->endOfFiscalYear($start)->year; // current year |             $year = $fiscalHelper->endOfFiscalYear($start)->year; // current year | ||||||
|             if (!isset($months[$year])) { |             if (!array_key_exists($year, $months)) { | ||||||
|                 $months[$year] = [ |                 $months[$year] = [ | ||||||
|                     'fiscal_start' => $fiscalHelper->startOfFiscalYear($start)->format('Y-m-d'), |                     'fiscal_start' => $fiscalHelper->startOfFiscalYear($start)->format('Y-m-d'), | ||||||
|                     'fiscal_end'   => $fiscalHelper->endOfFiscalYear($start)->format('Y-m-d'), |                     'fiscal_end'   => $fiscalHelper->endOfFiscalYear($start)->format('Y-m-d'), | ||||||
|   | |||||||
| @@ -156,7 +156,7 @@ class CreateController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // redirect to previous URL. |         // redirect to previous URL. | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ class DeleteController extends Controller | |||||||
|     public function delete(Account $account) |     public function delete(Account $account) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $typeName    = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); |         $typeName    = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); | ||||||
| @@ -98,7 +98,7 @@ class DeleteController extends Controller | |||||||
|     public function destroy(Request $request, Account $account) |     public function destroy(Request $request, Account $account) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $type     = $account->accountType->type; |         $type     = $account->accountType->type; | ||||||
|   | |||||||
| @@ -84,7 +84,7 @@ class EditController extends Controller | |||||||
|     public function edit(Request $request, Account $account, AccountRepositoryInterface $repository) |     public function edit(Request $request, Account $account, AccountRepositoryInterface $repository) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $objectType     = config('firefly.shortNamesByFullName')[$account->accountType->type]; |         $objectType     = config('firefly.shortNamesByFullName')[$account->accountType->type]; | ||||||
| @@ -177,7 +177,7 @@ class EditController extends Controller | |||||||
|     public function update(AccountFormRequest $request, Account $account) |     public function update(AccountFormRequest $request, Account $account) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $data = $request->getAccountData(); |         $data = $request->getAccountData(); | ||||||
| @@ -195,7 +195,7 @@ class EditController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // redirect |         // redirect | ||||||
|   | |||||||
| @@ -91,14 +91,14 @@ class ReconcileController extends Controller | |||||||
|     public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) |     public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|         if (AccountType::ASSET !== $account->accountType->type) { |         if (AccountType::ASSET !== $account->accountType->type) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             session()->flash('error', (string)trans('firefly.must_be_asset_account')); |             session()->flash('error', (string)trans('firefly.must_be_asset_account')); | ||||||
|  |  | ||||||
|             return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))])); |             return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))])); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         $currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency(); |         $currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency(); | ||||||
|  |  | ||||||
| @@ -106,7 +106,7 @@ class ReconcileController extends Controller | |||||||
|         $range = app('preferences')->get('viewRange', '1M')->data; |         $range = app('preferences')->get('viewRange', '1M')->data; | ||||||
|  |  | ||||||
|         // get start and end |         // get start and end | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if (null === $start && null === $end) { |         if (null === $start && null === $end) { | ||||||
|  |  | ||||||
|             /** @var Carbon $start */ |             /** @var Carbon $start */ | ||||||
| @@ -118,7 +118,7 @@ class ReconcileController extends Controller | |||||||
|             /** @var Carbon $end */ |             /** @var Carbon $end */ | ||||||
|             $end = app('navigation')->endOfPeriod($start, $range); |             $end = app('navigation')->endOfPeriod($start, $range); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         if ($end->lt($start)) { |         if ($end->lt($start)) { | ||||||
|             [$start, $end] = [$end, $start]; |             [$start, $end] = [$end, $start]; | ||||||
|         } |         } | ||||||
| @@ -168,7 +168,7 @@ class ReconcileController extends Controller | |||||||
|     public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end) |     public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Log::debug('In ReconcileController::submit()'); |         Log::debug('In ReconcileController::submit()'); | ||||||
| @@ -217,7 +217,7 @@ class ReconcileController extends Controller | |||||||
|     private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference) |     private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $reconciliation = $this->accountRepos->getReconciliation($account); |         $reconciliation = $this->accountRepos->getReconciliation($account); | ||||||
|   | |||||||
| @@ -91,7 +91,7 @@ class ShowController extends Controller | |||||||
|         $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); |         $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type)); | ||||||
|  |  | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /** @var Carbon $start */ |         /** @var Carbon $start */ | ||||||
| @@ -100,7 +100,7 @@ class ShowController extends Controller | |||||||
|         $end = $end ?? session('end'); |         $end = $end ?? session('end'); | ||||||
|  |  | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             [$start, $end] = [$end, $start]; // @codeCoverageIgnore |             [$start, $end] = [$end, $start];  | ||||||
|         } |         } | ||||||
|         $location         = $this->repository->getLocation($account); |         $location         = $this->repository->getLocation($account); | ||||||
|         $attachments      = $this->repository->getAttachments($account); |         $attachments      = $this->repository->getAttachments($account); | ||||||
| @@ -164,7 +164,7 @@ class ShowController extends Controller | |||||||
|     public function showAll(Request $request, Account $account) |     public function showAll(Request $request, Account $account) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account);  | ||||||
|         } |         } | ||||||
|         $location     = $this->repository->getLocation($account); |         $location     = $this->repository->getLocation($account); | ||||||
|         $isLiability  = $this->repository->isLiability($account); |         $isLiability  = $this->repository->isLiability($account); | ||||||
|   | |||||||
| @@ -163,7 +163,7 @@ class LinkController extends Controller | |||||||
|  |  | ||||||
|         // put previous url in session if not redirect from store (not "return_to_edit"). |         // put previous url in session if not redirect from store (not "return_to_edit"). | ||||||
|         if (true !== session('link-types.edit.fromUpdate')) { |         if (true !== session('link-types.edit.fromUpdate')) { | ||||||
|             $this->rememberPreviousUri('link-types.edit.uri'); // @codeCoverageIgnore |             $this->rememberPreviousUri('link-types.edit.uri');  | ||||||
|         } |         } | ||||||
|         $request->session()->forget('link-types.edit.fromUpdate'); |         $request->session()->forget('link-types.edit.fromUpdate'); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -219,11 +219,11 @@ class UserController extends Controller | |||||||
|         app('preferences')->mark(); |         app('preferences')->mark(); | ||||||
|         $redirect = redirect($this->getPreviousUri('users.edit.uri')); |         $redirect = redirect($this->getPreviousUri('users.edit.uri')); | ||||||
|         if (1 === (int)$request->get('return_to_edit')) { |         if (1 === (int)$request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             session()->put('users.edit.fromUpdate', true); |             session()->put('users.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('admin.users.edit', [$user->id]))->withInput(['return_to_edit' => 1]); |             $redirect = redirect(route('admin.users.edit', [$user->id]))->withInput(['return_to_edit' => 1]); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // redirect to previous URL. |         // redirect to previous URL. | ||||||
|   | |||||||
| @@ -197,11 +197,11 @@ class AttachmentController extends Controller | |||||||
|  |  | ||||||
|         $redirect = redirect($this->getPreviousUri('attachments.edit.uri')); |         $redirect = redirect($this->getPreviousUri('attachments.edit.uri')); | ||||||
|         if (1 === (int)$request->get('return_to_edit')) { |         if (1 === (int)$request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->put('attachments.edit.fromUpdate', true); |             $request->session()->put('attachments.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]); |             $redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // redirect to previous URL. |         // redirect to previous URL. | ||||||
|   | |||||||
| @@ -72,14 +72,14 @@ class ForgotPasswordController extends Controller | |||||||
|     { |     { | ||||||
|         Log::info('Start of sendResetLinkEmail()'); |         Log::info('Start of sendResetLinkEmail()'); | ||||||
|         $loginProvider = config('firefly.login_provider'); |         $loginProvider = config('firefly.login_provider'); | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ('eloquent' !== $loginProvider) { |         if ('eloquent' !== $loginProvider) { | ||||||
|             $message = sprintf('Cannot reset password when authenticating over "%s".', $loginProvider); |             $message = sprintf('Cannot reset password when authenticating over "%s".', $loginProvider); | ||||||
|             Log::error($message); |             Log::error($message); | ||||||
|  |  | ||||||
|             return prefixView('error', compact('message')); |             return prefixView('error', compact('message')); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         $this->validateEmail($request); |         $this->validateEmail($request); | ||||||
|  |  | ||||||
| @@ -102,7 +102,7 @@ class ForgotPasswordController extends Controller | |||||||
|             return back()->with('status', trans($response)); |             return back()->with('status', trans($response)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return back()->withErrors(['email' => trans($response)]); // @codeCoverageIgnore |         return back()->withErrors(['email' => trans($response)]);  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ class LoginController extends Controller | |||||||
|         Log::info(sprintf('User is trying to login.')); |         Log::info(sprintf('User is trying to login.')); | ||||||
|         if ('ldap' === config('auth.providers.users.driver')) { |         if ('ldap' === config('auth.providers.users.driver')) { | ||||||
|             /** @var Adldap\Connections\Provider $provider */ |             /** @var Adldap\Connections\Provider $provider */ | ||||||
|             Adldap::getProvider('default'); |             Adldap::getProvider('default'); // @phpstan-ignore-line | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $this->validateLogin($request); |         $this->validateLogin($request); | ||||||
| @@ -96,7 +96,7 @@ class LoginController extends Controller | |||||||
|             Log::channel('audit')->info(sprintf('Login for user "%s" was locked out.', $request->get('email'))); |             Log::channel('audit')->info(sprintf('Login for user "%s" was locked out.', $request->get('email'))); | ||||||
|             $this->fireLockoutEvent($request); |             $this->fireLockoutEvent($request); | ||||||
|  |  | ||||||
|             return $this->sendLockoutResponse($request); |             $this->sendLockoutResponse($request); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /** Copied directly from AuthenticatesUsers, but with logging added: */ |         /** Copied directly from AuthenticatesUsers, but with logging added: */ | ||||||
| @@ -190,7 +190,7 @@ class LoginController extends Controller | |||||||
|         $loginProvider = config('firefly.login_provider'); |         $loginProvider = config('firefly.login_provider'); | ||||||
|         $title         = (string)trans('firefly.login_page_title'); |         $title         = (string)trans('firefly.login_page_title'); | ||||||
|         if (0 === $count && 'eloquent' === $loginProvider) { |         if (0 === $count && 'eloquent' === $loginProvider) { | ||||||
|             return redirect(route('register')); // @codeCoverageIgnore |             return redirect(route('register'));  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // is allowed to? |         // is allowed to? | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ use Illuminate\Contracts\View\Factory; | |||||||
| use Illuminate\Http\RedirectResponse; | use Illuminate\Http\RedirectResponse; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Illuminate\View\View; | use Illuminate\View\View; | ||||||
|  | use Log; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class CreateController |  * Class CreateController | ||||||
| @@ -124,7 +125,7 @@ class CreateController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return redirect(route('rules.create-from-bill', [$bill->id])); |         return redirect(route('rules.create-from-bill', [$bill->id])); | ||||||
|   | |||||||
| @@ -138,16 +138,16 @@ class EditController extends Controller | |||||||
|  |  | ||||||
|         // flash messages |         // flash messages | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|         $redirect = redirect($this->getPreviousUri('bills.edit.uri')); |         $redirect = redirect($this->getPreviousUri('bills.edit.uri')); | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('return_to_edit')) { |         if (1 === (int)$request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->put('bills.edit.fromUpdate', true); |             $request->session()->put('bills.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]); |             $redirect = redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
| @@ -168,7 +168,7 @@ class ShowController extends Controller | |||||||
|         $collection  = $this->repository->getAttachments($bill); |         $collection  = $this->repository->getAttachments($bill); | ||||||
|         $attachments = new Collection; |         $attachments = new Collection; | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($collection->count() > 0) { |         if ($collection->count() > 0) { | ||||||
|             /** @var AttachmentTransformer $transformer */ |             /** @var AttachmentTransformer $transformer */ | ||||||
|             $transformer = app(AttachmentTransformer::class); |             $transformer = app(AttachmentTransformer::class); | ||||||
| @@ -179,7 +179,7 @@ class ShowController extends Controller | |||||||
|             ); |             ); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         return prefixView('bills.show', compact('attachments', 'groups', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle')); |         return prefixView('bills.show', compact('attachments', 'groups', 'rules', 'yearAverage', 'overallAverage', 'year', 'object', 'bill', 'subTitle')); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -131,17 +131,17 @@ class CreateController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $redirect = redirect($this->getPreviousUri('budgets.create.uri')); |         $redirect = redirect($this->getPreviousUri('budgets.create.uri')); | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('create_another')) { |         if (1 === (int)$request->get('create_another')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->put('budgets.create.fromStore', true); |             $request->session()->put('budgets.create.fromStore', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('budgets.create'))->withInput(); |             $redirect = redirect(route('budgets.create'))->withInput(); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
| @@ -144,15 +144,15 @@ class EditController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('return_to_edit')) { |         if (1 === (int)$request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->put('budgets.edit.fromUpdate', true); |             $request->session()->put('budgets.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]); |             $redirect = redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
| @@ -219,7 +219,7 @@ class IndexController extends Controller | |||||||
|             /** @var TransactionCurrency $currency */ |             /** @var TransactionCurrency $currency */ | ||||||
|             foreach ($currencies as $currency) { |             foreach ($currencies as $currency) { | ||||||
|                 $spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$current]), $currency); |                 $spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$current]), $currency); | ||||||
|                 if (isset($spentArr[$currency->id]['sum'])) { |                 if (array_key_exists('sum', $spentArr[$currency->id])) { | ||||||
|                     $array['spent'][$currency->id]['spent']                   = $spentArr[$currency->id]['sum']; |                     $array['spent'][$currency->id]['spent']                   = $spentArr[$currency->id]['sum']; | ||||||
|                     $array['spent'][$currency->id]['currency_id']             = $currency->id; |                     $array['spent'][$currency->id]['currency_id']             = $currency->id; | ||||||
|                     $array['spent'][$currency->id]['currency_symbol']         = $currency->symbol; |                     $array['spent'][$currency->id]['currency_symbol']         = $currency->symbol; | ||||||
|   | |||||||
| @@ -180,7 +180,7 @@ class ShowController extends Controller | |||||||
|     public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit) |     public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit) | ||||||
|     { |     { | ||||||
|         if ($budgetLimit->budget->id !== $budget->id) { |         if ($budgetLimit->budget->id !== $budget->id) { | ||||||
|             throw new FireflyException('This budget limit is not part of this budget.'); // @codeCoverageIgnore |             throw new FireflyException('This budget limit is not part of this budget.');  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $page     = (int)$request->get('page'); |         $page     = (int)$request->get('page'); | ||||||
|   | |||||||
| @@ -105,16 +105,16 @@ class CreateController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $redirect = redirect(route('categories.index')); |         $redirect = redirect(route('categories.index')); | ||||||
|         if (1 === (int)$request->get('create_another')) { |         if (1 === (int)$request->get('create_another')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->put('categories.create.fromStore', true); |             $request->session()->put('categories.create.fromStore', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('categories.create'))->withInput(); |             $redirect = redirect(route('categories.create'))->withInput(); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
| @@ -115,16 +115,16 @@ class EditController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|         $redirect = redirect($this->getPreviousUri('categories.edit.uri')); |         $redirect = redirect($this->getPreviousUri('categories.edit.uri')); | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('return_to_edit')) { |         if (1 === (int)$request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->put('categories.edit.fromUpdate', true); |             $request->session()->put('categories.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('categories.edit', [$category->id])); |             $redirect = redirect(route('categories.edit', [$category->id])); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
| @@ -95,7 +95,7 @@ class AccountController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.account.expense-accounts'); |         $cache->addProperty('chart.account.expense-accounts'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $start->subDay(); |         $start->subDay(); | ||||||
|  |  | ||||||
| @@ -203,7 +203,7 @@ class AccountController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.account.expense-budget'); |         $cache->addProperty('chart.account.expense-budget'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         /** @var GroupCollectorInterface $collector */ |         /** @var GroupCollectorInterface $collector */ | ||||||
|         $collector = app(GroupCollectorInterface::class); |         $collector = app(GroupCollectorInterface::class); | ||||||
| @@ -217,7 +217,7 @@ class AccountController extends Controller | |||||||
|             $budgetId    = (int)$journal['budget_id']; |             $budgetId    = (int)$journal['budget_id']; | ||||||
|             $key         = sprintf('%d-%d', $budgetId, $journal['currency_id']); |             $key         = sprintf('%d-%d', $budgetId, $journal['currency_id']); | ||||||
|             $budgetIds[] = $budgetId; |             $budgetIds[] = $budgetId; | ||||||
|             if (!isset($result[$key])) { |             if (!array_key_exists($key, $result)) { | ||||||
|                 $result[$key] = [ |                 $result[$key] = [ | ||||||
|                     'total'           => '0', |                     'total'           => '0', | ||||||
|                     'budget_id'       => $budgetId, |                     'budget_id'       => $budgetId, | ||||||
| @@ -277,7 +277,7 @@ class AccountController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.account.expense-category'); |         $cache->addProperty('chart.account.expense-category'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /** @var GroupCollectorInterface $collector */ |         /** @var GroupCollectorInterface $collector */ | ||||||
| @@ -290,7 +290,7 @@ class AccountController extends Controller | |||||||
|         /** @var array $journal */ |         /** @var array $journal */ | ||||||
|         foreach ($journals as $journal) { |         foreach ($journals as $journal) { | ||||||
|             $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); |             $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); | ||||||
|             if (!isset($result[$key])) { |             if (!array_key_exists($key, $result)) { | ||||||
|                 $result[$key] = [ |                 $result[$key] = [ | ||||||
|                     'total'           => '0', |                     'total'           => '0', | ||||||
|                     'category_id'     => (int)$journal['category_id'], |                     'category_id'     => (int)$journal['category_id'], | ||||||
| @@ -373,7 +373,7 @@ class AccountController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.account.income-category'); |         $cache->addProperty('chart.account.income-category'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // grab all journals: |         // grab all journals: | ||||||
| @@ -387,7 +387,7 @@ class AccountController extends Controller | |||||||
|         /** @var array $journal */ |         /** @var array $journal */ | ||||||
|         foreach ($journals as $journal) { |         foreach ($journals as $journal) { | ||||||
|             $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); |             $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); | ||||||
|             if (!isset($result[$key])) { |             if (!array_key_exists($key, $result)) { | ||||||
|                 $result[$key] = [ |                 $result[$key] = [ | ||||||
|                     'total'           => '0', |                     'total'           => '0', | ||||||
|                     'category_id'     => $journal['category_id'], |                     'category_id'     => $journal['category_id'], | ||||||
| @@ -431,7 +431,7 @@ class AccountController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty($account->id); |         $cache->addProperty($account->id); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $currencies = $this->accountRepository->getUsedCurrencies($account); |         $currencies = $this->accountRepository->getUsedCurrencies($account); | ||||||
|  |  | ||||||
| @@ -488,7 +488,7 @@ class AccountController extends Controller | |||||||
|                     $current->addDay(); |                     $current->addDay(); | ||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             case '1W': |             case '1W': | ||||||
|             case '1M': |             case '1M': | ||||||
|             case '1Y': |             case '1Y': | ||||||
| @@ -499,7 +499,7 @@ class AccountController extends Controller | |||||||
|                     $current         = app('navigation')->addPeriod($current, $step, 0); |                     $current         = app('navigation')->addPeriod($current, $step, 0); | ||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         $result['entries'] = $entries; |         $result['entries'] = $entries; | ||||||
|  |  | ||||||
| @@ -540,7 +540,7 @@ class AccountController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.account.revenue-accounts'); |         $cache->addProperty('chart.account.revenue-accounts'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $start->subDay(); |         $start->subDay(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -67,7 +67,7 @@ class BillController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.bill.frontpage'); |         $cache->addProperty('chart.bill.frontpage'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         /** @var CurrencyRepositoryInterface $currencyRepository */ |         /** @var CurrencyRepositoryInterface $currencyRepository */ | ||||||
|         $currencyRepository = app(CurrencyRepositoryInterface::class); |         $currencyRepository = app(CurrencyRepositoryInterface::class); | ||||||
| @@ -109,7 +109,7 @@ class BillController extends Controller | |||||||
|         $cache->addProperty('chart.bill.single'); |         $cache->addProperty('chart.bill.single'); | ||||||
|         $cache->addProperty($bill->id); |         $cache->addProperty($bill->id); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $locale = app('steam')->getLocale(); |         $locale = app('steam')->getLocale(); | ||||||
|  |  | ||||||
| @@ -147,7 +147,7 @@ class BillController extends Controller | |||||||
|             $chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill |             $chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill | ||||||
|  |  | ||||||
|             // append amount because there are more than one per moment: |             // append amount because there are more than one per moment: | ||||||
|             if (!isset($chartData[2]['entries'][$date])) { |             if (!array_key_exists($date, $chartData[2]['entries'])) { | ||||||
|                 $chartData[2]['entries'][$date] = '0'; |                 $chartData[2]['entries'][$date] = '0'; | ||||||
|             } |             } | ||||||
|             $amount                         = bcmul($journal['amount'], '-1'); |             $amount                         = bcmul($journal['amount'], '-1'); | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($budget->id); |         $cache->addProperty($budget->id); | ||||||
|  |  | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             //return response()->json($cache->get()); // @codeCoverageIgnore |             //return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $step           = $this->calculateStep($start, $end); // depending on diff, do something with range of chart. |         $step           = $this->calculateStep($start, $end); // depending on diff, do something with range of chart. | ||||||
|         $collection     = new Collection([$budget]); |         $collection     = new Collection([$budget]); | ||||||
| @@ -169,7 +169,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($budget->id); |         $cache->addProperty($budget->id); | ||||||
|  |  | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $locale           = app('steam')->getLocale(); |         $locale           = app('steam')->getLocale(); | ||||||
|         $entries          = []; |         $entries          = []; | ||||||
| @@ -224,7 +224,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|  |  | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $collector->setRange($start, $end); |         $collector->setRange($start, $end); | ||||||
|         $collector->setBudget($budget); |         $collector->setBudget($budget); | ||||||
| @@ -291,7 +291,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|  |  | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $collector->setRange($start, $end); |         $collector->setRange($start, $end); | ||||||
|         $collector->setBudget($budget)->withCategoryInformation(); |         $collector->setBudget($budget)->withCategoryInformation(); | ||||||
| @@ -355,7 +355,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|  |  | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $collector->setRange($start, $end); |         $collector->setRange($start, $end); | ||||||
|         $collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation(); |         $collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation(); | ||||||
| @@ -410,7 +410,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.budget.frontpage'); |         $cache->addProperty('chart.budget.frontpage'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $chartGenerator = app(FrontpageChartGenerator::class); |         $chartGenerator = app(FrontpageChartGenerator::class); | ||||||
| @@ -447,7 +447,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($currency->id); |         $cache->addProperty($currency->id); | ||||||
|         $cache->addProperty('chart.budget.period'); |         $cache->addProperty('chart.budget.period'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $titleFormat    = app('navigation')->preferredCarbonLocalizedFormat($start, $end); |         $titleFormat    = app('navigation')->preferredCarbonLocalizedFormat($start, $end); | ||||||
|         $preferredRange = app('navigation')->preferredRangeFormat($start, $end); |         $preferredRange = app('navigation')->preferredRangeFormat($start, $end); | ||||||
| @@ -521,7 +521,7 @@ class BudgetController extends Controller | |||||||
|         $cache->addProperty($currency->id); |         $cache->addProperty($currency->id); | ||||||
|         $cache->addProperty('chart.budget.no-budget'); |         $cache->addProperty('chart.budget.no-budget'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // the expenses: |         // the expenses: | ||||||
|   | |||||||
| @@ -76,7 +76,7 @@ class CategoryController extends Controller | |||||||
|         $cache->addProperty('chart.category.all'); |         $cache->addProperty('chart.category.all'); | ||||||
|         $cache->addProperty($category->id); |         $cache->addProperty($category->id); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         /** @var CategoryRepositoryInterface $repository */ |         /** @var CategoryRepositoryInterface $repository */ | ||||||
|         $repository = app(CategoryRepositoryInterface::class); |         $repository = app(CategoryRepositoryInterface::class); | ||||||
| @@ -102,8 +102,8 @@ class CategoryController extends Controller | |||||||
|         $carbon = null; |         $carbon = null; | ||||||
|         try { |         try { | ||||||
|             $carbon = today(config('app.timezone')); |             $carbon = today(config('app.timezone')); | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             $e->getMessage(); |             // @ignoreException | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $carbon; |         return $carbon; | ||||||
| @@ -125,7 +125,7 @@ class CategoryController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.category.frontpage'); |         $cache->addProperty('chart.category.frontpage'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $frontPageGenerator = new FrontpageChartGenerator($start, $end); |         $frontPageGenerator = new FrontpageChartGenerator($start, $end); | ||||||
| @@ -156,7 +156,7 @@ class CategoryController extends Controller | |||||||
|         $cache->addProperty($accounts->pluck('id')->toArray()); |         $cache->addProperty($accounts->pluck('id')->toArray()); | ||||||
|         $cache->addProperty($category); |         $cache->addProperty($category); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get());// @codeCoverageIgnore |             return response()->json($cache->get()); | ||||||
|         } |         } | ||||||
|         $data = $this->reportPeriodChart($accounts, $start, $end, $category); |         $data = $this->reportPeriodChart($accounts, $start, $end, $category); | ||||||
|  |  | ||||||
| @@ -270,7 +270,7 @@ class CategoryController extends Controller | |||||||
|         $cache->addProperty('chart.category.period.no-cat'); |         $cache->addProperty('chart.category.period.no-cat'); | ||||||
|         $cache->addProperty($accounts->pluck('id')->toArray()); |         $cache->addProperty($accounts->pluck('id')->toArray()); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $data = $this->reportPeriodChart($accounts, $start, $end, null); |         $data = $this->reportPeriodChart($accounts, $start, $end, null); | ||||||
|  |  | ||||||
| @@ -294,7 +294,7 @@ class CategoryController extends Controller | |||||||
|         $start = app('navigation')->startOfPeriod($date, $range); |         $start = app('navigation')->startOfPeriod($date, $range); | ||||||
|         $end   = session()->get('end'); |         $end   = session()->get('end'); | ||||||
|         if ($end < $start) { |         if ($end < $start) { | ||||||
|             [$end, $start] = [$start, $end]; // @codeCoverageIgnore |             [$end, $start] = [$start, $end];  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $cache = new CacheProperties; |         $cache = new CacheProperties; | ||||||
| @@ -303,7 +303,7 @@ class CategoryController extends Controller | |||||||
|         $cache->addProperty($category->id); |         $cache->addProperty($category->id); | ||||||
|         $cache->addProperty('chart.category.period-chart'); |         $cache->addProperty('chart.category.period-chart'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /** @var WholePeriodChartGenerator $chartGenerator */ |         /** @var WholePeriodChartGenerator $chartGenerator */ | ||||||
|   | |||||||
| @@ -88,7 +88,7 @@ class ExpenseReportController extends Controller | |||||||
|         $cache->addProperty($start); |         $cache->addProperty($start); | ||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $format       = app('navigation')->preferredCarbonLocalizedFormat($start, $end); |         $format       = app('navigation')->preferredCarbonLocalizedFormat($start, $end); | ||||||
| @@ -184,11 +184,11 @@ class ExpenseReportController extends Controller | |||||||
|         $newSet = []; |         $newSet = []; | ||||||
|         foreach ($chartData as $key => $entry) { |         foreach ($chartData as $key => $entry) { | ||||||
|             if (0 === !array_sum($entry['entries'])) { |             if (0 === !array_sum($entry['entries'])) { | ||||||
|                 $newSet[$key] = $chartData[$key]; // @codeCoverageIgnore |                 $newSet[$key] = $chartData[$key];  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (empty($newSet)) { |         if (0===count($newSet)) { | ||||||
|             $newSet = $chartData; // @codeCoverageIgnore |             $newSet = $chartData;  | ||||||
|         } |         } | ||||||
|         $data = $this->generator->multiSet($newSet); |         $data = $this->generator->multiSet($newSet); | ||||||
|         $cache->store($data); |         $cache->store($data); | ||||||
|   | |||||||
| @@ -73,7 +73,7 @@ class PiggyBankController extends Controller | |||||||
|         $cache->addProperty('chart.piggy-bank.history'); |         $cache->addProperty('chart.piggy-bank.history'); | ||||||
|         $cache->addProperty($piggyBank->id); |         $cache->addProperty($piggyBank->id); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $set    = $repository->getEvents($piggyBank); |         $set    = $repository->getEvents($piggyBank); | ||||||
|         $set    = $set->reverse(); |         $set    = $set->reverse(); | ||||||
|   | |||||||
| @@ -78,7 +78,7 @@ class ReportController extends Controller | |||||||
|         $cache->addProperty(implode(',', $accounts->pluck('id')->toArray())); |         $cache->addProperty(implode(',', $accounts->pluck('id')->toArray())); | ||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $locale    = app('steam')->getLocale(); |         $locale    = app('steam')->getLocale(); | ||||||
|         $current   = clone $start; |         $current   = clone $start; | ||||||
| @@ -113,7 +113,7 @@ class ReportController extends Controller | |||||||
|             foreach ($result as $netWorthItem) { |             foreach ($result as $netWorthItem) { | ||||||
|                 $currencyId = $netWorthItem['currency']->id; |                 $currencyId = $netWorthItem['currency']->id; | ||||||
|                 $label      = $current->formatLocalized((string)trans('config.month_and_day', [], $locale)); |                 $label      = $current->formatLocalized((string)trans('config.month_and_day', [], $locale)); | ||||||
|                 if (!isset($chartData[$currencyId])) { |                 if (!array_key_exists($currencyId, $chartData)) { | ||||||
|                     $chartData[$currencyId] = [ |                     $chartData[$currencyId] = [ | ||||||
|                         'label'           => 'Net worth in ' . $netWorthItem['currency']->name, |                         'label'           => 'Net worth in ' . $netWorthItem['currency']->name, | ||||||
|                         'type'            => 'line', |                         'type'            => 'line', | ||||||
| @@ -152,7 +152,7 @@ class ReportController extends Controller | |||||||
|         $cache->addProperty($accounts); |         $cache->addProperty($accounts); | ||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray()); |         Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray()); | ||||||
|         $format         = app('navigation')->preferredCarbonFormat($start, $end); |         $format         = app('navigation')->preferredCarbonFormat($start, $end); | ||||||
|   | |||||||
| @@ -66,7 +66,7 @@ class TransactionController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('chart.transactions.budgets'); |         $cache->addProperty('chart.transactions.budgets'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         /** @var GroupCollectorInterface $collector */ |         /** @var GroupCollectorInterface $collector */ | ||||||
|         $collector = app(GroupCollectorInterface::class); |         $collector = app(GroupCollectorInterface::class); | ||||||
| @@ -111,7 +111,7 @@ class TransactionController extends Controller | |||||||
|         $cache->addProperty($objectType); |         $cache->addProperty($objectType); | ||||||
|         $cache->addProperty('chart.transactions.categories'); |         $cache->addProperty('chart.transactions.categories'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         /** @var GroupCollectorInterface $collector */ |         /** @var GroupCollectorInterface $collector */ | ||||||
|         $collector = app(GroupCollectorInterface::class); |         $collector = app(GroupCollectorInterface::class); | ||||||
| @@ -169,7 +169,7 @@ class TransactionController extends Controller | |||||||
|         $cache->addProperty($objectType); |         $cache->addProperty($objectType); | ||||||
|         $cache->addProperty('chart.transactions.destinations'); |         $cache->addProperty('chart.transactions.destinations'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         /** @var GroupCollectorInterface $collector */ |         /** @var GroupCollectorInterface $collector */ | ||||||
|         $collector = app(GroupCollectorInterface::class); |         $collector = app(GroupCollectorInterface::class); | ||||||
| @@ -226,7 +226,7 @@ class TransactionController extends Controller | |||||||
|         $cache->addProperty($objectType); |         $cache->addProperty($objectType); | ||||||
|         $cache->addProperty('chart.transactions.sources'); |         $cache->addProperty('chart.transactions.sources'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         /** @var GroupCollectorInterface $collector */ |         /** @var GroupCollectorInterface $collector */ | ||||||
|         $collector = app(GroupCollectorInterface::class); |         $collector = app(GroupCollectorInterface::class); | ||||||
|   | |||||||
| @@ -130,12 +130,12 @@ class CurrencyController extends Controller | |||||||
|         /** @var User $user */ |         /** @var User $user */ | ||||||
|         $user = auth()->user(); |         $user = auth()->user(); | ||||||
|         if (!$this->userRepository->hasRole($user, 'owner')) { |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); |             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); | ||||||
|             Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code)); |             Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code)); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.index')); |             return redirect(route('currencies.index')); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ($this->repository->currencyInUse($currency)) { |         if ($this->repository->currencyInUse($currency)) { | ||||||
| @@ -168,12 +168,12 @@ class CurrencyController extends Controller | |||||||
|         /** @var User $user */ |         /** @var User $user */ | ||||||
|         $user = auth()->user(); |         $user = auth()->user(); | ||||||
|         if (!$this->userRepository->hasRole($user, 'owner')) { |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); |             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); | ||||||
|             Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code)); |             Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code)); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.index')); |             return redirect(route('currencies.index')); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ($this->repository->currencyInUse($currency)) { |         if ($this->repository->currencyInUse($currency)) { | ||||||
| @@ -212,12 +212,12 @@ class CurrencyController extends Controller | |||||||
|         /** @var User $user */ |         /** @var User $user */ | ||||||
|         $user = auth()->user(); |         $user = auth()->user(); | ||||||
|         if (!$this->userRepository->hasRole($user, 'owner')) { |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); |             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); | ||||||
|             Log::channel('audit')->info(sprintf('Tried to disable currency %s but is not site owner.', $currency->code)); |             Log::channel('audit')->info(sprintf('Tried to disable currency %s but is not site owner.', $currency->code)); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.index')); |             return redirect(route('currencies.index')); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ($this->repository->currencyInUse($currency)) { |         if ($this->repository->currencyInUse($currency)) { | ||||||
| @@ -268,12 +268,12 @@ class CurrencyController extends Controller | |||||||
|         /** @var User $user */ |         /** @var User $user */ | ||||||
|         $user = auth()->user(); |         $user = auth()->user(); | ||||||
|         if (!$this->userRepository->hasRole($user, 'owner')) { |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); |             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); | ||||||
|             Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code)); |             Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code)); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.index')); |             return redirect(route('currencies.index')); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $subTitleIcon     = 'fa-pencil'; |         $subTitleIcon     = 'fa-pencil'; | ||||||
| @@ -355,12 +355,12 @@ class CurrencyController extends Controller | |||||||
|         $user = auth()->user(); |         $user = auth()->user(); | ||||||
|         $data = $request->getCurrencyData(); |         $data = $request->getCurrencyData(); | ||||||
|         if (!$this->userRepository->hasRole($user, 'owner')) { |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @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.'); | ||||||
|             Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data); |             Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data); | ||||||
|  |  | ||||||
|             return redirect($this->getPreviousUri('currencies.create.uri')); |             return redirect($this->getPreviousUri('currencies.create.uri')); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $data['enabled'] = true; |         $data['enabled'] = true; | ||||||
| @@ -378,11 +378,11 @@ class CurrencyController extends Controller | |||||||
|             $request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name])); |             $request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name])); | ||||||
|             Log::channel('audit')->info('Created (POST) currency.', $data); |             Log::channel('audit')->info('Created (POST) currency.', $data); | ||||||
|             if (1 === (int) $request->get('create_another')) { |             if (1 === (int) $request->get('create_another')) { | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|                 $request->session()->put('currencies.create.fromStore', true); |                 $request->session()->put('currencies.create.fromStore', true); | ||||||
|  |  | ||||||
|                 $redirect = redirect(route('currencies.create'))->withInput(); |                 $redirect = redirect(route('currencies.create'))->withInput(); | ||||||
|                 // @codeCoverageIgnoreEnd |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -406,12 +406,12 @@ class CurrencyController extends Controller | |||||||
|             $data['enabled'] = true; |             $data['enabled'] = true; | ||||||
|         } |         } | ||||||
|         if (!$this->userRepository->hasRole($user, 'owner')) { |         if (!$this->userRepository->hasRole($user, 'owner')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); |             $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))])); | ||||||
|             Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data); |             Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.index')); |             return redirect(route('currencies.index')); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         $currency = $this->repository->update($currency, $data); |         $currency = $this->repository->update($currency, $data); | ||||||
|         Log::channel('audit')->info('Updated (POST) currency.', $data); |         Log::channel('audit')->info('Updated (POST) currency.', $data); | ||||||
| @@ -419,11 +419,11 @@ class CurrencyController extends Controller | |||||||
|         app('preferences')->mark(); |         app('preferences')->mark(); | ||||||
|  |  | ||||||
|         if (1 === (int) $request->get('return_to_edit')) { |         if (1 === (int) $request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             $request->session()->put('currencies.edit.fromUpdate', true); |             $request->session()->put('currencies.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             return redirect(route('currencies.edit', [$currency->id])); |             return redirect(route('currencies.edit', [$currency->id])); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return redirect($this->getPreviousUri('currencies.edit.uri')); |         return redirect($this->getPreviousUri('currencies.edit.uri')); | ||||||
|   | |||||||
| @@ -98,12 +98,11 @@ class DebugController extends Controller | |||||||
|         Log::debug('Call twig:clean...'); |         Log::debug('Call twig:clean...'); | ||||||
|         try { |         try { | ||||||
|             Artisan::call('twig:clean'); |             Artisan::call('twig:clean'); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (Exception $e) { |         } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|             // don't care |             // @ignoreException | ||||||
|             Log::debug(sprintf('Called twig:clean: %s', $e->getMessage())); |  | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         Log::debug('Call view:clear...'); |         Log::debug('Call view:clear...'); | ||||||
|         Artisan::call('view:clear'); |         Artisan::call('view:clear'); | ||||||
|         Log::debug('Done! Redirecting...'); |         Log::debug('Done! Redirecting...'); | ||||||
| @@ -179,12 +178,11 @@ class DebugController extends Controller | |||||||
|                 if (null !== $logFile) { |                 if (null !== $logFile) { | ||||||
|                     try { |                     try { | ||||||
|                         $logContent = file_get_contents($logFile); |                         $logContent = file_get_contents($logFile); | ||||||
|                         // @codeCoverageIgnoreStart |  | ||||||
|                     } catch (Exception $e) { |                     } catch (Exception $e) { // @phpstan-ignore-line | ||||||
|                         // don't care |                         // @ignoreException | ||||||
|                         Log::debug(sprintf('Could not read log file. %s', $e->getMessage())); |  | ||||||
|                     } |                     } | ||||||
|                     // @codeCoverageIgnoreEnd |  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -39,7 +39,6 @@ use Illuminate\Routing\Redirector; | |||||||
| use Illuminate\Support\Collection; | use Illuminate\Support\Collection; | ||||||
| use Illuminate\View\View; | use Illuminate\View\View; | ||||||
| use Log; | use Log; | ||||||
| use DB; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class HomeController. |  * Class HomeController. | ||||||
| @@ -108,8 +107,8 @@ class HomeController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function index(AccountRepositoryInterface $repository) |     public function index(AccountRepositoryInterface $repository) | ||||||
|     { |     { | ||||||
|         $types  = config('firefly.accountTypesByIdentifier.asset'); |         $types = config('firefly.accountTypesByIdentifier.asset'); | ||||||
|         $count  = $repository->count($types); |         $count = $repository->count($types); | ||||||
|         Log::channel('audit')->info('User visits homepage.'); |         Log::channel('audit')->info('User visits homepage.'); | ||||||
|  |  | ||||||
|         if (0 === $count) { |         if (0 === $count) { | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ class BoxController extends Controller | |||||||
|         $cache->addProperty($today); |         $cache->addProperty($today); | ||||||
|         $cache->addProperty('box-available'); |         $cache->addProperty('box-available'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         $leftPerDayAmount  = '0'; |         $leftPerDayAmount  = '0'; | ||||||
|         $leftToSpendAmount = '0'; |         $leftToSpendAmount = '0'; | ||||||
| @@ -142,7 +142,7 @@ class BoxController extends Controller | |||||||
|         $cache->addProperty($end); |         $cache->addProperty($end); | ||||||
|         $cache->addProperty('box-balance'); |         $cache->addProperty('box-balance'); | ||||||
|         if ($cache->has()) { |         if ($cache->has()) { | ||||||
|             return response()->json($cache->get()); // @codeCoverageIgnore |             return response()->json($cache->get());  | ||||||
|         } |         } | ||||||
|         // prep some arrays: |         // prep some arrays: | ||||||
|         $incomes  = []; |         $incomes  = []; | ||||||
| @@ -189,7 +189,7 @@ class BoxController extends Controller | |||||||
|             $incomes[$currencyId]  = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false); |             $incomes[$currencyId]  = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false); | ||||||
|             $expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false); |             $expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false); | ||||||
|         } |         } | ||||||
|         if (empty($sums)) { |         if (0===count($sums)) { | ||||||
|             $currency                = app('amount')->getDefaultCurrency(); |             $currency                = app('amount')->getDefaultCurrency(); | ||||||
|             $sums[$currency->id]     = app('amount')->formatAnything($currency, '0', false); |             $sums[$currency->id]     = app('amount')->formatAnything($currency, '0', false); | ||||||
|             $incomes[$currency->id]  = app('amount')->formatAnything($currency, '0', false); |             $incomes[$currency->id]  = app('amount')->formatAnything($currency, '0', false); | ||||||
|   | |||||||
| @@ -64,15 +64,15 @@ class FrontpageController extends Controller | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         $html = ''; |         $html = ''; | ||||||
|         if (!empty($info)) { |         if (0!==count($info)) { | ||||||
|             try { |             try { | ||||||
|                 $html = prefixView('json.piggy-banks', compact('info'))->render(); |                 $html = prefixView('json.piggy-banks', compact('info'))->render(); | ||||||
|                 // @codeCoverageIgnoreStart |  | ||||||
|             } catch (Throwable $e) { |             } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|                 Log::error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage())); |                 Log::error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage())); | ||||||
|                 $html = 'Could not render view.'; |                 $html = 'Could not render view.'; | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return response()->json(['html' => $html]); |         return response()->json(['html' => $html]); | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ class IntroController extends Controller | |||||||
|             return response()->json($steps); |             return response()->json($steps); | ||||||
|         } |         } | ||||||
|         if ($this->hasOutroStep($route)) { |         if ($this->hasOutroStep($route)) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             // save last step: |             // save last step: | ||||||
|             $lastStep = $steps[count($steps) - 1]; |             $lastStep = $steps[count($steps) - 1]; | ||||||
|             // remove last step: |             // remove last step: | ||||||
| @@ -62,7 +62,7 @@ class IntroController extends Controller | |||||||
|             // merge arrays and add last step again |             // merge arrays and add last step again | ||||||
|             $steps   = array_merge($steps, $specificSteps); |             $steps   = array_merge($steps, $specificSteps); | ||||||
|             $steps[] = $lastStep; |             $steps[] = $lastStep; | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|         if (!$this->hasOutroStep($route)) { |         if (!$this->hasOutroStep($route)) { | ||||||
|             $steps = array_merge($steps, $specificSteps); |             $steps = array_merge($steps, $specificSteps); | ||||||
|   | |||||||
| @@ -153,12 +153,12 @@ class ReconcileController extends Controller | |||||||
|                     'selectedIds' |                     'selectedIds' | ||||||
|                 ) |                 ) | ||||||
|             )->render(); |             )->render(); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::debug(sprintf('View error: %s', $e->getMessage())); |             Log::debug(sprintf('View error: %s', $e->getMessage())); | ||||||
|             $view = sprintf('Could not render accounts.reconcile.overview: %s', $e->getMessage()); |             $view = sprintf('Could not render accounts.reconcile.overview: %s', $e->getMessage()); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|         $return = [ |         $return = [ | ||||||
|             'post_uri' => $route, |             'post_uri' => $route, | ||||||
|             'html'     => $view, |             'html'     => $view, | ||||||
| @@ -181,7 +181,7 @@ class ReconcileController extends Controller | |||||||
|         Log::debug(sprintf('User submitted %s #%d: "%s"', $journal['transaction_type_type'], $journal['transaction_journal_id'], $journal['description'])); |         Log::debug(sprintf('User submitted %s #%d: "%s"', $journal['transaction_type_type'], $journal['transaction_journal_id'], $journal['description'])); | ||||||
|  |  | ||||||
|         // not much magic below we need to cover using tests. |         // not much magic below we need to cover using tests. | ||||||
|         // @codeCoverageIgnoreStart |  | ||||||
|         if ($account->id === $journal['source_account_id']) { |         if ($account->id === $journal['source_account_id']) { | ||||||
|             if ($currency->id === $journal['currency_id']) { |             if ($currency->id === $journal['currency_id']) { | ||||||
|                 $toAdd = $journal['amount']; |                 $toAdd = $journal['amount']; | ||||||
| @@ -198,7 +198,7 @@ class ReconcileController extends Controller | |||||||
|                 $toAdd = bcmul($journal['foreign_amount'], '-1'); |                 $toAdd = bcmul($journal['foreign_amount'], '-1'); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         Log::debug(sprintf('Going to add %s to %s', $toAdd, $amount)); |         Log::debug(sprintf('Going to add %s to %s', $toAdd, $amount)); | ||||||
|         $amount = bcadd($amount, $toAdd); |         $amount = bcadd($amount, $toAdd); | ||||||
| @@ -250,13 +250,13 @@ class ReconcileController extends Controller | |||||||
|                 'accounts.reconcile.transactions', |                 'accounts.reconcile.transactions', | ||||||
|                 compact('account', 'journals', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd') |                 compact('account', 'journals', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd') | ||||||
|             )->render(); |             )->render(); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::debug(sprintf('Could not render: %s', $e->getMessage())); |             Log::debug(sprintf('Could not render: %s', $e->getMessage())); | ||||||
|             $html = sprintf('Could not render accounts.reconcile.transactions: %s', $e->getMessage()); |             $html = sprintf('Could not render accounts.reconcile.transactions: %s', $e->getMessage()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]); |         return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]); | ||||||
|     } |     } | ||||||
| @@ -275,7 +275,7 @@ class ReconcileController extends Controller | |||||||
|         /** @var array $journal */ |         /** @var array $journal */ | ||||||
|         foreach ($array as $journal) { |         foreach ($array as $journal) { | ||||||
|             $inverse = false; |             $inverse = false; | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             if (TransactionType::DEPOSIT === $journal['transaction_type_type']) { |             if (TransactionType::DEPOSIT === $journal['transaction_type_type']) { | ||||||
|                 $inverse = true; |                 $inverse = true; | ||||||
|             } |             } | ||||||
| @@ -296,7 +296,7 @@ class ReconcileController extends Controller | |||||||
|                     $journal['foreign_amount'] = app('steam')->positive($journal['foreign_amount']); |                     $journal['foreign_amount'] = app('steam')->positive($journal['foreign_amount']); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|             $journals[] = $journal; |             $journals[] = $journal; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -51,13 +51,13 @@ class RuleController extends Controller | |||||||
|         } |         } | ||||||
|         try { |         try { | ||||||
|             $view = prefixView('rules.partials.action', compact('actions', 'count'))->render(); |             $view = prefixView('rules.partials.action', compact('actions', 'count'))->render(); | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage())); | ||||||
|             $view = 'Could not render view.'; |             $view = 'Could not render view.'; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // @codeCoverageIgnoreEnd |  | ||||||
|  |  | ||||||
|         return response()->json(['html' => $view]); |         return response()->json(['html' => $view]); | ||||||
|     } |     } | ||||||
| @@ -84,7 +84,7 @@ class RuleController extends Controller | |||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             $view = prefixView('rules.partials.trigger', compact('triggers', 'count'))->render(); |             $view = prefixView('rules.partials.trigger', compact('triggers', 'count'))->render(); | ||||||
|         } catch (Throwable $e) { |         } catch (Throwable $e) { // @phpstan-ignore-line | ||||||
|             Log::error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage())); |             Log::error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage())); | ||||||
|             $view = 'Could not render view.'; |             $view = 'Could not render view.'; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -92,11 +92,11 @@ class EditController extends Controller | |||||||
|         $redirect = redirect($this->getPreviousUri('object-groups.edit.uri')); |         $redirect = redirect($this->getPreviousUri('object-groups.edit.uri')); | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('return_to_edit')) { |         if (1 === (int)$request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             session()->put('object-groups.edit.fromUpdate', true); |             session()->put('object-groups.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('object-groups.edit', [$piggyBank->id])); |             $redirect = redirect(route('object-groups.edit', [$piggyBank->id])); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
| @@ -111,16 +111,16 @@ class CreateController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|         $redirect = redirect($this->getPreviousUri('piggy-banks.create.uri')); |         $redirect = redirect($this->getPreviousUri('piggy-banks.create.uri')); | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('create_another')) { |         if (1 === (int)$request->get('create_another')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             session()->put('piggy-banks.create.fromStore', true); |             session()->put('piggy-banks.create.fromStore', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('piggy-banks.create'))->withInput(); |             $redirect = redirect(route('piggy-banks.create'))->withInput(); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
| @@ -132,16 +132,16 @@ class EditController extends Controller | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (count($this->attachments->getMessages()->get('attachments')) > 0) { |         if (count($this->attachments->getMessages()->get('attachments')) > 0) { | ||||||
|             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore |             $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));  | ||||||
|         } |         } | ||||||
|         $redirect = redirect($this->getPreviousUri('piggy-banks.edit.uri')); |         $redirect = redirect($this->getPreviousUri('piggy-banks.edit.uri')); | ||||||
|  |  | ||||||
|         if (1 === (int)$request->get('return_to_edit')) { |         if (1 === (int)$request->get('return_to_edit')) { | ||||||
|             // @codeCoverageIgnoreStart |  | ||||||
|             session()->put('piggy-banks.edit.fromUpdate', true); |             session()->put('piggy-banks.edit.fromUpdate', true); | ||||||
|  |  | ||||||
|             $redirect = redirect(route('piggy-banks.edit', [$piggyBank->id])); |             $redirect = redirect(route('piggy-banks.edit', [$piggyBank->id])); | ||||||
|             // @codeCoverageIgnoreEnd |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return $redirect; |         return $redirect; | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user