Fix some report issues.

This commit is contained in:
James Cole
2019-08-17 07:47:39 +02:00
parent 3e242aaca6
commit 6f78735bc5
5 changed files with 21 additions and 24 deletions

View File

@@ -113,8 +113,6 @@ trait ChartGeneration
* @param Carbon $end
*
* @return array
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function getChartData(Collection $accounts, Carbon $start, Carbon $end): array // chart helper function
{
@@ -138,25 +136,24 @@ trait ChartGeneration
$currentEnd = app('navigation')->endOfPeriod($currentStart, '1M');
$earned = (string)array_sum(
array_map(
function ($item) {
static function ($item) {
return $item['sum'];
},
$tasker->getIncomeReport($currentStart, $currentEnd, $accounts)
$tasker->getIncomeReport($currentStart, $currentEnd, $accounts)['accounts']
)
);
$spent = (string)array_sum(
array_map(
function ($item) {
static function ($item) {
return $item['sum'];
},
$tasker->getExpenseReport($currentStart, $currentEnd, $accounts)
$tasker->getExpenseReport($currentStart, $currentEnd, $accounts)['accounts']
)
);
$label = $currentStart->format('Y-m') . '-01';
$spentArray[$label] = bcmul($spent, '-1');
$earnedArray[$label] = $earned;
$earnedArray[$label] = bcmul($earned, '-1');
$currentStart = app('navigation')->addPeriod($currentStart, '1M', 0);
}
$result = [