report->categories as $accountCategoryName => $accountCategory) { $categories[] = [ 'header' => ['', $accountCategoryName, '', '', '', '', ''], 'data' => array_map(static function (AccountDTO $account) { return [ $account->accountCode, $account->accountName, $account->balance->startingBalance ?? '', $account->balance->debitBalance, $account->balance->creditBalance, $account->balance->netMovement, $account->balance->endingBalance ?? '', ]; }, $accountCategory->accounts), 'summary' => [ '', 'Total ' . $accountCategoryName, $accountCategory->summary->startingBalance ?? '', $accountCategory->summary->debitBalance, $accountCategory->summary->creditBalance, $accountCategory->summary->netMovement, $accountCategory->summary->endingBalance ?? '', ], ]; } return $categories; } public function getOverallTotals(): array { return [ '', 'Total for all accounts', '', $this->report->overallTotal->debitBalance, $this->report->overallTotal->creditBalance, '', '', ]; } }