diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 9d79bfd7cf..8205914831 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -22,6 +22,7 @@ use FireflyIII\Http\Requests\BudgetIncomeRequest; use FireflyIII\Models\AccountType; use FireflyIII\Models\Budget; use FireflyIII\Models\BudgetLimit; +use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; @@ -215,7 +216,10 @@ class BudgetController extends Controller if (strlen($moment) > 0 && $moment !== 'all') { $start = new Carbon($moment); $end = Navigation::endOfPeriod($start, $range); - $subTitle = trans('firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]); + $subTitle = trans( + 'firefly.without_budget_between', + ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] + ); $periods = $this->noBudgetPeriodEntries(); } @@ -242,7 +246,8 @@ class BudgetController extends Controller Log::info('Count is zero, search for journals.'); /** @var JournalCollectorInterface $collector */ $collector = app(JournalCollectorInterface::class); - $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutBudget()->withOpposingAccount(); + $collector->setAllAssetAccounts()->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page) + ->withoutBudget()->withOpposingAccount(); $journals = $collector->getPaginatedJournals(); $journals->setPath('/budgets/list/no-budget'); $count = $journals->getCollection()->count(); @@ -256,7 +261,10 @@ class BudgetController extends Controller // fix title: if ((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) { - $subTitle = trans('firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]); + $subTitle = trans( + 'firefly.without_budget_between', + ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] + ); } return view('budgets.no-budget', compact('journals', 'subTitle', 'moment', 'periods', 'start', 'end')); @@ -520,11 +528,21 @@ class BudgetController extends Controller // count journals without budget in this period: /** @var JournalCollectorInterface $collector */ $collector = app(JournalCollectorInterface::class); - $collector->setAllAssetAccounts()->setRange($end, $currentEnd)->withoutBudget()->withOpposingAccount(); - $journals = $collector->getJournals()->count(); + $collector->setAllAssetAccounts()->setRange($end, $currentEnd)->withoutBudget()->withOpposingAccount()->setTypes([TransactionType::WITHDRAWAL]); + $set = $collector->getJournals(); + $sum = $set->sum('transaction_amount'); + $journals = $set->count(); $dateStr = $end->format('Y-m-d'); $dateName = Navigation::periodShow($end, $range); - $entries->push([$dateStr, $dateName, $journals, clone $end]); + $entries->push( + [ + 'string' => $dateStr, + 'name' => $dateName, + 'count' => $journals, + 'sum' => $sum, + 'date' => clone $end, + ] + ); $end = Navigation::subtractPeriod($end, $range, 1); } $cache->store($entries); diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 1d79655dd1..6ef2d16b4b 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -91,7 +91,7 @@ Breadcrumbs::register( Breadcrumbs::register( 'accounts.delete', function (BreadCrumbGenerator $breadcrumbs, Account $account) { - $breadcrumbs->parent('accounts.show', $account); + $breadcrumbs->parent('accounts.show', $account, '', new Carbon, new Carbon); $breadcrumbs->push(trans('firefly.delete_account', ['name' => e($account->name)]), route('accounts.delete', [$account->id])); } ); @@ -99,7 +99,7 @@ Breadcrumbs::register( Breadcrumbs::register( 'accounts.edit', function (BreadCrumbGenerator $breadcrumbs, Account $account) { - $breadcrumbs->parent('accounts.show', $account); + $breadcrumbs->parent('accounts.show', $account, '', new Carbon, new Carbon); $what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $breadcrumbs->push(trans('firefly.edit_' . $what . '_account', ['name' => e($account->name)]), route('accounts.edit', [$account->id])); diff --git a/resources/views/accounts/delete.twig b/resources/views/accounts/delete.twig index 7203d40a25..97a6fab792 100644 --- a/resources/views/accounts/delete.twig +++ b/resources/views/accounts/delete.twig @@ -1,7 +1,9 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute().getName(), account) }} + + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account) }} + {{ Route.getCurrentRoute.getName }} {% endblock %} {% block content %} diff --git a/resources/views/budgets/no-budget.twig b/resources/views/budgets/no-budget.twig index 20166e601d..1b169a6270 100644 --- a/resources/views/budgets/no-budget.twig +++ b/resources/views/budgets/no-budget.twig @@ -41,16 +41,20 @@ {% if periods.count > 0 %}
{% for entry in periods %} -
+
- + + + + +
{{ 'transactions'|_ }}{{ entry[2] }}{{ entry.count }}
{{ 'sum'|_ }}{{ entry.sum|formatAmount }}
diff --git a/routes/web.php b/routes/web.php index 2d94859db5..6abaca3534 100755 --- a/routes/web.php +++ b/routes/web.php @@ -86,7 +86,6 @@ Route::group( Route::get('create/{what}', ['uses' => 'AccountController@create', 'as' => 'create'])->where('what', 'revenue|asset|expense'); Route::get('edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'edit']); Route::get('delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'delete']); - Route::get('show/{account}/{moment?}', ['uses' => 'AccountController@show', 'as' => 'show']); Route::post('store', ['uses' => 'AccountController@store', 'as' => 'store']); diff --git a/tests/Feature/Controllers/AccountControllerTest.php b/tests/Feature/Controllers/AccountControllerTest.php index 50f4ece96f..aeec1e506b 100644 --- a/tests/Feature/Controllers/AccountControllerTest.php +++ b/tests/Feature/Controllers/AccountControllerTest.php @@ -158,8 +158,8 @@ class AccountControllerTest extends TestCase $tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1'); $repository = $this->mock(AccountRepositoryInterface::class); - $repository->shouldReceive('oldestJournalDate')->andReturn(clone $date); - $repository->shouldReceive('getAccountsByType')->andReturn(new Collection); + $repository->shouldReceive('oldestJournalDate')->andReturn(clone $date)->once(); + $repository->shouldReceive('getAccountsByType')->andReturn(new Collection)->once(); $transaction = factory(Transaction::class)->make(); $collector = $this->mock(JournalCollectorInterface::class); @@ -190,7 +190,7 @@ class AccountControllerTest extends TestCase $transaction = factory(Transaction::class)->make(); $collector = $this->mock(JournalCollectorInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); + $journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal); $collector->shouldReceive('setAccounts')->andReturnSelf(); $collector->shouldReceive('setRange')->andReturnSelf(); $collector->shouldReceive('setLimit')->andReturnSelf(); @@ -202,10 +202,6 @@ class AccountControllerTest extends TestCase $tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1'); $tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1'); - $repository = $this->mock(AccountRepositoryInterface::class); - $repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon)->once(); - $repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET, AccountType::DEFAULT]])->once()->andReturn(new Collection); - $this->be($this->user()); $this->changeDateRange($this->user(), $range); $response = $this->get(route('accounts.show', [1, 'all'])); @@ -253,14 +249,14 @@ class AccountControllerTest extends TestCase $tasker = $this->mock(AccountTaskerInterface::class); $repository = $this->mock(AccountRepositoryInterface::class); - $repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon); + $repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon)->once(); $repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET, AccountType::DEFAULT]])->once()->andReturn(new Collection); $tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1'); $tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1'); $this->be($this->user()); $this->changeDateRange($this->user(), $range); - $response = $this->get(route('accounts.show.date', [1, '2016-01-01'])); + $response = $this->get(route('accounts.show', [1, '2016-01-01'])); $response->assertStatus(200); // has bread crumb $response->assertSee('