mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-29 06:34:37 +00:00
First part of a large code cleanup commit.
This commit is contained in:
@@ -30,32 +30,6 @@ 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.
|
||||
*
|
||||
@@ -73,6 +47,33 @@ trait BasicDataSupport
|
||||
return $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the ID in a given array. Return '0' of not there (amount).
|
||||
*
|
||||
@@ -83,10 +84,7 @@ trait BasicDataSupport
|
||||
*/
|
||||
protected function isInArray(array $array, int $entryId) // helper for data (math, calculations)
|
||||
{
|
||||
$result = '0';
|
||||
if (isset($array[$entryId])) {
|
||||
$result = $array[$entryId];
|
||||
}
|
||||
$result = $array[$entryId] ?? '0';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user