From 6dd61c006b1e4635833db3fd898f18bee10fdfd2 Mon Sep 17 00:00:00 2001 From: Emerson Date: Tue, 28 May 2024 16:06:11 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20para=20exibi=C3=A7=C3=A3o?= =?UTF-8?q?=20individual=20das=20unidades=20med?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correção afim de exibir de forma separada as unidades de medida do CT-e. --- src/CTe/Dacte.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/CTe/Dacte.php b/src/CTe/Dacte.php index 20737e7a..b6921690 100644 --- a/src/CTe/Dacte.php +++ b/src/CTe/Dacte.php @@ -1569,10 +1569,19 @@ protected function descricaoCarga($x = 0, $y = 0) //Identifica código da unidade //01 = KG (QUILOS) $qCarga = 0; + $qCargaPesoBruto = 0; + $qCargaPesoBaseCalculo = 0; + $qCargaPesoAferido = 0; foreach ($this->infQ as $infQ) { if (in_array($this->getTagValue($infQ, "cUnid"), array('01', '02'))) { - $qCarga += $this->getTagValue($infQ, "cUnid") == '01' ? - $this->getTagValue($infQ, "qCarga") : $this->getTagValue($infQ, "qCarga") * 1000; + if ($this->getTagValue($infQ, "tpMed") == 'PESO BRUTO') + $qCargaPesoBruto += $this->getTagValue($infQ, "cUnid") == '01' ? $this->getTagValue($infQ, "qCarga") : $this->getTagValue($infQ, "qCarga") * 1000; + else if ($this->getTagValue($infQ, "tpMed") == 'PESO BASE DE CALCULO') + $qCargaPesoBaseCalculo += $this->getTagValue($infQ, "cUnid") == '01' ? $this->getTagValue($infQ, "qCarga") : $this->getTagValue($infQ, "qCarga") * 1000; + else + $qCargaPesoAferido += $this->getTagValue($infQ, "cUnid") == '01' ? $this->getTagValue($infQ, "qCarga") : $this->getTagValue($infQ, "qCarga") * 1000; + } else { + $qCarga += $this->getTagValue($infQ, "qCarga"); } } $texto = 'PESO BRUTO (KG)'; @@ -1581,7 +1590,7 @@ protected function descricaoCarga($x = 0, $y = 0) 'size' => 5, 'style' => ''); $this->pdf->textBox($x + 8, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); - $texto = number_format($qCarga, 3, ",", "."); + $texto = number_format($qCargaPesoBruto, 3, ",", "."); $aFont = array( 'font' => $this->fontePadrao, 'size' => 7, @@ -1595,7 +1604,7 @@ protected function descricaoCarga($x = 0, $y = 0) 'size' => 5, 'style' => ''); $this->pdf->textBox($x + 20, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); - $texto = number_format($qCarga, 3, ",", "."); + $texto = number_format($qCargaPesoBaseCalculo, 3, ",", "."); $aFont = array( 'font' => $this->fontePadrao, 'size' => 7, @@ -1609,7 +1618,7 @@ protected function descricaoCarga($x = 0, $y = 0) 'size' => 5, 'style' => ''); $this->pdf->textBox($x + 35, $y, $w, $h, $texto, $aFont, 'T', 'L', 0, ''); - $texto = number_format($qCarga, 3, ",", "."); + $texto = number_format($qCargaPesoAferido, 3, ",", "."); $aFont = array( 'font' => $this->fontePadrao, 'size' => 7,