Skip to content

Commit

Permalink
Merge pull request #20 from arquivei/feature/engaja-131-v2
Browse files Browse the repository at this point in the history
Ajusta código para não quebrar ao realizar os testes de integração co…
  • Loading branch information
lucasm-moreira authored Dec 28, 2021
2 parents 00262a7 + a12debd commit 025b781
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/CTe/Dacte.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ protected function cabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
if (!empty($this->logomarca)) {
$logoInfo = getimagesize($this->logomarca);
//largura da imagem em mm
$logoWmm = ($logoInfo[0] / 72) * 25.4;
$logoWmm = $logoInfo[0] > 0 ? ($logoInfo[0] / 72) * 25.4 : 212;
//altura da imagem em mm
$logoHmm = ($logoInfo[1] / 72) * 25.4;
$logoHmm = $logoInfo[1] > 0 ? ($logoInfo[1] / 72) * 25.4 : 129;
if ($this->logoAlign == 'L') {
$nImgW = round($w / 3, 0);
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
Expand Down
34 changes: 20 additions & 14 deletions src/CTe/DacteOS.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function loadDoc($xml)
if (!is_numeric($vTrib)) {
$vTrib = 0;
}
$textoAdic = number_format($vTrib, 2, ",", ".");
$textoAdic = !empty($vTrib) ? number_format($vTrib, 2, ",", ".") : '';
$this->textoAdic = "o valor aproximado de tributos incidentes sobre o preço deste serviço é de R$"
.$textoAdic;
$this->toma = $this->dom->getElementsByTagName("toma")->item(0);
Expand Down Expand Up @@ -447,9 +447,9 @@ protected function cabecalho($x = 0, $y = 0, $pag = '1', $totPag = '1')
if (!empty($this->logomarca)) {
$logoInfo = getimagesize($this->logomarca);
//largura da imagem em mm
$logoWmm = ($logoInfo[0] / 72) * 25.4;
$logoWmm = $logoInfo[0] > 0 ? ($logoInfo[0] / 72) * 25.4 : 212;
//altura da imagem em mm
$logoHmm = ($logoInfo[1] / 72) * 25.4;
$logoHmm = $logoInfo[1] > 0 ? ($logoInfo[1] / 72) * 25.4 : 129;
if ($this->logoAlign == 'L') {
$nImgW = round($w / 3, 0);
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
Expand Down Expand Up @@ -1177,7 +1177,8 @@ protected function compValorServ($x = 0, $y = 0)
$texto = 'VALOR TOTAL DO SERVIÇO';
$aFont = $this->formatPadrao;
$this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
$texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
$texto = !empty($this->getTagValue($this->vPrest, "vTPrest")) ?
number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".") : '';
$aFont = array(
'font' => $this->fontePadrao,
'size' => 9,
Expand All @@ -1189,7 +1190,8 @@ protected function compValorServ($x = 0, $y = 0)
$texto = 'VALOR A RECEBER';
$aFont = $this->formatPadrao;
$this->pdf->textBox($x, $y, $w * 0.14, $h, $texto, $aFont, 'T', 'C', 0, '');
$texto = number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".");
$texto = !empty($this->getTagValue($this->vPrest, "vRec")) ?
number_format($this->getTagValue($this->vPrest, "vRec"), 2, ",", ".") : '';
$aFont = array(
'font' => $this->fontePadrao,
'size' => 9,
Expand All @@ -1200,12 +1202,13 @@ protected function compValorServ($x = 0, $y = 0)

foreach ($this->Comp as $k => $d) {
$nome = $this->Comp->item($k)->getElementsByTagName('xNome')->item(0)->nodeValue;
$valor = number_format(
$this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
2,
",",
"."
);
$valor = !empty($this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue) ?
number_format(
$this->Comp->item($k)->getElementsByTagName('vComp')->item(0)->nodeValue,
2,
",",
"."
) : '';
if ($auxX > $w * 0.60) {
$yIniDados = $yIniDados + 4;
$auxX = $oldX;
Expand Down Expand Up @@ -1355,7 +1358,8 @@ protected function geraChaveAdicCont()
$cUF = $this->ide->getElementsByTagName('cUF')->item(0)->nodeValue;
$CNPJ = "00000000000000" . $this->emit->getElementsByTagName('CNPJ')->item(0)->nodeValue;
$CNPJ = substr($CNPJ, -14);
$vCT = number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100;
$vCT = !empty($this->getTagValue($this->vPrest, "vRec")) ?
number_format($this->getTagValue($this->vPrest, "vRec"), 2, "", "") * 100 : '';
$ICMS_CST = $this->getTagValue($this->ICMS, "CST");
switch ($ICMS_CST) {
case '00':
Expand Down Expand Up @@ -1448,7 +1452,8 @@ protected function infPrestacaoServico($x = 0, $y = 0)

$x = $oldX;
$y = $y + 4;
$texto = number_format($this->getTagValue($this->infQ->item(0), "qCarga"), 3, ",", ".");
$texto = !empty($this->getTagValue($this->infQ->item(0), "qCarga")) ?
number_format($this->getTagValue($this->infQ->item(0), "qCarga"), 3, ",", ".") : '';
$aFont = $this->formatNegrito;
$this->pdf->textBox($x, $y, $w * 0.26, $h, $texto, $aFont, 'T', 'L', 0, '');
$x += $w * 0.26;
Expand Down Expand Up @@ -1519,7 +1524,8 @@ protected function docCompl($x = 0, $y = 0)
'size' => 8,
'style' => '');
$this->pdf->textBox($auxX, $yIniDados, $w, $h, $texto, $aFont, 'T', 'L', 0, '');
$texto = number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".");
$texto = !empty($this->getTagValue($this->vPrest, "vTPrest")) ?
number_format($this->getTagValue($this->vPrest, "vTPrest"), 2, ",", ".") : '';
$aFont = array(
'font' => $this->fontePadrao,
'size' => 8,
Expand Down
8 changes: 4 additions & 4 deletions src/MDFe/Damdfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ private function headerMDFePaisagem($x, $y, $pag)
if (is_file($this->logomarca)) {
$logoInfo = getimagesize($this->logomarca);
//largura da imagem em mm
$logoWmm = ($logoInfo[0] / 72) * 25.4;
$logoWmm = $logoInfo[0] > 0 ? ($logoInfo[0] / 72) * 25.4 : 212;
//altura da imagem em mm
$logoHmm = ($logoInfo[1] / 72) * 25.4;
$logoHmm = $logoInfo[1] > 0 ? ($logoInfo[1] / 72) * 25.4 : 129;
if ($this->logoAlign == 'L') {
$nImgW = round($w / 3, 0);
$nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
Expand Down Expand Up @@ -410,9 +410,9 @@ private function headerMDFeRetrato($x, $y, $pag)
if (is_file($this->logomarca)) {
$logoInfo = getimagesize($this->logomarca);
//largura da imagem em mm
$logoWmm = ($logoInfo[0] / 72) * 25.4;
$logoWmm = $logoInfo[0] > 0 ? ($logoInfo[0] / 72) * 25.4 : 212;
//altura da imagem em mm
$logoHmm = ($logoInfo[1] / 72) * 25.4;
$logoHmm = $logoInfo[1] > 0 ? ($logoInfo[1] / 72) * 25.4 : 129;
if ($this->logoAlign == 'L') {
// ajusta a dimensão do logo
$nImgW = round((round($maxW * 0.50, 0)) / 3, 0);
Expand Down
27 changes: 16 additions & 11 deletions src/NFe/Danfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,9 @@ protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
$type == 'jpg';
}
//largura da imagem em mm
$logoWmm = ($logoInfo[0]/72)*25.4;
$logoWmm = $logoInfo[0] > 0 ? ($logoInfo[0]/72)*25.4 : 212;
//altura da imagem em mm
$logoHmm = ($logoInfo[1]/72)*25.4;
$logoHmm = $logoInfo[1] > 0 ? ($logoInfo[1]/72)*25.4 : 129;
if ($this->logoAlign=='L') {
$nImgW = round($w/3, 0);
$nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
Expand Down Expand Up @@ -1196,9 +1196,10 @@ protected function header($x = 0, $y = 0, $pag = '1', $totPag = '1')
$texto = ! empty($this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue)
? $this->nfeProc->getElementsByTagName("nProt")->item(0)->nodeValue
: '';
$tsHora = $this->toTimestamp(
$this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
);
$tsHora = !empty($this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue) ?
$this->toTimestamp(
$this->nfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue
) : '';
if ($texto != '') {
$texto .= " - " . date('d/m/Y H:i:s', $tsHora);
}
Expand Down Expand Up @@ -1605,7 +1606,7 @@ protected function destinatarioDANFE($x = 0, $y = 0)
$dhSaiEnt = ! empty($this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue)
? $this->ide->getElementsByTagName("dhSaiEnt")->item(0)->nodeValue
: '';
$tsDhSaiEnt = $this->toTimestamp($dhSaiEnt);
$tsDhSaiEnt = !empty($dhSaiEnt) ? $this->toTimestamp($dhSaiEnt) : '';
if ($tsDhSaiEnt != '') {
$hSaiEnt = date('H:i:s', $tsDhSaiEnt);
}
Expand Down Expand Up @@ -2941,11 +2942,13 @@ protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabe
$alinhamento = 'R';
}
// QTDADE
$texto = number_format($prod->getElementsByTagName("qCom")->item(0)->nodeValue, 4, ",", ".");
$texto = !empty($prod->getElementsByTagName("qCom")->item(0)->nodeValue) ?
number_format($prod->getElementsByTagName("qCom")->item(0)->nodeValue, 4, ",", ".") : '';
$this->pdf->textBox($x, $y, $w7, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
$x += $w7;
// Valor Unitário
$texto = number_format($prod->getElementsByTagName("vUnCom")->item(0)->nodeValue, 4, ",", ".");
$texto = !empty($prod->getElementsByTagName("vUnCom")->item(0)->nodeValue) ?
number_format($prod->getElementsByTagName("vUnCom")->item(0)->nodeValue, 4, ",", ".") : '';
$this->pdf->textBox($x, $y, $w8, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
$x += $w8;
// Valor do Produto
Expand All @@ -2956,7 +2959,8 @@ protected function itens($x, $y, &$nInicio, $hmax, $pag = 0, $totpag = 0, $hCabe
$this->pdf->textBox($x, $y, $w9, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
$x += $w9;
//Valor do Desconto
$texto = number_format($prod->getElementsByTagName("vDesc")->item(0)->nodeValue, 2, ",", ".");
$texto = !empty($prod->getElementsByTagName("vDesc")->item(0)->nodeValue) ?
number_format($prod->getElementsByTagName("vDesc")->item(0)->nodeValue, 2, ",", ".") : '';
$this->pdf->textBox($x, $y, $w10, $h, $texto, $aFont, 'T', $alinhamento, 0, '');
//Valor da Base de calculo
$x += $w10;
Expand Down Expand Up @@ -3288,7 +3292,7 @@ protected function issqn($x, $y)
if (isset($this->ISSQNtot)) {
$texto = ! empty($this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue) ?
$this->ISSQNtot->getElementsByTagName("vServ")->item(0)->nodeValue : '';
$texto = number_format($texto, 2, ",", ".");
$texto = !empty($texto) ? number_format($texto, 2, ",", ".") : '';
} else {
$texto = '';
}
Expand Down Expand Up @@ -3529,7 +3533,8 @@ protected function canhoto($x, $y)
}
$texto .= $this->ymdTodmy($dEmi) ." ";
$texto .= "VALOR TOTAL: R$ ";
$texto .= number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " ";
$texto .= !empty($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue) ?
number_format($this->ICMSTot->getElementsByTagName("vNF")->item(0)->nodeValue, 2, ",", ".") . " " : '';
$texto .= "DESTINATÁRIO: ";
$texto .= $destinatario;
if ($this->orientacao == 'P') {
Expand Down

0 comments on commit 025b781

Please sign in to comment.