public function addBoleto(BoletoContract $boleto) { $this->iniciaDetalhe(); $this->add(1, 1, '1'); $this->add(2, 3, strlen(Util::onlyNumbers($this->getBeneficiario()->getDocumento())) == 14 ? '02' : '01'); $this->add(4, 17, Util::formatCnab('9L', $this->getBeneficiario()->getDocumento(), 14)); $this->add(18, 21, Util::formatCnab('9', $this->getAgencia(), 4)); $this->add(22, 27, Util::formatCnab('9', $this->getCodigoCliente(), 6)); $this->add(28, 28, '2'); // ‘1’ = Banco Emite ‘2’ = Cliente Emite $this->add(29, 29, '0'); // ‘0’ = Postagem pelo Beneficiário ‘1’ = Pagador via Correio ‘2’ = Beneficiário via Agência CAIXA ‘3’ = Pagador via e-mail $this->add(30, 31, '00'); $this->add(32, 56, Util::formatCnab('X', $boleto->getNumero(), 25)); // numero de controle $this->add(57, 73, Util::formatCnab('9', $boleto->getNossoNumero(), 17)); $this->add(74, 76, ''); $this->add(77, 106, ''); $this->add(107, 108, Util::formatCnab('9', $this->getCarteiraNumero(), 2)); $this->add(109, 110, self::OCORRENCIA_REMESSA); // REGISTRO if ($boleto->getStatus() == $boleto::STATUS_BAIXA) { $this->add(109, 110, self::OCORRENCIA_PEDIDO_BAIXA); // BAIXA } if ($boleto->getStatus() == $boleto::STATUS_ALTERACAO) { $this->add(109, 110, self::OCORRENCIA_ALT_VENCIMENTO); // ALTERAR VENCIMENTO } $this->add(111, 120, Util::formatCnab('X', $boleto->getNumeroDocumento(), 10)); $this->add(121, 126, $boleto->getDataVencimento()->format('dmy')); $this->add(127, 139, Util::formatCnab('9', $boleto->getValor(), 13, 2)); $this->add(140, 142, $this->getCodigoBanco()); $this->add(143, 147, '00000'); $this->add(148, 149, $boleto->getEspecieDocCodigo()); $this->add(150, 150, $boleto->getAceite()); $this->add(151, 156, $boleto->getDataDocumento()->format('dmy')); $this->add(157, 158, self::INSTRUCAO_SEM); $this->add(159, 160, self::INSTRUCAO_SEM); if ($boleto->getDiasProtesto() > 0) { $this->add(157, 158, self::INSTRUCAO_PROTESTAR_VENC_XX); } $juros = 0; if ($boleto->getJuros() > 0) { $juros = Util::percent($boleto->getValor(), $boleto->getJuros()) / 30; } $this->add(161, 173, Util::formatCnab('9', $juros, 13, 2)); $this->add(174, 179, '000000'); $this->add(180, 192, Util::formatCnab('9', 0, 13, 2)); $this->add(193, 205, Util::formatCnab('9', 0, 13, 2)); $this->add(206, 218, Util::formatCnab('9', $boleto->getDescontosAbatimentos(), 13, 2)); $this->add(219, 220, strlen(Util::onlyNumbers($boleto->getPagador()->getDocumento())) == 14 ? '02' : '01'); $this->add(221, 234, Util::formatCnab('9L', $boleto->getPagador()->getDocumento(), 14)); $this->add(235, 274, Util::formatCnab('X', $boleto->getPagador()->getNome(), 40)); $this->add(275, 314, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 40)); $this->add(315, 326, ''); $this->add(327, 334, Util::formatCnab('9L', $boleto->getPagador()->getCep(), 8)); $this->add(335, 349, Util::formatCnab('X', $boleto->getPagador()->getCidade(), 15)); $this->add(350, 351, Util::formatCnab('X', $boleto->getPagador()->getUf(), 2)); $this->add(352, 357, $boleto->getDataVencimento()->copy()->addDays($boleto->getJurosApos())->format('dmy')); $this->add(358, 367, Util::formatCnab('9', Util::percent($boleto->getValor(), $boleto->getMulta()), 10, 2)); $this->add(368, 389, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 22)); $this->add(390, 391, '00'); $this->add(392, 393, Util::formatCnab('9', $boleto->getDiasProtesto('0'), 2)); $this->add(394, 394, Util::formatCnab('9', $boleto->getMoeda(), 1)); $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6)); return $this; }
public function addBoleto(BoletoContract $boleto) { $this->iniciaDetalhe(); $this->add(1, 1, '1'); $this->add(2, 3, strlen(Util::onlyNumbers($this->getBeneficiario()->getDocumento())) == 14 ? '02' : '01'); $this->add(4, 17, Util::formatCnab('NL', $this->getBeneficiario()->getDocumento(), 14)); $this->add(18, 18, 0); $this->add(19, 22, Util::formatCnab('N', $this->getAgencia(), 4)); $this->add(23, 24, '55'); $this->add(25, 28, Util::formatCnab('NL', $this->getAgencia(), 4)); $this->add(29, 34, Util::formatCnab('NL', $this->getConta(), 6)); $this->add(35, 35, Util::formatCnab('NL', $this->getContaDv(), 1)); $this->add(36, 37, Util::formatCnab('X', '', 2)); $this->add(38, 62, Util::formatCnab('X', '', 25)); // numero de controle $this->add(63, 73, Util::formatCnab('N', $boleto->getNossoNumero(), 11)); $this->add(74, 79, '000000'); $this->add(80, 90, Util::formatCnab('N', 0, 11, 2)); $this->add(91, 96, '000000'); $this->add(97, 107, Util::formatCnab('N', 0, 11, 2)); $this->add(108, 108, $this->getCarteiraNumero()); $this->add(109, 110, '01'); // REGISTRO if ($boleto->getStatus() == $boleto::STATUS_BAIXA) { $this->add(109, 110, '02'); // BAIXA } if ($boleto->getStatus() == $boleto::STATUS_ALTERACAO) { $this->add(109, 110, '48'); // ALTERAR VENCIMENTO } $this->add(111, 120, Util::formatCnab('X', $boleto->getNumeroDocumento(), 10)); $this->add(121, 126, $boleto->getDataVencimento()->format('dmy')); $this->add(127, 139, Util::formatCnab('N', $boleto->getValor(), 13, 2)); $this->add(140, 142, $this->getCodigoBanco()); $this->add(143, 147, '00000'); $this->add(148, 149, $boleto->getEspecieDocCodigo()); $this->add(150, 150, $boleto->getAceite()); $this->add(151, 156, $boleto->getDataDocumento()->format('dmy')); $this->add(157, 158, '00'); $this->add(159, 160, '57'); if ($boleto->getDiasProtesto() !== false) { $this->add(157, 158, '84'); } if ($boleto->getMulta() !== false) { $this->add(159, 160, '74'); $this->add(206, 211, Util::formatCnab('X', '', 6)); $this->add(206, 215, Util::formatCnab('9', $boleto->getMulta(), 2, 2)); $this->add(206, 218, Util::formatCnab('9', $boleto->getJurosApos(0), 3)); } else { $this->add(206, 218, Util::formatCnab('9', $boleto->getDescontosAbatimentos(), 13, 2)); } $juros = 0; if ($boleto->getJuros() !== false) { $juros = Util::percent($boleto->getValor(), $boleto->getJuros()) / 30; } $this->add(161, 173, Util::formatCnab('9', $juros, 13, 2)); $this->add(174, 179, '000000'); $this->add(180, 192, Util::formatCnab('9', 0, 13, 2)); $this->add(193, 205, Util::formatCnab('9', 0, 13, 2)); $this->add(219, 220, strlen(Util::onlyNumbers($boleto->getPagador()->getDocumento())) == 14 ? '02' : '01'); $this->add(221, 234, Util::formatCnab('NL', $boleto->getPagador()->getDocumento(), 14)); $this->add(235, 274, Util::formatCnab('X', $boleto->getPagador()->getNome(), 40)); $this->add(275, 312, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 38)); $this->add(313, 314, '00'); $this->add(315, 326, Util::formatCnab('X', '', 12)); $this->add(327, 334, Util::formatCnab('NL', $boleto->getPagador()->getCep(), 8)); $this->add(335, 349, Util::formatCnab('X', $boleto->getPagador()->getCidade(), 15)); $this->add(350, 351, Util::formatCnab('X', $boleto->getPagador()->getUf(), 2)); $this->add(352, 390, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 39)); $this->add(391, 391, ''); $this->add(392, 393, Util::formatCnab('N', $boleto->getDiasProtesto(' '), 2)); $this->add(394, 394, $boleto->getMoeda()); $this->add(395, 400, Util::formatCnab('N', $this->iRegistros + 1, 6)); }