diff --git a/manuais/CEF/novos/Manual_de_Leiaute_de_Arquivo_Eletronico_CNAB_240-1.pdf b/manuais/CEF/novos/Manual_de_Leiaute_de_Arquivo_Eletronico_CNAB_240-1.pdf new file mode 100644 index 00000000..3fbbbbb2 Binary files /dev/null and b/manuais/CEF/novos/Manual_de_Leiaute_de_Arquivo_Eletronico_CNAB_240-1.pdf differ diff --git a/src/Boleto/AbstractBoleto.php b/src/Boleto/AbstractBoleto.php index 88c1c18e..11c38932 100644 --- a/src/Boleto/AbstractBoleto.php +++ b/src/Boleto/AbstractBoleto.php @@ -96,6 +96,12 @@ abstract class AbstractBoleto implements BoletoContract */ public $multa = 0; + /** + * Valor para mora multa + * + * @var float + */ + public $multaApos = 0; /** * Valor para mora juros * @@ -1372,6 +1378,31 @@ public function getJurosApos() return $this->jurosApos ? $this->jurosApos : false; } + /** + * Seta a quantidade de dias apos o vencimento que cobra a multa + * + * @param int $multaApos + * + * @return AbstractBoleto + */ + public function setMultaApos($multaApos) + { + $multaApos = (int)$multaApos; + $this->multaApos = $multaApos > 0 ? $multaApos : 0; + + return $this; + } + + /** + * Retorna a quantidade de dias apos o vencimento que cobra a multa + * + * @return int + */ + public function getMultaApos() + { + return $this->multaApos; + } + /** * Seta dias para protesto * @@ -2164,6 +2195,7 @@ public function toArray() 'multa' => Util::nReal($this->getMulta(), 2, false), 'juros' => Util::nReal($this->getJuros(), 2, false), 'juros_apos' => $this->getJurosApos(), + 'multa_apos' => $this->getMultaApos(), 'dias_protesto' => $this->getDiasProtesto(), 'sacador_avalista' => $this->getSacadorAvalista() ? [ diff --git a/src/Cnab/Remessa/Cnab240/Banco/Bancoob.php b/src/Cnab/Remessa/Cnab240/Banco/Bancoob.php index 02c3e00d..3728d316 100644 --- a/src/Cnab/Remessa/Cnab240/Banco/Bancoob.php +++ b/src/Cnab/Remessa/Cnab240/Banco/Bancoob.php @@ -239,7 +239,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()->addDay()->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'); diff --git a/src/Cnab/Remessa/Cnab240/Banco/Bb.php b/src/Cnab/Remessa/Cnab240/Banco/Bb.php index 6c5b986a..1832518f 100644 --- a/src/Cnab/Remessa/Cnab240/Banco/Bb.php +++ b/src/Cnab/Remessa/Cnab240/Banco/Bb.php @@ -309,7 +309,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->getDataVencimento()->format('dmY')); + $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'); diff --git a/src/Cnab/Remessa/Cnab240/Banco/Bradesco.php b/src/Cnab/Remessa/Cnab240/Banco/Bradesco.php index 4de78a86..920694b9 100644 --- a/src/Cnab/Remessa/Cnab240/Banco/Bradesco.php +++ b/src/Cnab/Remessa/Cnab240/Banco/Bradesco.php @@ -281,7 +281,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->getDataVencimento()->format('dmY')); + $this->add(67, 74, $boleto->getMulta() > 0 ? $boleto->getDataVencimento()->copy()->addDays($boleto->getMultaApos())->format('dmY') : $boleto->getDataVencimento()->copy()->format('dmY')); $this->add(75, 89, Util::formatCnab('9', $boleto->getMulta(), 15, 2)); //2,20 = 0000000000220 $this->add(90, 199, ''); $this->add(200, 207, '00000000'); diff --git a/src/Cnab/Remessa/Cnab240/Banco/Caixa.php b/src/Cnab/Remessa/Cnab240/Banco/Caixa.php index ab3d69a6..68be75b1 100644 --- a/src/Cnab/Remessa/Cnab240/Banco/Caixa.php +++ b/src/Cnab/Remessa/Cnab240/Banco/Caixa.php @@ -132,7 +132,7 @@ protected function segmentoP(BoletoContract $boleto) $this->add(16, 17, self::OCORRENCIA_ALT_OUTROS_DADOS); } $this->add(18, 22, Util::formatCnab('9', $this->getAgencia(), 5)); - $this->add(23, 23, ! is_null($this->getAgenciaDv()) ? $this->getAgenciaDv() : CalculoDV::cefAgencia($this->getAgencia())); + $this->add(23, 23, !is_null($this->getAgenciaDv()) ? $this->getAgenciaDv() : CalculoDV::cefAgencia($this->getAgencia())); if (strlen($this->getCodigoCliente()) == 7) { $this->add(24, 30, Util::formatCnab('9', $this->getCodigoCliente(), 7)); $this->add(31, 37, '0000000'); @@ -247,6 +247,8 @@ public function segmentoR(BoletoContract $boleto) $this->add(9, 13, Util::formatCnab('9', $this->iRegistrosLote, 5)); $this->add(14, 14, 'R'); $this->add(15, 15, ''); + $this->add(67, 74, $boleto->getMulta() > 0 ? $boleto->getDataVencimento()->copy()->addDays($boleto->getMultaApos())->format('dmY') : '00000000'); + $this->add(16, 17, self::OCORRENCIA_REMESSA); if ($boleto->getStatus() == $boleto::STATUS_BAIXA) { $this->add(16, 17, self::OCORRENCIA_PEDIDO_BAIXA); @@ -261,7 +263,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->getDataVencimento()->format('dmY')); + $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, 240, ''); @@ -287,7 +289,7 @@ protected function header() $this->add(19, 32, Util::formatCnab('9', Util::onlyNumbers($this->getBeneficiario()->getDocumento()), 14)); $this->add(33, 52, Util::formatCnab('9', 0, 20)); $this->add(53, 57, Util::formatCnab('9', $this->getAgencia(), 5)); - $this->add(58, 58, ! is_null($this->getAgenciaDv()) ? $this->getAgenciaDv() : CalculoDV::cefAgencia($this->getAgencia())); + $this->add(58, 58, !is_null($this->getAgenciaDv()) ? $this->getAgenciaDv() : CalculoDV::cefAgencia($this->getAgencia())); if (strlen($this->getCodigoCliente()) == 7) { $this->add(59, 65, Util::formatCnab('9', $this->getCodigoCliente(), 7)); $this->add(66, 72, '0000000'); @@ -302,7 +304,7 @@ protected function header() $this->add(144, 151, $this->getDataRemessa('dmY')); $this->add(152, 157, date('His')); $this->add(158, 163, Util::formatCnab('9', $this->getIdremessa(), 6)); - $this->add(164, 166, '101'); + $this->add(164, 166, strlen($this->getCodigoCliente()) == 7 ? '107' : '101'); $this->add(167, 171, '00000'); $this->add(172, 191, ''); $this->add(192, 211, Util::formatCnab('X', 'REMESSA-PRODUCAO', 20)); @@ -329,7 +331,7 @@ protected function headerLote() $this->add(9, 9, 'R'); $this->add(10, 11, '01'); $this->add(12, 13, '00'); - $this->add(14, 16, '060'); + $this->add(14, 16, strlen($this->getCodigoCliente()) == 7 ? '067' : '060'); $this->add(17, 17, ''); $this->add(18, 18, strlen(Util::onlyNumbers($this->getBeneficiario()->getDocumento())) == 14 ? 2 : 1); $this->add(19, 33, Util::formatCnab('9', Util::onlyNumbers($this->getBeneficiario()->getDocumento()), 15)); @@ -341,7 +343,7 @@ protected function headerLote() $this->add(40, 53, Util::formatCnab('9', 0, 14)); } $this->add(54, 58, Util::formatCnab('9', $this->getAgencia(), 5)); - $this->add(59, 59, ! is_null($this->getAgenciaDv()) ? $this->getAgenciaDv() : CalculoDV::cefAgencia($this->getAgencia())); + $this->add(59, 59, !is_null($this->getAgenciaDv()) ? $this->getAgenciaDv() : CalculoDV::cefAgencia($this->getAgencia())); if (strlen($this->getCodigoCliente()) == 7) { $this->add(60, 65, '000000'); } else { diff --git a/src/Cnab/Remessa/Cnab240/Banco/Santander.php b/src/Cnab/Remessa/Cnab240/Banco/Santander.php index 16e7bcd7..6d4e1a01 100644 --- a/src/Cnab/Remessa/Cnab240/Banco/Santander.php +++ b/src/Cnab/Remessa/Cnab240/Banco/Santander.php @@ -246,7 +246,7 @@ public function segmentoR(BoletoContract $boleto) $this->add(27, 41, '000000000000000'); $this->add(42, 65, ''); $this->add(66, 66, '2'); //1 = VALOR FIXO | 2 = PERCENTUAL - $this->add(67, 74, $boleto->getDataVencimento()->format('dmY')); + $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, 240, ''); diff --git a/src/Cnab/Remessa/Cnab240/Banco/Sicredi.php b/src/Cnab/Remessa/Cnab240/Banco/Sicredi.php index 2b4f7eb1..d6ea6b3c 100644 --- a/src/Cnab/Remessa/Cnab240/Banco/Sicredi.php +++ b/src/Cnab/Remessa/Cnab240/Banco/Sicredi.php @@ -200,7 +200,7 @@ protected function segmentoR(BoletoContract $boleto) if ($boleto->getMulta() > 0) { $percentualMulta = number_format((($boleto->getMulta() * 100) / $boleto->getValor()), 2); $this->add(66, 66, '2'); // '2' = Percentual - $this->add(67, 74, $boleto->getDataVencimento()->format('dmY')); + $this->add(67, 74, $boleto->getMulta() > 0 ? $boleto->getDataVencimento()->copy()->addDays($boleto->getMultaApos())->format('dmY') : '00000000'); $this->add(75, 89, Util::formatCnab('9', $percentualMulta, 13, 2)); } $this->add(90, 99, Util::formatCnab('X', '', 10)); diff --git a/src/Cnab/Remessa/Cnab400/Banco/Bb.php b/src/Cnab/Remessa/Cnab400/Banco/Bb.php index d19668b6..1f2eceaa 100644 --- a/src/Cnab/Remessa/Cnab400/Banco/Bb.php +++ b/src/Cnab/Remessa/Cnab400/Banco/Bb.php @@ -347,7 +347,7 @@ public function addBoleto(BoletoContract $boleto) $this->add(1, 1, 5); $this->add(2, 3, 99); $this->add(4, 4, 2); - $this->add(5, 10, $boleto->getJurosApos() === false ? '000000' : $boleto->getDataVencimento()->copy()->addDays($boleto->getJurosApos())->format('dmy')); + $this->add(5, 10, $boleto->getMultaApos() === false ? $boleto->getDataVencimento()->copy()->format('dmy') : $boleto->getDataVencimento()->copy()->addDays($boleto->getMultaApos())->format('dmy')); $this->add(11, 22, Util::formatCnab('9', $boleto->getMulta(), 12, 2)); $this->add(23, 394, ''); $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6)); diff --git a/src/Contracts/Boleto/Boleto.php b/src/Contracts/Boleto/Boleto.php index 5b77b6a8..9db7dc9f 100644 --- a/src/Contracts/Boleto/Boleto.php +++ b/src/Contracts/Boleto/Boleto.php @@ -166,6 +166,11 @@ public function getMoraDia(); * @return mixed */ public function getJurosApos(); + + /** + * @return mixed + */ + public function getMultaApos(); /** * @param int $default