Cleanup logs, fixed add Venta, fixed search

This commit is contained in:
2024-01-19 23:10:20 -03:00
parent f55e4dbd5f
commit fa11f5b240
15 changed files with 238 additions and 91 deletions

View File

@ -100,17 +100,22 @@ class Venta
$venta_data[$field] = $forma_pago->{$name}->id;
}
}
$venta = $this->ventaRepository->create($venta_data);
$venta = $this->ventaRepository->save($venta);
$tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('vigente');
$estado = $this->estadoVentaRepository->create([
'venta' => $venta->id,
'estado' => $tipoEstado->id,
'fecha' => $venta->fecha->format('Y-m-d')
]);
$this->estadoVentaRepository->save($estado);
try {
return $this->ventaRepository->fetchByPropietarioAndPropiedad($propietario->rut, $propiedad->id);
} catch (Implement\Exception\EmptyResult) {
$venta = $this->ventaRepository->create($venta_data);
$venta = $this->ventaRepository->save($venta);
return $venta;
$tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('vigente');
$estado = $this->estadoVentaRepository->create([
'venta' => $venta->id,
'estado' => $tipoEstado->id,
'fecha' => $venta->fecha->format('Y-m-d')
]);
$this->estadoVentaRepository->save($estado);
return $venta;
}
}
protected function addPropietario(array $data): Model\Venta\Propietario
{