Cambios al api revisado en UI

This commit is contained in:
2021-07-29 22:05:38 -04:00
parent e338e39e75
commit 4374392af1
5 changed files with 59 additions and 2 deletions

View File

@ -12,6 +12,15 @@ class Entradas {
public function __invoke(Request $request, Response $response, Factory $factory): Response {
$entradas = $factory->find(Entrada::class)->array();
if ($entradas !== null) {
usort($entradas, function($a, $b) {
$d = $a['fecha'] - $b['fecha'];
if ($d === 0) {
return strcmp($a['cuenta']['nombre'], $b['cuenta']['nombre']);
}
return $d;
});
}
$output = [
'entradas' => $entradas
];

View File

@ -69,6 +69,13 @@ class Fuentes {
if ($fuente !== null) {
$entradas = $fuente->entradas();
if ($entradas !== null) {
usort($entradas, function($a, $b) {
$d = $a->fecha()->diffInDays($b->fecha(), false);
if ($d === 0) {
return strcmp($a->cuenta()->nombre, $b->cuenta()->nombre);
}
return $d;
});
array_walk($entradas, function(&$item) {
$item = $item->toArray();
});