Skip to content

Commit 4512025

Browse files
authored
Merge pull request #744 from thiagosouza84/master
Refatoração: converter e-mails para minúsculas na atualização de chav…
2 parents 85c56f3 + 8775217 commit 4512025

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Cnab/Remessa/Cnab400/Banco/Santander.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function addBoleto(BoletoContract $boleto)
258258
$this->add(25, 37, Util::formatCnab('9', $boleto->getValor(), 13, 2));
259259
$this->add(38, 42, Util::formatCnab('9', 100, 5, 2));
260260
$this->add(43, 43, Util::formatCnab('9', $tipoChave[$boleto->getPixChaveTipo()], 1));
261-
$this->add(44, 120, Util::formatCnab('X', $boleto->getPixChave(), 77));
261+
$this->add(44, 120, Util::formatCnab('Z', $boleto->getPixChave(), 77));
262262
$this->add(121, 155, Util::formatCnab('X', $boleto->getID(), 35));
263263
$this->add(156, 394, '');
264264
$this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));

src/Util.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,19 @@ public static function formatCnab($tipo, $valor, $tamanho, $dec = 0, $sFill = ''
501501
$type = 's';
502502
$valor = ($dec > 0) ? sprintf("%.{$dec}f", $valor) : $valor;
503503
$valor = str_replace([',', '.'], '', $valor);
504-
} elseif (in_array($tipo, ['A', 'X'])) {
504+
} elseif (in_array($tipo, ['A', 'X', 'Z'])) { // Adiciona 'x' como uma condição válida
505505
$left = '-';
506506
$type = 's';
507507
} else {
508508
throw new ValidationException('Tipo inválido');
509509
}
510510

511-
return sprintf("%{$left}{$sFill}{$tamanho}{$type}", mb_substr($valor, 0, $tamanho));
511+
// Verifica se o tipo é 'x' minúsculo e então retorna a string em minúsculas
512+
if ($tipo === 'Z') {
513+
return strtolower(sprintf("%{$left}{$sFill}{$tamanho}{$type}", mb_substr($valor, 0, $tamanho)));
514+
} else {
515+
return sprintf("%{$left}{$sFill}{$tamanho}{$type}", mb_substr($valor, 0, $tamanho));
516+
}
512517
}
513518

514519
/**

0 commit comments

Comments
 (0)