Expand category view.

This commit is contained in:
James Cole
2017-03-22 17:00:01 +01:00
parent 477acafc4c
commit 32c89f9a98
2 changed files with 19 additions and 6 deletions

View File

@@ -290,7 +290,7 @@ class CategoryController extends Controller
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount() $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
->setCategory($category)->withBudgetInformation()->withCategoryInformation(); ->setCategory($category)->withBudgetInformation()->withCategoryInformation()->disableInternalFilter();
$journals = $collector->getPaginatedJournals(); $journals = $collector->getPaginatedJournals();
$journals->setPath('categories/show/' . $category->id); $journals->setPath('categories/show/' . $category->id);
$count = $journals->getCollection()->count(); $count = $journals->getCollection()->count();
@@ -479,13 +479,22 @@ class CategoryController extends Controller
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $end, $currentEnd); $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $end, $currentEnd);
$dateStr = $end->format('Y-m-d'); $dateStr = $end->format('Y-m-d');
$dateName = Navigation::periodShow($end, $range); $dateName = Navigation::periodShow($end, $range);
// amount transferred
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($end, $currentEnd)->setCategory($category)
->withOpposingAccount()->setTypes([TransactionType::TRANSFER])->disableInternalFilter();
$transferred = Steam::positive($collector->getJournals()->sum('transaction_amount'));
$entries->push( $entries->push(
[ [
'string' => $dateStr, 'string' => $dateStr,
'name' => $dateName, 'name' => $dateName,
'spent' => $spent, 'spent' => $spent,
'earned' => $earned, 'earned' => $earned,
'date' => clone $end, 'transferred' => $transferred,
'date' => clone $end,
] ]
); );
$end = Navigation::subtractPeriod($end, $range, 1); $end = Navigation::subtractPeriod($end, $range, 1);

View File

@@ -109,6 +109,10 @@
<td style="width:33%;">{{ 'earned'|_ }}</td> <td style="width:33%;">{{ 'earned'|_ }}</td>
<td style="text-align: right;">{{ period.earned|formatAmount }}</td> <td style="text-align: right;">{{ period.earned|formatAmount }}</td>
</tr> </tr>
<tr>
<td style="width:33%;">{{ 'transferred'|_ }}</td>
<td style="text-align: right;" class="text-info">{{ period.transferred|formatAmountPlain }}</td>
</tr>
</table> </table>
</div> </div>
</div> </div>