From 43977d1bd966f5a31b8c8095b923198c39c2f913 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Mon, 4 Dec 2023 19:51:44 -0300 Subject: [PATCH] FIX: IPC no disponible --- app/resources/views/ventas/facturacion/show.blade.php | 8 ++++++++ app/src/Model/Proyecto/Terreno.php | 2 +- app/src/Service/IPC.php | 8 +++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/resources/views/ventas/facturacion/show.blade.php b/app/resources/views/ventas/facturacion/show.blade.php index 2d4edad..aa40a96 100644 --- a/app/resources/views/ventas/facturacion/show.blade.php +++ b/app/resources/views/ventas/facturacion/show.blade.php @@ -62,6 +62,14 @@ @endif + @if ($IPC->get($venta->proyecto()->terreno->fecha, $venta->currentEstado()->fecha) === 0.0) +
+ +
+ IPC no disponible para este mes. +
+
+ @endif
diff --git a/app/src/Model/Proyecto/Terreno.php b/app/src/Model/Proyecto/Terreno.php index b76a04b..cdb1bd8 100644 --- a/app/src/Model/Proyecto/Terreno.php +++ b/app/src/Model/Proyecto/Terreno.php @@ -16,7 +16,7 @@ class Terreno implements JsonSerializable return [ 'superficie' => $this->superficie, 'valor' => $this->valor, - 'date' => $this->fecha?->format('Y-m-d') + 'fecha' => $this->fecha?->format('Y-m-d') ]; } } diff --git a/app/src/Service/IPC.php b/app/src/Service/IPC.php index b6d6699..1c1acfc 100644 --- a/app/src/Service/IPC.php +++ b/app/src/Service/IPC.php @@ -26,6 +26,9 @@ class IPC } } catch (EmptyRedis) { $ipc = $this->moneyService->getIPC($from, $to); + if ($ipc === -1.0) { + return 0; + } $ipcs[$dateKey] = $ipc; ksort($ipcs); $this->redisService->set($this->redisKey, json_encode($ipcs), 60 * 60 * 24 * 30); @@ -34,6 +37,9 @@ class IPC } public function readjust(float $base, DateTimeInterface $from, DateTimeInterface $to = new DateTimeImmutable()):float { - return $base * (1 + $this->get($from, $to->sub(new DateInterval('P1M')))); + if (($ipc = $this->get($from, $to->sub(new DateInterval('P1M')))) === 0.0) { + return 0; + } + return $base * (1 + $ipc); } }