mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Expand view of report and make multi currency
This commit is contained in:
@@ -81,6 +81,16 @@ class PopupReport implements PopupReportInterface
|
||||
*/
|
||||
public function balanceForNoBudget(Account $account, array $attributes): array
|
||||
{
|
||||
// filter by currency, if set.
|
||||
$currencyId = $attributes['currencyId'] ?? null;
|
||||
$currency = null;
|
||||
if (null !== $currencyId) {
|
||||
/** @var CurrencyRepositoryInterface $repos */
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = $repos->find((int)$currencyId);
|
||||
}
|
||||
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector
|
||||
@@ -91,6 +101,10 @@ class PopupReport implements PopupReportInterface
|
||||
->setRange($attributes['startDate'], $attributes['endDate'])
|
||||
->withoutBudget();
|
||||
|
||||
if (null !== $currency) {
|
||||
$collector->setCurrency($currency);
|
||||
}
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
@@ -139,12 +153,12 @@ class PopupReport implements PopupReportInterface
|
||||
/**
|
||||
* Collect journals by a category.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Category|null $category
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function byCategory(Category $category, array $attributes): array
|
||||
public function byCategory(?Category $category, array $attributes): array
|
||||
{
|
||||
// filter by currency, if set.
|
||||
$currencyId = $attributes['currencyId'] ?? null;
|
||||
@@ -163,8 +177,15 @@ class PopupReport implements PopupReportInterface
|
||||
->withAccountInformation()
|
||||
->withBudgetInformation()
|
||||
->withCategoryInformation()
|
||||
->setRange($attributes['startDate'], $attributes['endDate'])->withAccountInformation()
|
||||
->setCategory($category);
|
||||
->setRange($attributes['startDate'], $attributes['endDate'])->withAccountInformation();
|
||||
|
||||
if(null!== $category) {
|
||||
$collector->setCategory($category);
|
||||
}
|
||||
if(null === $category) {
|
||||
$collector->withoutCategory();
|
||||
}
|
||||
|
||||
if (null !== $currency) {
|
||||
$collector->setCurrency($currency);
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface PopupReportInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get balances for budget.
|
||||
*
|
||||
@@ -66,12 +67,12 @@ interface PopupReportInterface
|
||||
/**
|
||||
* Group by category.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Category|null $category
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function byCategory(Category $category, array $attributes): array;
|
||||
public function byCategory(?Category $category, array $attributes): array;
|
||||
|
||||
/**
|
||||
* Do something with expense. Sorry, I am not very inspirational here.
|
||||
|
Reference in New Issue
Block a user