Skip to content

Commit

Permalink
Merge pull request #47 from LucianoHanna/master
Browse files Browse the repository at this point in the history
Adiciona opção de não protestar ao BB
  • Loading branch information
newerton authored Feb 23, 2023
2 parents 114620e + 9524f8b commit 116b307
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
30 changes: 30 additions & 0 deletions src/Boleto/AbstractBoleto.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ abstract class AbstractBoleto implements BoletoContract
*/
protected $jurosApos = 0;

/**
* Não protestar boleto
*
* @var bool
*/
protected $naoProtestar = false;

/**
* Dias para protesto
*
Expand Down Expand Up @@ -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
*
Expand Down
14 changes: 9 additions & 5 deletions src/Cnab/Remessa/Cnab400/Banco/Bb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions src/Contracts/Boleto/Boleto.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ public function getJurosApos();
*/
public function getDiasProtesto($default = 0);

/**
* Retorna o naoProtestar
*
* @return bool
*/
public function getNaoProtestar();

/**
* @param int $default
*
Expand Down

0 comments on commit 116b307

Please sign in to comment.