And fix sorting.

This commit is contained in:
James Cole 2019-08-17 08:04:41 +02:00
parent 7f887e294a
commit b97d3d3627
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -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;
}