diff --git a/app/Support/Twig/Extension/Transaction.php b/app/Support/Twig/Extension/Transaction.php index 7114d156c6..eb2abd71e0 100644 --- a/app/Support/Twig/Extension/Transaction.php +++ b/app/Support/Twig/Extension/Transaction.php @@ -129,7 +129,6 @@ class Transaction extends Twig_Extension if (isset($transaction->transaction_journal_budget_id)) { $name = app('steam')->tryDecrypt($transaction->transaction_journal_budget_name); $txt = sprintf('%s', route('budgets.show', [$transaction->transaction_journal_budget_id]), $name, $name); - $cache->store($txt); return $txt; } @@ -138,7 +137,6 @@ class Transaction extends Twig_Extension if (isset($transaction->transaction_budget_id)) { $name = app('steam')->tryDecrypt($transaction->transaction_budget_name); $txt = sprintf('%s', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name); - $cache->store($txt); return $txt; } diff --git a/resources/views/transactions/show.twig b/resources/views/transactions/show.twig index 2f841422c6..025361444f 100644 --- a/resources/views/transactions/show.twig +++ b/resources/views/transactions/show.twig @@ -345,8 +345,9 @@ #{{ link.source.id }}: {{ link.source.description }} ({{ link.source|journalTotalAmount }}) {% endif %} - {% if link.comment != "" %} -
{{ link.comment }} + {% if link.notes.count == 1 %} +
+ {{ link.notes.first.text|markdown }} {% endif %} @@ -459,9 +460,9 @@
- +
- +
diff --git a/tests/Feature/Controllers/CategoryControllerTest.php b/tests/Feature/Controllers/CategoryControllerTest.php index 6d2c56ea6d..866634bd2d 100644 --- a/tests/Feature/Controllers/CategoryControllerTest.php +++ b/tests/Feature/Controllers/CategoryControllerTest.php @@ -159,8 +159,6 @@ class CategoryControllerTest extends TestCase $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf(); $collector->shouldReceive('setLimit')->andReturnSelf(); - Steam::shouldReceive('positive')->once()->andReturn('1'); - $this->be($this->user()); $this->changeDateRange($this->user(), $range); $response = $this->get(route('categories.no-category')); @@ -231,8 +229,6 @@ class CategoryControllerTest extends TestCase $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf(); $collector->shouldReceive('setLimit')->andReturnSelf(); - Steam::shouldReceive('positive')->once()->andReturn('1'); - $this->be($this->user()); $this->changeDateRange($this->user(), $range); $response = $this->get(route('categories.no-category', ['2016-01-01'])); @@ -253,11 +249,10 @@ class CategoryControllerTest extends TestCase { $transaction = factory(Transaction::class)->make(); $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); + $journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal); // mock stuff $repository = $this->mock(CategoryRepositoryInterface::class); - $repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon); $repository->shouldReceive('spentInPeriod')->andReturn('0'); $repository->shouldReceive('earnedInPeriod')->andReturn('0'); @@ -267,16 +262,13 @@ class CategoryControllerTest extends TestCase $collector = $this->mock(JournalCollectorInterface::class); $collector->shouldReceive('setPage')->andReturnSelf()->once(); $collector->shouldReceive('setLimit')->andReturnSelf()->once(); - $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->twice(); - $collector->shouldReceive('setRange')->andReturnSelf()->twice(); - $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->twice(); - $collector->shouldReceive('setTypes')->andReturnSelf()->once(); + $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once(); + $collector->shouldReceive('setRange')->andReturnSelf()->once(); + $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->once(); $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once(); $collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once(); - $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->twice(); - - $collector->shouldReceive('getJournals')->andReturn(new Collection)->once(); - $collector->shouldReceive('setCategory')->andReturnSelf()->twice(); + $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once(); + $collector->shouldReceive('setCategory')->andReturnSelf()->once(); $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once(); $this->be($this->user()); @@ -313,7 +305,6 @@ class CategoryControllerTest extends TestCase $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once(); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); - $repository->shouldReceive('firstUseDate')->andReturn(new Carbon); $this->be($this->user()); @@ -338,7 +329,7 @@ class CategoryControllerTest extends TestCase $accountRepos = $this->mock(AccountRepositoryInterface::class); $collector = $this->mock(JournalCollectorInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); + $journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal); $accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection); @@ -355,7 +346,6 @@ class CategoryControllerTest extends TestCase $collector->shouldReceive('getJournals')->andReturn(new Collection)->atLeast(1); $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once(); - $repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon('1900-01-01')); $repository->shouldReceive('spentInPeriod')->andReturn('-1'); $repository->shouldReceive('earnedInPeriod')->andReturn('1'); @@ -377,11 +367,10 @@ class CategoryControllerTest extends TestCase public function testShowEmpty(string $range) { $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); + $journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal); // mock stuff $repository = $this->mock(CategoryRepositoryInterface::class); - $repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon); $repository->shouldReceive('spentInPeriod')->andReturn('0'); $repository->shouldReceive('earnedInPeriod')->andReturn('0'); @@ -391,16 +380,14 @@ class CategoryControllerTest extends TestCase $collector = $this->mock(JournalCollectorInterface::class); $collector->shouldReceive('setPage')->andReturnSelf()->once(); $collector->shouldReceive('setLimit')->andReturnSelf()->once(); - $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->twice(); - $collector->shouldReceive('setRange')->andReturnSelf()->twice(); - $collector->shouldReceive('setTypes')->andReturnSelf()->times(1); - $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->twice(); + $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once(); + $collector->shouldReceive('setRange')->andReturnSelf()->once(); + $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->once(); $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once(); $collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once(); - $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->twice(); - $collector->shouldReceive('setCategory')->andReturnSelf()->twice(); + $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once(); + $collector->shouldReceive('setCategory')->andReturnSelf()->once(); - $collector->shouldReceive('getJournals')->andReturn(new Collection)->times(1); $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once(); $this->be($this->user()); diff --git a/tests/Feature/Controllers/Report/CategoryControllerTest.php b/tests/Feature/Controllers/Report/CategoryControllerTest.php index 7901fd95c3..e452cbf0dd 100644 --- a/tests/Feature/Controllers/Report/CategoryControllerTest.php +++ b/tests/Feature/Controllers/Report/CategoryControllerTest.php @@ -81,6 +81,8 @@ class CategoryControllerTest extends TestCase $category = factory(Category::class)->make(); $repository->shouldReceive('getCategories')->andReturn(new Collection([$category])); $repository->shouldReceive('spentInPeriod')->andReturn('-1'); + $repository->shouldReceive('earnedInPeriod')->andReturn('1'); + $this->be($this->user()); $response = $this->get(route('report-data.category.operations', ['1', '20120101', '20120131']));