Updates
This commit is contained in:
@ -66,14 +66,15 @@ class Invoice extends AbstractEndPoint
|
||||
if ($data['status'] !== 'AUTHORIZED') {
|
||||
throw new InvalidResult("Pago no autorizado", 422);
|
||||
}
|
||||
$dateString = $data['date'];
|
||||
try {
|
||||
$date = new DateTimeImmutable($data['transaction_date']);
|
||||
$date = new DateTimeImmutable($dateString);
|
||||
} catch (DateMalformedStringException $exception) {
|
||||
throw new InvalidResult("Fecha no válida: {$data['transaction_date']}", 422, $exception);
|
||||
throw new InvalidResult("Fecha no válida: {$dateString}", 422, $exception);
|
||||
}
|
||||
$uf = $this->ufService->get($date);
|
||||
if ($uf === 0.0) {
|
||||
throw new InvalidResult("No hay UF para la fecha: {$data['transaction_date']}", 422);
|
||||
throw new InvalidResult("No hay UF para la fecha: {$dateString}", 422);
|
||||
}
|
||||
$valor = $data['amount'] / $uf;
|
||||
if (abs($valor - $invoice->cuota->pago->valor()) >= 0.0001) {
|
||||
|
Reference in New Issue
Block a user