mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 22:48:18 +00:00
Refactor various methods away from controllers
This commit is contained in:
@@ -30,6 +30,33 @@ namespace FireflyIII\Support\Http\Controllers;
|
||||
*/
|
||||
trait BasicDataSupport
|
||||
{
|
||||
|
||||
/**
|
||||
* Filters empty results from getBudgetPeriodReport.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function filterPeriodReport(array $data): array // helper function for period overview.
|
||||
{
|
||||
/**
|
||||
* @var int $entryId
|
||||
* @var array $set
|
||||
*/
|
||||
foreach ($data as $entryId => $set) {
|
||||
$sum = '0';
|
||||
foreach ($set['entries'] as $amount) {
|
||||
$sum = bcadd($amount, $sum);
|
||||
}
|
||||
$data[$entryId]['sum'] = $sum;
|
||||
if (0 === bccomp('0', $sum)) {
|
||||
unset($data[$entryId]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Sum up an array.
|
||||
*
|
||||
|
Reference in New Issue
Block a user