From 3484effbab8d6860c4628509850fbb629c3e52b2 Mon Sep 17 00:00:00 2001 From: Jonay Marrero Date: Tue, 25 Nov 2025 14:34:12 +0000 Subject: [PATCH] Fix Verifactu QR amount --- .../EDocument/Standards/Verifactu.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Services/EDocument/Standards/Verifactu.php b/app/Services/EDocument/Standards/Verifactu.php index 55fe52df0e..52323f3a7a 100644 --- a/app/Services/EDocument/Standards/Verifactu.php +++ b/app/Services/EDocument/Standards/Verifactu.php @@ -196,7 +196,24 @@ class Verifactu extends AbstractService $nif = $log->nif; $invoiceNumber = $log->invoice_number; $date = $log->date->format('d-m-Y'); - $total = (string)round($log->invoice->amount, 2); + $totalAmount = $log->invoice->amount; + + // Intentar usar el importe que realmente se envió a la AEAT (sin retenciones) + try { + $state = @unserialize($log->state); + + if ($state instanceof VerifactuInvoice) { + $stateTotal = $state->getImporteTotal(); + + if (is_numeric($stateTotal)) { + $totalAmount = (float)$stateTotal; + } + } + } catch (\Throwable $e) { + nlog('VERIFACTU WARNING: [qr-state]' . $e->getMessage()); + } + + $total = (string)round($totalAmount, 2); $url = sprintf( $this->aeat_client->base_qr_url,