FIX: valor cuota cuando UF no existe.

This commit is contained in:
Juan Pablo Vial
2025-05-30 17:10:59 -04:00
parent 734f258382
commit a54586e870

View File

@ -3,6 +3,7 @@ namespace Incoviba\Service\Venta\MediosPago\Toku;
use DateMalformedStringException; use DateMalformedStringException;
use DateTimeImmutable; use DateTimeImmutable;
use DateTimeZone;
use Psr\Http\Client\ClientInterface; use Psr\Http\Client\ClientInterface;
use Incoviba\Common\Implement\Exception\EmptyResponse; use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Common\Implement\Exception\EmptyResult; use Incoviba\Common\Implement\Exception\EmptyResult;
@ -151,6 +152,8 @@ class Invoice extends AbstractEndPoint
'invoice_external_id' => 'cuota_id' 'invoice_external_id' => 'cuota_id'
]; ];
$today = new DateTimeImmutable('now', new DateTimeZone('America/Santiago'));
$params = []; $params = [];
foreach ($paramsMap as $key => $ref) { foreach ($paramsMap as $key => $ref) {
if ($ref === null) { if ($ref === null) {
@ -161,7 +164,10 @@ class Invoice extends AbstractEndPoint
continue; continue;
} }
if ($ref === 'valor') { if ($ref === 'valor') {
$valor = $data['cuota']->pago->valor(); $valor = 0;
if ($data['cuota']->pago->fecha <= $today) {
$valor = $data['cuota']->pago->valor();
}
if ($valor === 0) { if ($valor === 0) {
$valor = $data['cuota']->pago->valor / $data['venta']->uf; $valor = $data['cuota']->pago->valor / $data['venta']->uf;
} }