From b97d3d3627753bbb3d5333ff3bc00a9855f885da Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 17 Aug 2019 08:04:41 +0200 Subject: [PATCH] And fix sorting. --- app/Repositories/Account/AccountTasker.php | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php index 81664d9802..f58a6d6dce 100644 --- a/app/Repositories/Account/AccountTasker.php +++ b/app/Repositories/Account/AccountTasker.php @@ -146,15 +146,14 @@ class AccountTasker implements AccountTaskerInterface $report = $this->groupExpenseByDestination($journals); - // TODO sorting -// // sort the result -// // Obtain a list of columns -// $sum = []; -// foreach ($expenses as $accountId => $row) { -// $sum[$accountId] = (float)$row['sum']; -// } -// -// array_multisort($sum, SORT_ASC, $expenses); + // sort the result + // Obtain a list of columns + $sum = []; + foreach ($report['accounts'] as $accountId => $row) { + $sum[$accountId] = (float)$row['sum']; + } + + array_multisort($sum, SORT_ASC, $report['accounts']); return $report; } @@ -181,13 +180,12 @@ class AccountTasker implements AccountTaskerInterface // sort the result // Obtain a list of columns - // $sum = []; - // foreach ($report['income'] as $accountId => $row) { - // $sum[$accountId] = (float)$row['sum']; - // } - // TODO proper sorting. - //array_multisort($sum, SORT_DESC, $report); - // var_dump($report);exit; + $sum = []; + foreach ($report['accounts'] as $accountId => $row) { + $sum[$accountId] = (float)$row['sum']; + } + + array_multisort($sum, SORT_DESC, $report['accounts']); return $report; }