This commit is contained in:
2021-08-18 19:03:58 -04:00
parent b58cda3e4e
commit 4f7241e146
12 changed files with 143 additions and 25 deletions

View File

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

View File

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