mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix sorting.
This commit is contained in:
parent
b5a5a216cd
commit
3833a41acb
@ -102,6 +102,38 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getCategoriesWithExpenses(Carbon $start, Carbon $end, Collection $accounts): Collection
|
||||||
|
{
|
||||||
|
/** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
|
||||||
|
$repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||||
|
$collection = $repository->earnedForAccountsPerMonth($accounts, $start, $end);
|
||||||
|
$second = $repository->spentForAccountsPerMonth($accounts, $start, $end);
|
||||||
|
$collection = $collection->merge($second);
|
||||||
|
$array = [];
|
||||||
|
/** @var Category $category */
|
||||||
|
foreach ($collection as $category) {
|
||||||
|
$id = $category->id;
|
||||||
|
$array[$id] = $category;
|
||||||
|
|
||||||
|
}
|
||||||
|
$set = new Collection($array);
|
||||||
|
|
||||||
|
$set = $set->sort(
|
||||||
|
function (Category $category) {
|
||||||
|
return $category->name;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $set;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
@ -312,30 +344,4 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
|
|
||||||
return $sum;
|
return $sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getCategoriesWithExpenses(Carbon $start, Carbon $end, Collection $accounts): Collection
|
|
||||||
{
|
|
||||||
/** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
|
|
||||||
$repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
|
||||||
$collection = $repository->earnedForAccountsPerMonth($accounts, $start, $end);
|
|
||||||
$second = $repository->spentForAccountsPerMonth($accounts, $start, $end);
|
|
||||||
$collection = $collection->merge($second);
|
|
||||||
$array = [];
|
|
||||||
/** @var Category $category */
|
|
||||||
foreach ($collection as $category) {
|
|
||||||
$id = $category->id;
|
|
||||||
$array[$id] = $category;
|
|
||||||
|
|
||||||
}
|
|
||||||
$set = new Collection($array);
|
|
||||||
|
|
||||||
return $set;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user