From a4b6599281b28caa753f4145cd196839485ec984 Mon Sep 17 00:00:00 2001 From: gabrielrassweiler Date: Thu, 13 Apr 2023 11:57:16 -0300 Subject: [PATCH] fix(docOrigContinuacao): corrige while para conter ultima chave vinculada --- src/CTe/DacteV3.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CTe/DacteV3.php b/src/CTe/DacteV3.php index c22212f0..2703921c 100644 --- a/src/CTe/DacteV3.php +++ b/src/CTe/DacteV3.php @@ -2533,9 +2533,9 @@ protected function zDocOrigContinuacao($x = 0, $y = 0) //$h = 9 + 3.5 ;// segunda linha //$h = 9 + 3.5+ 3.5 ;// segunda linha $h = (( ( count($this->arrayNFe)/2 ) - 9) * 3.5)+9; - if (count($this->arrayNFe)%2 !=0) { - $h = $h+3.5; - } // Caso tenha apenas 1 registro na ultima linha + if (count($this->arrayNFe)%2 !=0 || (count($this->arrayNFe) - $contador) %2 == 0) { + $h = $h+4; + } // Caso tenha apenas 1 registro na ultima linha ou seja impar $texto = 'DOCUMENTOS ORIGINÁRIOS - CONTINUACÃO'; $aFont = $this->formatPadrao; $this->pTextBox($x, $y, $w, $h, $texto, $aFont, 'T', 'C', 1, ''); @@ -2583,13 +2583,13 @@ protected function zDocOrigContinuacao($x = 0, $y = 0) $this->pTextBox($x, $y, $w * 0.13, $h, $texto, $aFont, 'T', 'L', 0, ''); $auxX = $oldX; $yIniDados += 3; - while ($contador < (count($this->arrayNFe))) { + while ($contador <= (count($this->arrayNFe))) { if ($contador%(116*($i-1)) == 0) { // $contador++; break; } $tp = 'NF-e'; - $chaveNFe = $this->arrayNFe[$contador]; + $chaveNFe = $this->arrayNFe[$contador - 1]; $numNFe = substr($chaveNFe, 25, 9); $serieNFe = substr($chaveNFe, 22, 3); $doc = $serieNFe . '/' . $numNFe;