diff --git a/src/Boleto/AbstractBoleto.php b/src/Boleto/AbstractBoleto.php index 81051bf..a824716 100644 --- a/src/Boleto/AbstractBoleto.php +++ b/src/Boleto/AbstractBoleto.php @@ -81,6 +81,13 @@ abstract class AbstractBoleto implements BoletoContract */ protected $jurosApos = 0; + /** + * Não protestar boleto + * + * @var bool + */ + protected $naoProtestar = false; + /** * Dias para protesto * @@ -1112,6 +1119,29 @@ public function getJurosApos() return $this->jurosApos; } + /** + * Seta não protestar + * + * @param $naoProtestar + * @return AbstractBoleto + */ + public function setNaoProtestar($naoProtestar) + { + $this->naoProtestar = (bool) $naoProtestar; + + return $this; + } + + /** + * Retorna o naoProtestar + * + * @return bool + */ + public function getNaoProtestar() + { + return (bool) $this->naoProtestar; + } + /** * Seta dias para protesto * diff --git a/src/Cnab/Remessa/Cnab400/Banco/Bb.php b/src/Cnab/Remessa/Cnab400/Banco/Bb.php index 45213bd..0f88a38 100644 --- a/src/Cnab/Remessa/Cnab400/Banco/Bb.php +++ b/src/Cnab/Remessa/Cnab400/Banco/Bb.php @@ -275,16 +275,20 @@ public function addBoleto(BoletoContract $boleto) $this->add(157, 158, $boleto->getStatus() == $boleto::STATUS_BAIXA ? self::INSTRUCAO_BAIXAR : self::INSTRUCAO_SEM); $this->add(159, 160, self::INSTRUCAO_SEM); $diasProtesto = '00'; - $const = sprintf('self::INSTRUCAO_PROTESTAR_VENC_%02s', $boleto->getDiasProtesto()); $juros = 0; if ($boleto->getStatus() != $boleto::STATUS_BAIXA) { - if (defined($const)) { - $this->add(157, 158, constant($const)); + if ($boleto->getNaoProtestar()) { + $this->add(157, 158, self::INSTRUCAO_NAO_PROTESTAR); } else { - $this->add(157, 158, self::INSTRUCAO_PROTESTAR_VENC_XX); - $diasProtesto = Util::formatCnab('9', $boleto->getDiasProtesto(), 2, 0); + $const = sprintf('self::INSTRUCAO_PROTESTAR_VENC_%02s', $boleto->getDiasProtesto()); + if (defined($const)) { + $this->add(157, 158, constant($const)); + } else { + $this->add(157, 158, self::INSTRUCAO_PROTESTAR_VENC_XX); + $diasProtesto = Util::formatCnab('9', $boleto->getDiasProtesto(), 2, 0); + } } if ($boleto->getJuros() > 0) { diff --git a/src/Contracts/Boleto/Boleto.php b/src/Contracts/Boleto/Boleto.php index 885f96e..ff5646b 100644 --- a/src/Contracts/Boleto/Boleto.php +++ b/src/Contracts/Boleto/Boleto.php @@ -140,6 +140,13 @@ public function getJurosApos(); */ public function getDiasProtesto($default = 0); + /** + * Retorna o naoProtestar + * + * @return bool + */ + public function getNaoProtestar(); + /** * @param int $default *