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, 23, '00'); $this->add(24, 28, Util::formatCnab('9', $this->getConta(), 5)); $this->add(29, 29, $this->getContaDv()); $this->add(30, 33, Util::formatCnab('X', '', 4)); $this->add(34, 37, '0000'); $this->add(38, 62, Util::formatCnab('X', '', 25)); // numero de controle $this->add(63, 70, Util::formatCnab('9', substr($boleto->getNossoNumero(), 0, -1), 8)); $this->add(71, 83, Util::formatCnab('9', '0', 13, 2)); $this->add(84, 86, Util::formatCnab('9', $this->getCarteiraNumero(), 3)); $this->add(87, 107, Util::formatCnab('X', '', 21)); $this->add(108, 108, 'I'); $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, '06'); // 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, '00'); $this->add(159, 160, '57'); if ($boleto->getDiasProtesto() !== false) { $this->add(157, 158, '34'); } $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(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, 264, Util::formatCnab('X', $boleto->getPagador()->getNome(), 30)); $this->add(265, 274, Util::formatCnab('X', '', 10)); $this->add(275, 314, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 40)); $this->add(315, 326, Util::formatCnab('X', $boleto->getPagador()->getBairro(), 12)); $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, 381, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 30)); $this->add(382, 385, Util::formatCnab('X', '', 4)); $this->add(386, 391, $boleto->getDataVencimento()->copy()->addDays($boleto->getJurosApos(0))->format('dmy')); $this->add(392, 393, Util::formatCnab('9', $boleto->getDiasProtesto('0'), 2)); $this->add(394, 394, ''); $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('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->total += $boleto->getValor(); $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, 37, Util::formatCnab('9', $this->getCodigoTransmissao(), 20)); $this->add(38, 62, Util::formatCnab('X', $boleto->getNumero(), 25)); // numero de controle $this->add(63, 70, Util::numberFormatGeral($boleto->getNumeroDocumento(), 7) . Util::modulo11($boleto->getNumeroDocumento())); $this->add(71, 76, '000000'); $this->add(77, 77, ''); $this->add(78, 78, $boleto->getMulta() > 0 ? '4' : '0'); $this->add(79, 82, Util::formatCnab('9', $boleto->getMulta(), 4, 2)); $this->add(83, 84, '00'); $this->add(85, 97, Util::formatCnab('9', 0, 13, 2)); $this->add(98, 101, ''); $this->add(102, 107, $boleto->getDataVencimento()->copy()->addDays($boleto->getJurosApos())->format('dmy')); $this->add(108, 108, $this->getCarteiraNumero() > 200 ? '1' : '5'); $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); } $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, Util::formatCnab('X', $boleto->getPagador()->getBairro(), 12)); $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, 381, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 30)); $this->add(382, 382, ''); $this->add(383, 383, 'I'); $this->add(384, 385, substr($this->getConta(), -2)); $this->add(386, 391, ''); $this->add(392, 393, Util::formatCnab('9', $boleto->getDiasProtesto('0'), 2)); $this->add(394, 394, ''); $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6)); return $this; }
public function addBoleto(BoletoContract $boleto) { $this->iniciaDetalhe(); $this->add(1, 1, 7); $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, 22, Util::modulo11($this->getAgencia())); $this->add(23, 30, Util::formatCnab('9', $this->getConta(), 8)); $this->add(31, 31, Util::modulo11($this->getConta())); $this->add(32, 38, Util::formatCnab('9', $this->getConvenio(), 7)); $this->add(39, 63, Util::formatCnab('X', '', 25)); // numero de controle $this->add(64, 80, $boleto->getNossoNumero()); $this->add(81, 82, '00'); $this->add(83, 84, '00'); $this->add(85, 87, ''); $this->add(88, 88, $boleto->getSacadorAvalista() ? 'A' : ''); $this->add(89, 91, ''); $this->add(92, 94, Util::formatCnab('9', $this->getVariacaoCarteira(), 3)); $this->add(95, 95, '0'); $this->add(96, 101, '000000'); $this->add(102, 106, Util::formatCnab('X', '', 5)); $this->add(107, 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, '06'); // 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, 146, '0000'); $this->add(147, 147, ''); $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, '00'); switch ($boleto->getDiasProtesto()) { case '03': //- 03 - Protestar no 3º dia útil após vencido $this->add(157, 158, '03'); break; case '04': //- 04 - Protestar no 4º dia útil após vencido $this->add(157, 158, '04'); break; case '05': //- 05 - Protestar no 5º dia útil após vencido $this->add(157, 158, '05'); break; case '10': //- 10 - Protestar no 10º dia corrido após vencido $this->add(157, 158, '10'); break; case '15': //- 15 - Protestar no 15º dia corrido após vencido $this->add(157, 158, '15'); break; case '20': //- 20 - Protestar no 20º dia corrido após vencido $this->add(157, 158, '20'); break; case '25': //- 25 - Protestar no 25º dia corrido após vencido $this->add(157, 158, '25'); break; case '30': //- 30 - Protestar no 30º dia corrido após vencido $this->add(157, 158, '30'); break; case '45': //- 45 - Protestar no 45º dia corrido após vencido $this->add(157, 158, '45'); break; } $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(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, 271, Util::formatCnab('X', $boleto->getPagador()->getNome(), 37)); $this->add(272, 274, Util::formatCnab('N', '', 3)); $this->add(275, 314, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 40)); $this->add(315, 326, Util::formatCnab('X', $boleto->getPagador()->getBairro(), 12)); $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, 391, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 40)); $this->add(392, 393, '00'); $this->add(394, 394, ''); $this->add(395, 400, Util::formatCnab('N', $this->iRegistros + 1, 6)); if ($boleto->getMulta() !== false) { $this->iniciaDetalhe(); $this->add(1, 1, 5); $this->add(2, 3, 99); $this->add(4, 4, 2); $this->add(5, 10, $boleto->getDataVencimento()->copy()->addDays($boleto->getJurosApos(0))->format('dmy')); $this->add(11, 22, Util::formatCnab('9', $boleto->getMulta(), 7, 2)); $this->add(23, 394, ''); $this->add(23, 394, ''); $this->add(395, 400, Util::formatCnab('N', $this->iRegistros + 1, 6)); } }
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, 18, 0); $this->add(19, 22, Util::formatCnab('9', $this->getAgencia(), 4)); $this->add(23, 24, '55'); $this->add(25, 28, Util::formatCnab('9L', $this->getAgencia(), 4)); $this->add(29, 34, Util::formatCnab('9L', $this->getConta(), 6)); $this->add(35, 35, Util::formatCnab('9L', $this->getContaDv(), 1)); $this->add(36, 37, ''); $this->add(38, 62, Util::formatCnab('X', $boleto->getNumero(), 25)); // numero de controle $this->add(63, 73, Util::formatCnab('9', $boleto->getNossoNumero(), 11)); $this->add(74, 79, '000000'); $this->add(80, 90, Util::formatCnab('9', 0, 11, 2)); $this->add(91, 96, '000000'); $this->add(97, 107, Util::formatCnab('9', 0, 11, 2)); $this->add(108, 108, $this->getCarteiraNumero()); $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_XX_VENC_UTEIS); } if ($boleto->getMulta() > 0) { $this->add(159, 160, self::INSTRUCAO_MULTA_PERC_XX_APOS_VENC_UTEIS); $this->add(206, 211, ''); $this->add(206, 215, Util::formatCnab('9', $boleto->getMulta(), 2, 2)); $this->add(206, 218, Util::formatCnab('9', $boleto->getJurosApos(), 3)); } else { $this->add(206, 218, Util::formatCnab('9', $boleto->getDescontosAbatimentos(), 13, 2)); } $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(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, 312, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 38)); $this->add(313, 314, '00'); $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, 390, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 39)); $this->add(391, 391, ''); $this->add(392, 393, Util::formatCnab('9', $boleto->getDiasProtesto(' '), 2)); $this->add(394, 394, $boleto->getMoeda()); $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6)); }
public function addBoleto(BoletoContract $boleto) { $this->iniciaDetalhe(); $this->add(1, 1, 7); $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, 22, Util::modulo11($this->getAgencia())); $this->add(23, 30, Util::formatCnab('9', $this->getConta(), 8)); $this->add(31, 31, Util::modulo11($this->getConta())); $this->add(32, 38, Util::formatCnab('9', $this->getConvenio(), 7)); $this->add(39, 63, Util::formatCnab('X', $boleto->getNumero(), 25)); // numero de controle $this->add(64, 80, $boleto->getNossoNumero()); $this->add(81, 82, '00'); $this->add(83, 84, '00'); $this->add(85, 87, ''); $this->add(88, 88, $boleto->getSacadorAvalista() ? 'A' : ''); $this->add(89, 91, ''); $this->add(92, 94, Util::formatCnab('9', $this->getVariacaoCarteira(), 3)); $this->add(95, 95, '0'); $this->add(96, 101, '000000'); $this->add(102, 106, ''); $this->add(107, 108, $this->getCarteiraNumero()); $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, 146, '0000'); $this->add(147, 147, ''); $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); $diasProtesto = '00'; $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); } $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, 271, Util::formatCnab('X', $boleto->getPagador()->getNome(), 37)); $this->add(272, 274, ''); $this->add(275, 314, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 40)); $this->add(315, 326, Util::formatCnab('X', $boleto->getPagador()->getBairro(), 12)); $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, 391, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 40)); $this->add(392, 393, $diasProtesto); $this->add(394, 394, ''); $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6)); if ($boleto->getMulta() > 0) { $this->iniciaDetalhe(); $this->add(1, 1, 5); $this->add(2, 3, 99); $this->add(4, 4, 2); $this->add(5, 10, $boleto->getDataVencimento()->copy()->addDays($boleto->getJurosApos())->format('dmy')); $this->add(11, 22, Util::formatCnab('9', $boleto->getMulta(), 7, 2)); $this->add(23, 394, ''); $this->add(23, 394, ''); $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6)); } }