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