Subir cartolas procesadas
This commit is contained in:
@ -23,29 +23,30 @@ class Movimientos extends Ideal\Controller
|
||||
'movimiento_id' => $movimiento_id,
|
||||
'input' => $body,
|
||||
'status' => false,
|
||||
'movimiento' => null,
|
||||
'centro' => null,
|
||||
'detalle' => ''
|
||||
'movimiento' => null
|
||||
];
|
||||
try {
|
||||
$movimiento = $movimientoService->getById($movimiento_id);
|
||||
$output['movimiento'] = $this->movimientosToArray([$movimiento])[0];
|
||||
$data = [];
|
||||
if (isset($body['centro_id'])) {
|
||||
$centro = $centroCostoRepository->fetchById($body['centro_id']);
|
||||
$data['centro_costo_id'] = $centro->id;
|
||||
}
|
||||
if (isset($body['detalle'])) {
|
||||
$data['detalle'] = $body['detalle'];
|
||||
$fieldMap = [
|
||||
'centro_costo_id',
|
||||
'categoria',
|
||||
'detalle',
|
||||
'rut',
|
||||
'digito',
|
||||
'nombres',
|
||||
'identificador'
|
||||
];
|
||||
foreach ($fieldMap as $field) {
|
||||
if (key_exists($field, $body)) {
|
||||
$data[$field] = $body[$field];
|
||||
}
|
||||
}
|
||||
|
||||
$movimientoService->setDetalles($movimiento, $data);
|
||||
$output['movimiento'] = $this->movimientosToArray([$movimientoService->getById($movimiento->id)])[0];
|
||||
if (isset($body['centro_id'])) {
|
||||
$output['centro'] = $centro;
|
||||
}
|
||||
if (isset($body['detalle'])) {
|
||||
$output['detalle'] = $body['detalle'];
|
||||
}
|
||||
$output['status'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
Reference in New Issue
Block a user