Missing categoria from cuentas
This commit is contained in:
@ -82,6 +82,15 @@ class Cuentas {
|
|||||||
];
|
];
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
|
public function categoria(Request $request, Response $response, Factory $factory, $cuenta_id): Response {
|
||||||
|
$cuenta = $factory->find(Cuenta::class)->one($cuenta_id);
|
||||||
|
$output = [
|
||||||
|
'input' => $cuenta_id,
|
||||||
|
'cuenta' => $cuenta?->toArray(),
|
||||||
|
'categoria' => $cuenta?->categoria()->toArray()
|
||||||
|
];
|
||||||
|
return $this->withJson($response, $output);
|
||||||
|
}
|
||||||
public function entradas(Request $request, Response $response, Factory $factory, $cuenta_id): Response {
|
public function entradas(Request $request, Response $response, Factory $factory, $cuenta_id): Response {
|
||||||
$cuenta = $factory->find(Cuenta::class)->one($cuenta_id);
|
$cuenta = $factory->find(Cuenta::class)->one($cuenta_id);
|
||||||
$entradas = null;
|
$entradas = null;
|
||||||
@ -120,6 +129,8 @@ class Cuentas {
|
|||||||
$arr['valorFormateado'] = $cuenta->moneda()->format($arr['valor']);
|
$arr['valorFormateado'] = $cuenta->moneda()->format($arr['valor']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$arr['debito']['categoria'] = $transaccion->debito()->categoria()->toArray();
|
||||||
|
$arr['credito']['categoria'] = $transaccion->credito()->categoria()->toArray();
|
||||||
$transaccion = $arr;
|
$transaccion = $arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ $app->group('/cuenta/{cuenta_id}', function($app) {
|
|||||||
$app->get('/amount', [Cuentas::class, 'transaccionesAmount']);
|
$app->get('/amount', [Cuentas::class, 'transaccionesAmount']);
|
||||||
$app->get('[/{limit:[0-9]+}[/{start:[0-9]+}]]', [Cuentas::class, 'transacciones']);
|
$app->get('[/{limit:[0-9]+}[/{start:[0-9]+}]]', [Cuentas::class, 'transacciones']);
|
||||||
});
|
});
|
||||||
|
$app->get('/categoria', [Cuentas::class, 'categoria']);
|
||||||
$app->put('/edit', [Cuentas::class, 'edit']);
|
$app->put('/edit', [Cuentas::class, 'edit']);
|
||||||
$app->delete('/delete', [Cuentas::class, 'delete']);
|
$app->delete('/delete', [Cuentas::class, 'delete']);
|
||||||
$app->get('[/]', [Cuentas::class, 'show']);
|
$app->get('[/]', [Cuentas::class, 'show']);
|
||||||
|
@ -96,6 +96,9 @@ const transacciones = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.cuenta = data.cuenta
|
this.cuenta = data.cuenta
|
||||||
|
sendGet(_urls.api + '/cuenta/' + this.cuenta_id + '/categoria').then((resp) => {
|
||||||
|
this.cuenta.categoria = resp.categoria
|
||||||
|
}).then(() => {
|
||||||
this.saldo = this.cuenta.saldo
|
this.saldo = this.cuenta.saldo
|
||||||
$('#cuenta').html(this.cuenta.nombre + ' (' + this.cuenta.categoria.nombre + ')').append(
|
$('#cuenta').html(this.cuenta.nombre + ' (' + this.cuenta.categoria.nombre + ')').append(
|
||||||
$('<i></i>').attr('class', 'square full icon').css('color', '#' + this.cuenta.tipo.color)
|
$('<i></i>').attr('class', 'square full icon').css('color', '#' + this.cuenta.tipo.color)
|
||||||
@ -131,6 +134,7 @@ const transacciones = {
|
|||||||
this.draw()
|
this.draw()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
cuentas: () => {
|
cuentas: () => {
|
||||||
return sendGet(_urls.api + '/cuentas').then((data) => {
|
return sendGet(_urls.api + '/cuentas').then((data) => {
|
||||||
@ -141,11 +145,18 @@ const transacciones = {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
const select = this.modal.find("[name='cuenta']")
|
const select = this.modal.find("[name='cuenta']")
|
||||||
$.each(this.cuentas, (i, el) => {
|
$.each(this.cuentas, (i, el) => {
|
||||||
|
this.get().categoria(i).then(() => {
|
||||||
select.append(
|
select.append(
|
||||||
$('<option></option>').attr('value', el.id).html(el.nombre + ' (' + el.categoria.nombre + ')')
|
$('<option></option>').attr('value', el.id).html(el.nombre + ' (' + el.categoria.nombre + ')')
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
categoria: (idx) => {
|
||||||
|
return sendGet(_urls.api + '/cuenta/' + this.cuentas[idx].id + '/categoria').then((data) => {
|
||||||
|
this.cuentas[idx].categoria = data.categoria
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -172,7 +183,7 @@ const transacciones = {
|
|||||||
fecha: fecha,
|
fecha: fecha,
|
||||||
valor: $("[name='cambio']").val()
|
valor: $("[name='cambio']").val()
|
||||||
})
|
})
|
||||||
sendPut(_urls.api + '/tipos/cambios/add', data1)
|
sendPost(_urls.api + '/tipos/cambios/add', data1)
|
||||||
|
|
||||||
const valor = $("[name='valor']").val()
|
const valor = $("[name='valor']").val()
|
||||||
const cuenta = $("[name='cuenta']").val()
|
const cuenta = $("[name='cuenta']").val()
|
||||||
|
Reference in New Issue
Block a user