FIX: IPC no disponible
This commit is contained in:
@ -62,6 +62,14 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</form>
|
</form>
|
||||||
|
@if ($IPC->get($venta->proyecto()->terreno->fecha, $venta->currentEstado()->fecha) === 0.0)
|
||||||
|
<div class="ui compact icon error message">
|
||||||
|
<i class="exclamation triangle icon"></i>
|
||||||
|
<div class="content">
|
||||||
|
IPC no disponible para este mes.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
<div id="factura">
|
<div id="factura">
|
||||||
<div class="ui compact grid">
|
<div class="ui compact grid">
|
||||||
|
@ -16,7 +16,7 @@ class Terreno implements JsonSerializable
|
|||||||
return [
|
return [
|
||||||
'superficie' => $this->superficie,
|
'superficie' => $this->superficie,
|
||||||
'valor' => $this->valor,
|
'valor' => $this->valor,
|
||||||
'date' => $this->fecha?->format('Y-m-d')
|
'fecha' => $this->fecha?->format('Y-m-d')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ class IPC
|
|||||||
}
|
}
|
||||||
} catch (EmptyRedis) {
|
} catch (EmptyRedis) {
|
||||||
$ipc = $this->moneyService->getIPC($from, $to);
|
$ipc = $this->moneyService->getIPC($from, $to);
|
||||||
|
if ($ipc === -1.0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
$ipcs[$dateKey] = $ipc;
|
$ipcs[$dateKey] = $ipc;
|
||||||
ksort($ipcs);
|
ksort($ipcs);
|
||||||
$this->redisService->set($this->redisKey, json_encode($ipcs), 60 * 60 * 24 * 30);
|
$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
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user