mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fixes for #109.
This commit is contained in:
@@ -309,7 +309,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
$cache->addProperty($category->id);
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('spentInPeriod');
|
||||
$cache->addProperty('earnedInPeriod');
|
||||
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
@@ -323,4 +323,36 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param int $page
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end)
|
||||
{
|
||||
$offset = $page > 0 ? $page * 50 : 0;
|
||||
|
||||
return $category->transactionJournals()
|
||||
->after($start)
|
||||
->before($end)
|
||||
->withRelevantData()->take(50)->offset($offset)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->get(
|
||||
['transaction_journals.*']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end)
|
||||
{
|
||||
return $category->transactionJournals()->before($end)->after($start)->count();
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,13 @@ interface CategoryRepositoryInterface
|
||||
*/
|
||||
public function countJournals(Category $category);
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
@@ -57,6 +64,14 @@ interface CategoryRepositoryInterface
|
||||
*/
|
||||
public function getJournals(Category $category, $page);
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param int $page
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* This method returns the sum of the journals in the category, optionally
|
||||
* limited by a start or end date.
|
||||
|
Reference in New Issue
Block a user