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