Various report updates and code cleanup.

This commit is contained in:
James Cole
2016-12-04 18:02:19 +01:00
parent 905a2432c6
commit f4b9b7ae84
32 changed files with 592 additions and 450 deletions

View File

@@ -42,22 +42,6 @@ class BudgetReportHelper implements BudgetReportHelperInterface
$this->repository = $repository;
}
/**
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return array
*/
public function getBudgetPeriodReport(Carbon $start, Carbon $end, Collection $accounts): array
{
$budgets = $this->repository->getBudgets();
$report = $this->repository->getBudgetPeriodReport($budgets, $accounts, $start, $end, true);
$data = $this->filterBudgetPeriodReport($report);
return $data;
}
/**
* @param Carbon $start
* @param Carbon $end
@@ -162,31 +146,4 @@ class BudgetReportHelper implements BudgetReportHelperInterface
return $array;
}
/**
* Filters empty results from getBudgetPeriodReport
*
* @param array $data
*
* @return array
*/
private function filterBudgetPeriodReport(array $data): array
{
/**
* @var int $budgetId
* @var array $set
*/
foreach ($data as $budgetId => $set) {
$sum = '0';
foreach ($set['entries'] as $amount) {
$sum = bcadd($amount, $sum);
}
$data[$budgetId]['sum'] = $sum;
if (bccomp('0', $sum) === 0) {
unset($data[$budgetId]);
}
}
return $data;
}
}