diff --git a/app/Controller/Informes.php b/app/Controller/Informes.php index e4c4a12..bc40396 100644 --- a/app/Controller/Informes.php +++ b/app/Controller/Informes.php @@ -486,7 +486,10 @@ class Informes $info['Tipo'] = $venta->unidad()->abreviacion; $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); $info['Valor Promesa'] = $venta->valor_uf; - $info['Pie'] = $venta->pie()->valor; + $info['Pie'] = 0; + if ($venta->pie()) { + $info['Pie'] = $venta->pie()->valor; + } $info['Pie Pagado'] = 0; $info['% Pie Pagado'] = 0; if ($venta->pie()) { @@ -510,10 +513,10 @@ class Informes } $info['Credito'] = 0; $info['Banco'] = ''; - if ($venta->credito != 0) { - $info['Credito'] = $venta->credito()->pago()->valor('ufs'); - if ($venta->credito()->pago()->banco != 0) { - $info['Banco'] = $venta->credito()->pago()->banco()->nombre; + if ($venta->credito != 0 and $venta->credito()->pago()) { + $info['Credito'] = $venta->credito()?->pago()->valor('ufs'); + if ($venta->credito()?->pago()->banco != 0) { + $info['Banco'] = $venta->credito()?->pago()->banco()->nombre; } } $info['Valor Ests & Bods'] = $venta->valorEstacionamientosYBodegas(); @@ -525,6 +528,9 @@ class Informes $info['Precio'] = 0; try { $info['Precio'] = array_reduce($venta->propiedad()->departamentos(), function($sum, $item) use ($fecha) { + if (!$item->precio($fecha)) { + return $sum; + } return $sum + $item->precio($fecha)->valor; }); } catch (\Exception $e) { diff --git a/app/Helper/functions.php b/app/Helper/functions.php index 2be4618..5b61120 100644 --- a/app/Helper/functions.php +++ b/app/Helper/functions.php @@ -39,17 +39,16 @@ function uf($date, $async = false) { return (object) ['total' => 0]; } $url = 'http://' . config('locations.money') . '/api/uf/value/' . $date->format('Y-m-d'); - $client = new \Goutte\Client(); - $client->setHeader('Accept', 'application/json'); - $client->request('GET', $url); + $client = new \GuzzleHttp\Client(['base_uri' => 'http://' . config('locations.money') . '/', 'headers' => ['Accept' => 'application/json']]); + $response = $client->get('api/uf/value/' . $date->format('Y-m-d')); - $response = $client->getResponse(); + //$response = $client->getResponse(); if (!$response) { return (object) ['total' => 0]; } $status = $response->getStatusCode(); if ($status >= 200 and $status < 300) { - $data = json_decode($response->getContent()); + $data = json_decode($response->getBody()->getContents()); return $data; } return (object) ['total' => 0]; diff --git a/config/locations.php b/config/locations.php index f0a3c43..05442b6 100644 --- a/config/locations.php +++ b/config/locations.php @@ -11,6 +11,6 @@ return [ 'controllers' => '{locations.app}/Controller', 'money' => 'provm.cl/optimus/money', 'api' => '192.168.1.100/intranet/api', - 'api_url' => '/incoviba/api' + 'api_url' => '/api' ]; ?> diff --git a/resources/views/buscar/buscar.blade.php b/resources/views/buscar/buscar.blade.php index c6544bf..6312bb0 100644 --- a/resources/views/buscar/buscar.blade.php +++ b/resources/views/buscar/buscar.blade.php @@ -66,9 +66,11 @@
+ @if (isset($results) and is_array($results) and count($results) > 0) @foreach ($results as $resultado) - @include('buscar.resultado') + @include('buscar.resultado', ['resultado' => $resultado]) @endforeach + @endif