Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adicionado tipo de protesto para Bancoob/Sicoob #748

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Boleto/AbstractBoleto.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ abstract class AbstractBoleto implements BoletoContract
*/
public $diasProtesto = 0;

/**
* Tipo de prostesto se dias úteis, dias corridos, não protestar
* @var int
*/
public $tipoProtesto = 0;

/**
* Dias para baixa automática
*
Expand Down Expand Up @@ -1502,6 +1508,38 @@ public function getDiasProtesto($default = 0)
return $this->diasProtesto > 0 ? $this->diasProtesto : $default;
}

/**
* Seta dias para protesto
* 0 = Não protestar, 1 = Dias corridos, 2 = Dias úteis, 3 = Negativar dias corridos, 4 = Não negativar
* @param int $tipoProtesto
*
* @return AbstractBoleto
* @throws \Exception
*/
public function setTipoProtesto($tipoProtesto)
{
$tipoProtesto = (int)$tipoProtesto;
$this->tipoProtesto = $tipoProtesto > 0 ? $tipoProtesto : 0;

if (!empty($tipoProtesto) && $this->getDiasProtesto() == 0) {
throw new \Exception('Você deve informar dias de protesto se informar tipo de protesto');
}

return $this;
}

/**
* Retorna os diasProtesto
*
* @param int $default
*
* @return int
*/
public function getTipoProtesto($default = 0)
{
return $this->tipoProtesto > 0 ? $this->tipoProtesto : $default;
}

/**
* Seta os dias para baixa automática
*
Expand Down
20 changes: 17 additions & 3 deletions src/Cnab/Remessa/Cnab240/Banco/Bancoob.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,21 @@ protected function segmentoP(BoletoContract $boleto)
$this->add(196, 220, Util::formatCnab('X', $boleto->getNumeroControle(), 25));
$this->add(221, 221, self::PROTESTO_NAO_PROTESTAR);
if ($boleto->getDiasProtesto() > 0) {
$this->add(221, 221, self::PROTESTO_DIAS_UTEIS);
switch ($boleto->getTipoProtesto()) {
case 1:
$this->add(221, 221, self::PROTESTO_DIAS_CORRIDOS);
break;
case 2:
default:
$this->add(221, 221, self::PROTESTO_DIAS_UTEIS);
break;
case 3:
$this->add(221, 221, self::PROTESTO_NEGATIVAR_DIAS_CORRIDOS);
break;
case 4:
$this->add(221, 221, self::PROTESTO_NAO_NEGATIVAR);
break;
}
}
$this->add(222, 223, Util::formatCnab('9', $boleto->getDiasProtesto(), 2));
$this->add(224, 224, '0');
Expand Down Expand Up @@ -239,7 +253,7 @@ public function segmentoR(BoletoContract $boleto)
$this->add(43, 50, '00000000');
$this->add(51, 65, '000000000000000');
$this->add(66, 66, $boleto->getMulta() > 0 ? '2' : '0'); //0 = ISENTO | 1 = VALOR FIXO | 2 = PERCENTUAL
$this->add(67, 74, $boleto->getMulta() > 0 ? $boleto->getDataVencimento()->copy()->addDays($boleto->getMultaApos())->format('dmY') : '00000000');
$this->add(67, 74, $boleto->getMulta() > 0 ? $boleto->getDataVencimento()->copy()->addDays($boleto->getMultaApos())->format('dmY') : '00000000');
$this->add(75, 89, Util::formatCnab('9', $boleto->getMulta(), 15, 2)); //2,20 = 0000000000220
$this->add(90, 199, '');
$this->add(200, 207, '00000000');
Expand Down Expand Up @@ -338,7 +352,7 @@ protected function trailerLote()
{
$this->iniciaTrailerLote();

$valor = array_reduce($this->boletos, function ($valor, $boleto) {
$valor = array_reduce($this->boletos, function($valor, $boleto) {
return $valor + $boleto->getValor();
}, 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 @@ -181,6 +181,13 @@ public function getMultaApos();
*/
public function getDiasProtesto($default = 0);

/**
* @param int $default
*
* @return mixed
*/
public function getTipoProtesto($default = 0);

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