Simplificacion de retorno de ventas por unidades

This commit is contained in:
Juan Pablo Vial
2025-04-22 13:08:15 -04:00
parent 5147450ed6
commit eabdab23c3
3 changed files with 48 additions and 4 deletions

View File

@ -108,11 +108,11 @@ class Venta extends Service
public function getActiveByUnidadIds(array $unidad_ids): array
{
try {
$ventas = $this->ventaRepository->fetchActiveByUnidadIds($unidad_ids);
$ventas = $this->ventaRepository->fetchActiveArrayByUnidadIds($unidad_ids);
return array_map(function($data) {
return [
'unidad_id' => $data['unidad_id'],
'venta' => $this->process($data['venta'])
'venta' => $this->processSimple($data['venta'])
];
}, $ventas);
} catch (Implement\Exception\EmptyResult $exception) {
@ -189,6 +189,18 @@ class Venta extends Service
return $venta;
}
/**
* @param array $venta
* @return array
* @throws Read
*/
protected function processSimple(array $venta): array
{
$output = $venta;
$output['propiedad'] = $this->propiedadService->getArrayById($venta['propiedad']);
return $output;
}
/**
* @throws Exception
*/