diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index c947e3612b..970d90b618 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -307,8 +307,7 @@ class AccountController extends Controller } } - // fix title: - if ((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) { + if ($moment != 'all' && $loop > 1) { $subTitle = trans( 'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] @@ -478,7 +477,7 @@ class AccountController extends Controller $opposingTransaction = $journal->transactions()->where('transactions.id', '!=', $transaction->id)->first(); if (is_null($opposingTransaction)) { - throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.'); + throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.'); // @codeCoverageIgnore } return redirect(route('accounts.show', [$opposingTransaction->account_id])); diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php index 51b24e4d93..d731a913cc 100644 --- a/app/Http/Controllers/AttachmentController.php +++ b/app/Http/Controllers/AttachmentController.php @@ -176,10 +176,11 @@ class AttachmentController extends Controller Preferences::mark(); if (intval($request->get('return_to_edit')) === 1) { - // set value so edit routine will not overwrite URL: + // @codeCoverageIgnoreStart $request->session()->put('attachments.edit.fromUpdate', true); return redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]); + // @codeCoverageIgnoreEnd } // redirect to previous URL. diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index b05ede6e52..d738234d40 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -240,10 +240,11 @@ class BillController extends Controller Preferences::mark(); if (intval($request->get('create_another')) === 1) { - // set value so create routine will not overwrite URL: + // @codeCoverageIgnoreStart $request->session()->put('bills.create.fromStore', true); return redirect(route('bills.create'))->withInput(); + // @codeCoverageIgnoreEnd } // redirect to previous URL. @@ -267,10 +268,11 @@ class BillController extends Controller Preferences::mark(); if (intval($request->get('return_to_edit')) === 1) { - // set value so edit routine will not overwrite URL: + // @codeCoverageIgnoreStart $request->session()->put('bills.edit.fromUpdate', true); return redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]); + // @codeCoverageIgnoreEnd } return redirect($this->getPreviousUri('bills.edit.uri')); diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 5f5a3f1cc5..41ad31e2f3 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -259,8 +259,7 @@ class BudgetController extends Controller } } - // fix title: - if (((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) && $count > 0) { + if ($moment != 'all' && $loop > 1) { $subTitle = trans( 'firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index e67e71e1b1..2eedbf128c 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -219,8 +219,7 @@ class CategoryController extends Controller } } - // fix title: - if (((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) && $count > 0) { + if ($moment != 'all' && $loop > 1) { $subTitle = trans( 'firefly.without_category_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] @@ -302,8 +301,7 @@ class CategoryController extends Controller } } - // fix title: - if (((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) && $count > 0) { + if ($moment != 'all' && $loop > 1) { $subTitle = trans( 'firefly.journals_in_period_for_category', ['name' => $category->name,'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] @@ -313,66 +311,6 @@ class CategoryController extends Controller return view('categories.show', compact('category', 'moment', 'journals', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end')); } - // /** - // * @param Request $request - // * @param CategoryRepositoryInterface $repository - // * @param Category $category - // * - // * @return View - // */ - // public function showAll(Request $request, CategoryRepositoryInterface $repository, Category $category) - // { - // $range = Preferences::get('viewRange', '1M')->data; - // $start = $repository->firstUseDate($category); - // if ($start->year == 1900) { - // $start = new Carbon; - // } - // $end = Navigation::endOfPeriod(new Carbon, $range); - // $subTitle = $category->name; - // $subTitleIcon = 'fa-bar-chart'; - // $hideCategory = true; // used in list. - // $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page')); - // $pageSize = intval(Preferences::get('transactionPageSize', 50)->data); - // $method = 'all'; - // - // /** @var JournalCollectorInterface $collector */ - // $collector = app(JournalCollectorInterface::class); - // $collector->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->setCategory($category)->withBudgetInformation(); - // $journals = $collector->getPaginatedJournals(); - // $journals->setPath('categories/show/' . $category->id . '/all'); - // - // return view('categories.show', compact('category', 'method', 'journals', 'hideCategory', 'subTitle', 'subTitleIcon', 'start', 'end')); - // } - // - // /** - // * @param Request $request - // * @param Category $category - // * @param string $date - // * - // * @return View - // */ - // public function showByDate(Request $request, Category $category, string $date) - // { - // $carbon = new Carbon($date); - // $range = Preferences::get('viewRange', '1M')->data; - // $start = Navigation::startOfPeriod($carbon, $range); - // $end = Navigation::endOfPeriod($carbon, $range); - // $subTitle = $category->name; - // $subTitleIcon = 'fa-bar-chart'; - // $hideCategory = true; // used in list. - // $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page')); - // $pageSize = intval(Preferences::get('transactionPageSize', 50)->data); - // $entries = $this->getGroupedEntries($category); - // $method = 'date'; - // - // /** @var JournalCollectorInterface $collector */ - // $collector = app(JournalCollectorInterface::class); - // $collector->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->setRange($start, $end)->setCategory($category)->withBudgetInformation(); - // $journals = $collector->getPaginatedJournals(); - // $journals->setPath('categories/show/' . $category->id . '/' . $date); - // - // return view('categories.show', compact('category', 'method', 'entries', 'journals', 'hideCategory', 'subTitle', 'subTitleIcon', 'start', 'end')); - // } /** * @param CategoryFormRequest $request diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index f348445c18..67615e167a 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -221,9 +221,10 @@ class TagController extends Controller } /** - * @param Request $request - * @param JournalCollectorInterface $collector - * @param Tag $tag + * @param Request $request + * @param TagRepositoryInterface $repository + * @param Tag $tag + * @param string $moment * * @return View */ @@ -290,9 +291,8 @@ class TagController extends Controller Log::info(sprintf('Count is still zero, go back in time to "%s" and "%s"!', $start->format('Y-m-d'), $end->format('Y-m-d'))); } } - - // fix title: - if (((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) && $count > 0) { + + if ($moment != 'all' && $loop > 1) { $subTitle = trans( 'firefly.journals_in_period_for_tag', ['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] @@ -303,68 +303,6 @@ class TagController extends Controller return view('tags.show', compact('tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment')); } - // /** - // * @param Request $request - // * @param JournalCollectorInterface $collector - // * @param Tag $tag - // * - // * @return View - // */ - // public function showAll(Request $request, JournalCollectorInterface $collector, Tag $tag) - // { - // $subTitle = $tag->tag; - // $subTitleIcon = 'fa-tag'; - // $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page')); - // $pageSize = intval(Preferences::get('transactionPageSize', 50)->data); - // $collector->setAllAssetAccounts()->setLimit($pageSize)->setPage($page)->setTag($tag) - // ->withOpposingAccount()->disableInternalFilter() - // ->withBudgetInformation()->withCategoryInformation(); - // $journals = $collector->getPaginatedJournals(); - // $journals->setPath('tags/show/' . $tag->id . '/all'); - // - // $sum = $journals->sum( - // function (Transaction $transaction) { - // return $transaction->transaction_amount; - // } - // ); - // - // return view('tags.show', compact('tag', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end')); - // - // } - // - // public function showByDate(Request $request, JournalCollectorInterface $collector, Tag $tag, string $date) - // { - // $range = Preferences::get('viewRange', '1M')->data; - // - // try { - // $start = new Carbon($date); - // $end = Navigation::endOfPeriod($start, $range); - // } catch (Exception $e) { - // $start = Navigation::startOfPeriod($this->repository->firstUseDate($tag), $range); - // $end = Navigation::startOfPeriod($this->repository->lastUseDate($tag), $range); - // } - // - // $subTitle = $tag->tag; - // $subTitleIcon = 'fa-tag'; - // $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page')); - // $pageSize = intval(Preferences::get('transactionPageSize', 50)->data); - // $periods = $this->getPeriodOverview($tag); - // - // // use collector: - // $collector->setAllAssetAccounts() - // ->setLimit($pageSize)->setPage($page)->setTag($tag)->withOpposingAccount()->disableInternalFilter() - // ->withBudgetInformation()->withCategoryInformation()->setRange($start, $end); - // $journals = $collector->getPaginatedJournals(); - // $journals->setPath('tags/show/' . $tag->id); - // - // $sum = $journals->sum( - // function (Transaction $transaction) { - // return $transaction->transaction_amount; - // } - // ); - // - // return view('tags.show', compact('tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end')); - // } /** * @param TagFormRequest $request diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 8159fe6b01..527b6e84ca 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -125,8 +125,7 @@ class TransactionController extends Controller } } - // fix title: - if (((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) && $count > 0) { + if ($moment != 'all' && $loop > 1) { $subTitle = trans( 'firefly.title_' . $what . '_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index d727a45a98..ff878fd1be 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -33,6 +33,47 @@ $factory->define( } ); + +$factory->define( + FireflyIII\Models\TransactionJournal::class, function (Faker\Generator $faker) { + return [ + 'id' => $faker->numberBetween(1, 10), + 'user_id' => 1, + 'transaction_type_id' => 1, + 'bill_id' => null, + 'transaction_currency_id' => 1, + 'description' => $faker->words(3, true), + 'date' => '2017-01-01', + 'interest_date' => null, + 'book_date' => null, + 'process_date' => null, + 'order' => 0, + 'tag_count' => 0, + 'encrypted' => 0, + 'completed' => 1, + ]; +} +); + +$factory->define( + FireflyIII\Models\Bill::class, function (Faker\Generator $faker) { + return [ + 'id' => $faker->numberBetween(1, 10), + 'user_id' => 1, + 'name' => $faker->words(3, true), + 'match' => $faker->words(3, true), + 'amount_min' => '100.00', + 'amount_max' => '100.00', + 'date' => '2017-01-01', + 'repeat_freq' => 'monthly', + 'skip' => 0, + 'automatch' => 1, + 'name_encrypted' => 0, + 'match_encrypted' => 0, + ]; +} +); + $factory->define( FireflyIII\Models\PiggyBank::class, function (Faker\Generator $faker) { return [ diff --git a/resources/views/partials/flashes.twig b/resources/views/partials/flashes.twig index c80789ed0e..c4808c0ee5 100644 --- a/resources/views/partials/flashes.twig +++ b/resources/views/partials/flashes.twig @@ -1,4 +1,4 @@ - +{# SUCCESS MESSAGE (ALWAYS SINGULAR) #} {% if Session.has('success') %} {% endif %} - +{# INFO MESSAGE (CAN BE MULTIPLE) #} {% if Session.has('info') %}