From 125ba7b02fa2c92bfcb9c989235386e976b005d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Apr 2026 19:03:53 +0200 Subject: [PATCH] Clean code --- .../facture/doc/pdf_sponge.modules.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 5da913a611b..2eac789a8aa 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1964,6 +1964,8 @@ class pdf_sponge extends ModelePDFFactures if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) { // Nothing to do } else { + $tmpatleastoneratenotnull = 0; + // Local tax 1 before VAT foreach ($this->localtax1 as $localtax_type => $localtax_rate) { if (in_array((string) $localtax_type, array('1', '3', '5'))) { @@ -1972,7 +1974,7 @@ class pdf_sponge extends ModelePDFFactures foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX1_LINE_IF_ZERO')) { - //$this->atleastoneratenotnull++; + //$tmpatleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -2010,7 +2012,7 @@ class pdf_sponge extends ModelePDFFactures foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX2_LINE_IF_ZERO')) { - //$this->atleastoneratenotnull++; + //$tmpatleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -2063,11 +2065,11 @@ class pdf_sponge extends ModelePDFFactures } } - if (!getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) { + if (!getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) { // by default, we show detail of vat here // VAT foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_VAT_LINE_IF_ZERO')) { - $this->atleastoneratenotnull++; + $tmpatleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -2097,7 +2099,7 @@ class pdf_sponge extends ModelePDFFactures } } - //Local tax 1 after VAT + // Local tax 1 after VAT foreach ($this->localtax1 as $localtax_type => $localtax_rate) { if (in_array((string) $localtax_type, array('2', '4', '6'))) { continue; @@ -2105,7 +2107,7 @@ class pdf_sponge extends ModelePDFFactures foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX1_LINE_IF_ZERO')) { - //$this->atleastoneratenotnull++; + //$tmpatleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -2134,7 +2136,7 @@ class pdf_sponge extends ModelePDFFactures } } - //Local tax 2 after VAT + // Local tax 2 after VAT foreach ($this->localtax2 as $localtax_type => $localtax_rate) { if (in_array((string) $localtax_type, array('2', '4', '6'))) { continue; @@ -2143,7 +2145,7 @@ class pdf_sponge extends ModelePDFFactures foreach ($localtax_rate as $tvakey => $tvaval) { // retrieve global local tax if ($tvakey != 0 || getDolGlobalString('INVOICE_SHOW_ALSO_LOCALTAX2_LINE_IF_ZERO')) { - //$this->atleastoneratenotnull++; + //$tmpatleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -2172,6 +2174,9 @@ class pdf_sponge extends ModelePDFFactures } } + $this->atleastoneratenotnull = $tmpatleastoneratenotnull; + + // Revenue stamp if (price2num($object->revenuestamp, 'MT') != 0) { $index++;