From 2227331c3f038c22e247eca1b0f13c2271d3ee4c Mon Sep 17 00:00:00 2001 From: Sajo <75281007+sajotrei@users.noreply.github.com> Date: Thu, 22 Oct 2026 13:24:47 +0200 Subject: [PATCH] fix: stop autofattura creation when no VAT-compatible rows exist --- modules/fatture/actions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index e6df66b5c..bd9d73215 100755 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -1086,6 +1086,12 @@ function getIvaDichiarazione() { ->whereIn('co_iva.codice_natura_fe', $natura_fe_list) ->get(['co_righe_documenti.subtotale', 'co_righe_documenti.sconto', 'co_iva.indetraibile', 'co_iva.id as id_iva']); + if ($righe_fe->isEmpty()) { + flash()->error(tr("Impossibile creare l'autofattura: nessuna riga della fattura di acquisto ha un'aliquota IVA compatibile. Verificare le aliquote IVA.")); + + break; + } + $imponibile = $righe_fe->where('indetraibile', '!=', 100)->sum('subtotale'); $sconto = $righe_fe->where('indetraibile', '!=', 100)->sum('sconto'); $imponibile_indetraibile = $righe_fe->where('indetraibile', 100)->sum('subtotale');