Merge pull request #11450 from 4rkDev/fix/verifactu-qr-amount

Fix Verifactu QR amount
This commit is contained in:
David Bomba 2025-11-26 18:23:38 +11:00 committed by GitHub
commit 02d53f749b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 1 deletions

View File

@ -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,