Skip to content

Firefly III: a personal finances manager

Fix small issues in the category overview and the journal collector.

James Coleebdd64f46f77
diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php
index 5e3b3a09ef..35f4329d95 100644
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@ -214,7 +214,7 @@ class BillController extends Controller
// use collector:
$collector = new JournalCollector(auth()->user());
- $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->setPage($page)->setLimit($pageSize);
+ $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->setLimit($pageSize)->setPage($page);
$journals = $collector->getPaginatedJournals();
$journals->setPath('/bills/show/' . $bill->id);
diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php
index bd6c9178da..38f544598a 100644
--- a/app/Http/Controllers/CategoryController.php
+++ b/app/Http/Controllers/CategoryController.php
@@ -194,7 +194,7 @@ class CategoryController extends Controller
// use journal collector
$collector = app(JournalCollectorInterface::class);
- $collector->setPage($page)->setLimit($pageSize)->setAllAssetAccounts()->setRange($start, $end)->setCategory($category);
+ $collector->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->setRange($start, $end)->setCategory($category);
$journals = $collector->getPaginatedJournals();
$journals->setPath('categories/show/' . $category->id);
@@ -226,7 +226,7 @@ class CategoryController extends Controller
// new collector:
$collector = app(JournalCollectorInterface::class);
- $collector->setPage($page)->setLimit($pageSize)->setAllAssetAccounts()->setRange($start, $end)->setCategory($category);
+ $collector->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->setCategory($category);
$journals = $collector->getPaginatedJournals();
$journals->setPath('categories/show/' . $category->id . '/all');
@@ -253,7 +253,7 @@ class CategoryController extends Controller
// new collector:
$collector = app(JournalCollectorInterface::class);
- $collector->setPage($page)->setLimit($pageSize)->setAllAssetAccounts()->setRange($start, $end)->setCategory($category);
+ $collector->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->setRange($start, $end)->setCategory($category);
$journals = $collector->getPaginatedJournals();
$journals->setPath('categories/show/' . $category->id . '/' . $date);
diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php
index 65b46ad44c..4d32e42fa6 100644
--- a/app/Repositories/Category/CategoryRepository.php
+++ b/app/Repositories/Category/CategoryRepository.php
@@ -134,27 +134,27 @@ class CategoryRepository implements CategoryRepositoryInterface
{
$first = null;
-
- /** @var TransactionJournal $first */
+ /** @var TransactionJournal $firstJournal */
$firstJournal = $category->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.date']);
if ($firstJournal) {
$first = $firstJournal->date;
}
-
// check transactions:
-
$firstTransaction = $category->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->orderBy('transaction_journals.date', 'ASC')->first(['transaction_journals.date']);
- if (!is_null($firstTransaction) && ((!is_null($first) && $firstTransaction->date < $first) || is_null($first))) {
- $first = new Carbon($firstTransaction->date);
+ // both exist, the one that is earliest "wins".
+ if (!is_null($firstTransaction) && !is_null($first) && $firstTransaction->date->lt($first)) {
+ $first = $firstTransaction->date;
}
+
if (is_null($first)) {
return new Carbon('1900-01-01');
}
+
return $first;
}