v0.1.0
This commit is contained in:
@ -41,4 +41,10 @@ class Facturas {
|
||||
];
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function add_venta(Request $request, Response $response, $id_factura): Response {
|
||||
$post = $request->getParsedBody();
|
||||
$factura = Model::factory(FacturaProyectoOperador::class)->find_one($id_factura);
|
||||
$output = $factura->addVenta($post);
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
@ -28,4 +28,20 @@ class Ventas {
|
||||
];
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function facturas(Request $request, Response $response, $id_venta): Response {
|
||||
$venta = Model::factory(Venta::class)->find_one($id_venta);
|
||||
if (!$venta) {
|
||||
return $this->withJson($response, ['venta' =>null, 'facturas' => null]);
|
||||
}
|
||||
$output = [
|
||||
'venta' => $venta->as_array(),
|
||||
'facturas' => null
|
||||
];
|
||||
if ($venta->facturas() !== null) {
|
||||
$output['facturas'] = array_map(function($item) {
|
||||
return $item->as_array();
|
||||
}, $venta->facturas());
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user