onlyNumbers() public static méthode

Retorna somente os digitos da string
public static onlyNumbers ( String $string ) : String
$string String
Résultat String
 /**
  * Retorna o Nosso Número calculado.
  *
  * @param bool $incluirFormatacao Incluir formatação ou não (pontuação, espaços e barras)
  * @return string
  */
 public function getNossoNumero($incluirFormatacao = true)
 {
     if (empty($this->campoNossoNumero)) {
         $this->campoNossoNumero = $this->gerarNossoNumero();
     }
     $numero = $this->campoNossoNumero;
     // Remove a formatação, caso especificado
     if (!$incluirFormatacao) {
         return Util::onlyNumbers($numero);
     }
     return $numero;
 }
 /**
  * Método para gerar o código da posição de 20 a 44
  *
  * @return string
  * @throws \Exception
  */
 protected function getCampoLivre()
 {
     if ($this->campoLivre) {
         return $this->campoLivre;
     }
     // Carteira     => 20 - 20 | Valor: 1(Com registro) ou 2(Sem registro)
     $this->campoLivre = '2';
     // Constante    => 21 - 21 | Valor: 1(Constante)
     $this->campoLivre .= '1';
     // Agencia      => 22 a 25 | Valor: dinâmico(0000) ´4´
     $this->campoLivre .= Util::numberFormatGeral($this->getAgencia(), 4);
     // Cod. Cedente => 26 a 32 | Valor: dinâmico(0000000) ´7´
     $this->campoLivre .= $this->getConta();
     // Nosso numero => 33 a 40 | Valor: dinâmico(00000000) ´8´
     $this->campoLivre .= Util::numberFormatGeral($this->getNumeroDocumento(), 8);
     // Constante    => 41 - 42 | Valor: 40(Constante)
     $this->campoLivre .= '40';
     // Duplo digito => 43 - 44 | Valor: calculado(00) ´2´
     $this->campoLivre .= $this->duploDigitoBanrisul(Util::onlyNumbers($this->campoLivre));
     return $this->campoLivre;
 }
Exemple #3
0
 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;
 }
Exemple #4
0
 /**
  * Retorna se o tipo do documento é CPF ou CNPJ ou Documento
  *
  * @return string
  */
 public function getTipoDocumento()
 {
     $cpf_cnpj = Util::onlyNumbers($this->documento);
     if (strlen($cpf_cnpj) == 11) {
         return 'CPF';
     } else {
         if (strlen($cpf_cnpj) == 14) {
             return 'CNPJ';
         }
     }
     return 'Documento';
 }
Exemple #5
0
 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 getSacadoDocumento($default = ' ')
 {
     return Util::onlyNumbers($this->isEmpty($this->sacadoDocumento) ? $default : $this->sacadoDocumento);
 }
 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();
     $beneficiario_id = '0' . Util::formatCnab('9', $this->getCarteiraNumero(), 3) . Util::formatCnab('9', $this->getAgencia(), 5) . Util::formatCnab('9', $this->getConta(), 7) . Util::formatCnab('9', $this->getContaDv(), 1);
     $this->add(1, 1, '1');
     $this->add(2, 6, '');
     $this->add(7, 7, '');
     $this->add(8, 12, '');
     $this->add(13, 19, '');
     $this->add(20, 20, '');
     $this->add(21, 37, Util::formatCnab('X', $beneficiario_id, 17));
     $this->add(38, 62, Util::formatCnab('X', $boleto->getNumero(), 25));
     // numero de controle
     $this->add(63, 65, $this->getCodigoBanco());
     $this->add(66, 66, $boleto->getMulta() > 0 ? '2' : '0');
     $this->add(67, 70, Util::formatCnab('9', $boleto->getMulta() > 0 ? $boleto->getMulta() : '0', 4, 2));
     $this->add(71, 81, Util::formatCnab('9', $boleto->getNossoNumero(), 11));
     $this->add(82, 82, Util::modulo11($boleto->getCarteira() . $boleto->getNossoNumero(), 2, 7, 0, 'P'));
     $this->add(83, 92, Util::formatCnab('9', 0, 10, 2));
     $this->add(93, 93, '2');
     // 1 = Banco emite e Processa o registro. 2 = Cliente emite e o Banco somente processa o registro
     $this->add(94, 94, '');
     // N= Não registra na cobrança. Diferente de N registra e emite Boleto.
     $this->add(95, 104, '');
     $this->add(105, 105, '');
     $this->add(106, 106, '2');
     // 1 = emite aviso, e assume o endereço do Pagador constante do Arquivo-Remessa; 2 = não emite aviso;
     $this->add(107, 108, '');
     $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->add(143, 147, '00000');
     $this->add(148, 149, $boleto->getEspecieDocCodigo());
     $this->add(150, 150, 'N');
     $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);
         $this->add(159, 160, Util::formatCnab('9', $boleto->getDiasProtesto(), 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(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, 394, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 60));
     $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));
     return $this;
 }
 protected function trailer()
 {
     $this->iniciaTrailer();
     $this->add(1, 3, Util::onlyNumbers($this->getCodigoBanco()));
     //Codigo do banco
     $this->add(4, 7, '9999');
     // Numero do lote remessa
     $this->add(8, 8, Util::formatCnab(9, 9, 1));
     //Tipo de registro
     $this->add(9, 17, '');
     // Reservado (Uso Banco)
     $this->add(18, 23, Util::formatCnab(9, 1, 6));
     // Qtd de lotes do arquivo
     $this->add(24, 29, Util::formatCnab(9, $this->qtyRegistrosLote + 4, 6));
     // Qtd de lotes do arquivo
     $this->add(30, 240, '');
     // Reservado (Uso Banco)
     return $this;
 }
Exemple #10
0
 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));
     }
 }
Exemple #11
0
 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));
 }
 /**
  * @param BoletoContract $boleto
  * @return bool
  */
 public function addBoleto(BoletoContract $boleto)
 {
     $this->iniciaDetalhe();
     $this->add(1, 1, 1);
     $this->add(2, 17, '');
     $this->add(18, 30, Util::formatCnab('9', $this->getCodigoCliente(), 13, '0'));
     $this->add(31, 37, '');
     $this->add(38, 62, Util::formatCnab('X', $boleto->getNumero(), 25));
     $this->add(63, 72, Util::formatCnab('9L', $boleto->getNossoNumero(), 10));
     $this->add(73, 104, '');
     $this->add(105, 107, '');
     $this->add(108, 108, Util::formatCnab('X', $boleto->getCarteira(), 1));
     $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, '');
     $this->add(148, 149, $this->isCarteiraRSX() ? '' : self::TIPO_COBRANCA_CREDENCIADA);
     $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);
     }
     if ($boleto->getMulta() > 0) {
         $this->add(159, 160, self::INSTRUCAO_MULTA_XX);
     }
     $juros = 0;
     if ($boleto->getJuros() > 0) {
         $juros = Util::percent($boleto->getValor(), $boleto->getJuros()) / 30;
     }
     $this->add(161, 161, '0');
     $this->add(162, 173, Util::formatCnab('9', $juros, 12, 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, 269, Util::formatCnab('X', $boleto->getPagador()->getNome(), 35));
     $this->add(270, 274, '');
     $this->add(275, 314, Util::formatCnab('X', $boleto->getPagador()->getEndereco(), 40));
     $this->add(315, 321, '');
     $this->add(322, 324, Util::formatCnab('9', $boleto->getMulta(), 3, 1));
     $this->add(325, 326, '00');
     $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, 355, Util::formatCnab('9', 0, 3));
     $this->add(356, 357, '');
     $this->add(358, 369, '00');
     $this->add(370, 371, Util::formatCnab('9', $boleto->getDiasProtesto(), 2));
     $this->add(372, 394, '');
     $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));
     $this->valorTotal += $boleto->getValor();
     return true;
 }
Exemple #13
0
 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));
     }
 }
Exemple #14
0
 public function addBoleto(BoletoContract $boleto)
 {
     if (!$boleto->isComRegistro()) {
         return $this;
     }
     $this->iniciaDetalhe();
     $this->add(1, 1, '1');
     $this->add(2, 2, 'A');
     $this->add(3, 3, 'A');
     $this->add(4, 4, 'A');
     $this->add(5, 16, '');
     $this->add(17, 17, 'A');
     $this->add(18, 18, 'A');
     $this->add(19, 19, 'B');
     $this->add(20, 47, '');
     $this->add(48, 56, Util::formatCnab('9', $boleto->getNossoNumero(), 9));
     $this->add(57, 62, '');
     $this->add(63, 70, Carbon::now()->format('Ymd'));
     $this->add(71, 71, '');
     $this->add(72, 72, $boleto->getByte() == 1 ? 'S' : 'N');
     $this->add(73, 73, '');
     $this->add(74, 74, $boleto->getByte() == 1 ? 'A' : 'B');
     $this->add(75, 76, '');
     $this->add(77, 78, '');
     $this->add(79, 82, '');
     $this->add(83, 92, Util::formatCnab('9', 0, 10, 2));
     $this->add(93, 96, Util::formatCnab('9', $boleto->getMulta(), 4, 2));
     $this->add(97, 108, '');
     $this->add(109, 110, self::OCORRENCIA_REMESSA);
     // REGISTRO
     if ($boleto->getStatus() == $boleto::STATUS_BAIXA) {
         $this->add(109, 110, self::OCORRENCIA_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, 148, '');
     $this->add(149, 149, $boleto->getEspecieDocCodigo('A'));
     $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_PROTESTO);
         $this->add(159, 160, Util::formatCnab('9', $boleto->getDiasProtesto(), 2));
     }
     $this->add(161, 173, Util::formatCnab('9', $boleto->getJuros(), 13, 2));
     $this->add(174, 179, $boleto->getDataVencimento()->format('dmy'));
     $this->add(180, 192, Util::formatCnab('9', $boleto->getDescontosAbatimentos(), 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 ? '20' : '10');
     $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, 319, '00000');
     $this->add(320, 325, '000000');
     $this->add(326, 326, ' ');
     $this->add(327, 334, Util::formatCnab('9L', $boleto->getPagador()->getCep(), 8));
     $this->add(335, 339, '00000');
     $this->add(340, 353, Util::formatCnab('9L', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getDocumento() : '', 14));
     $this->add(354, 394, Util::formatCnab('X', $boleto->getSacadorAvalista() ? $boleto->getSacadorAvalista()->getNome() : '', 41));
     $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));
     if ($boleto->getByte() == 1) {
         $this->iniciaDetalhe();
         $this->add(1, 1, '2');
         $this->add(2, 12, '');
         $this->add(13, 21, Util::formatCnab('9', $boleto->getNossoNumero(), 9));
         $this->add(22, 101, Util::formatCnab('X', $boleto->getInstrucoes()[0], 80));
         $this->add(102, 181, Util::formatCnab('X', $boleto->getInstrucoes()[1], 80));
         $this->add(122, 261, Util::formatCnab('X', $boleto->getInstrucoes()[2], 80));
         $this->add(262, 341, Util::formatCnab('X', $boleto->getInstrucoes()[3], 80));
         $this->add(342, 351, Util::formatCnab('9', $boleto->getNumeroDocumento(), 10));
         $this->add(352, 394, '');
         $this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));
     }
     return $this;
 }