private function geraNossoNumero()
 {
     $nossonumero = Util::numberFormatGeral($this->getNumero(), 7, 0) . Util::modulo11($this->getNumero());
     $this->nossoNumero = Util::numberFormatGeral($this->getNumero(), 7, 0) . '-' . Util::modulo11($this->getNumero());
     return str_pad($nossonumero, 13, "0", STR_PAD_LEFT);
     #completo com zeros na esquerda até atingir 13 caracteres
 }
 public function getBanco($verificacao = false)
 {
     if ($verificacao) {
         return sprintf('%s-%s', $this->banco, Util::modulo11($this->banco));
     }
     return $this->banco;
 }
 private function gerarNossoNumero()
 {
     $nossoNumero = Util::numberFormatGeral($this->getNumero(), 11, 0);
     $dv = Util::modulo11($nossoNumero, 7, 0, 'P');
     $this->nossoNumero = $this->getCarteira() . '/' . $nossoNumero . '-' . $dv;
     return $nossoNumero;
 }
Beispiel #4
0
 /**
  * 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;
     }
     $nossoNumero = Util::numberFormatGeral($this->gerarNossoNumero(), 17);
     $beneficiario = Util::numberFormatGeral($this->getConta(), 6);
     // Código do beneficiário + DV]
     $campoLivre = $beneficiario . Util::modulo11($beneficiario);
     // Sequencia 1 (posições 3-5 NN) + Constante 1 (1 => registrada, 2 => sem registro)
     $carteira = $this->getCarteira();
     if ($carteira == 'SR') {
         $constante = '2';
     } else {
         $constante = '1';
     }
     $campoLivre .= substr($nossoNumero, 2, 3) . $constante;
     // Sequencia 2 (posições 6-8 NN) + Constante 2 (4-Beneficiário)
     $campoLivre .= substr($nossoNumero, 5, 3) . '4';
     // Sequencia 3 (posições 9-17 NN)
     $campoLivre .= substr($nossoNumero, 8, 9);
     // DV do Campo Livre
     $campoLivre .= Util::modulo11($campoLivre);
     return $this->campoLivre = $campoLivre;
 }
Beispiel #5
0
 /**
  * @param $file
  *
  * @return Retorno
  * @throws \Exception
  */
 public static function make($file)
 {
     if ($file == '') {
         throw new \Exception("file url is required.");
     } elseif (file_exists($file)) {
         $file_content = file($file);
     } elseif (is_string($file)) {
         $file_content = explode(PHP_EOL, $file);
     } else {
         throw new \Exception("Arquivo: {$file}, não existe");
     }
     if (!Util::isCnab400($file_content) && !Util::isCnab240($file_content)) {
         throw new \Exception("Formato do arquivo não identificado.");
     } elseif (Util::isCnab400($file_content)) {
         /**  Cnab 400 */
         if (substr($file_content[0], 0, 9) != '02RETORNO') {
             throw new \Exception("Arquivo: {$file}, não é um arquivo de retorno");
         }
         $banco = substr($file_content[0], 76, 3);
         switch ($banco) {
             case Cnab::COD_BANCO_BB:
                 $instancia = new Cnab400\Banco\Bb($file_content);
                 break;
             case Cnab::COD_BANCO_SANTANDER:
                 $instancia = new Cnab400\Banco\Santander($file_content);
                 break;
             case Cnab::COD_BANCO_CEF:
                 $instancia = new Cnab400\Banco\Caixa($file_content);
                 break;
             case Cnab::COD_BANCO_BRADESCO:
                 $instancia = new Cnab400\Banco\Bradesco($file_content);
                 break;
             case Cnab::COD_BANCO_ITAU:
                 $instancia = new Cnab400\Banco\Itau($file_content);
                 break;
             case Cnab::COD_BANCO_HSBC:
                 $instancia = new Cnab400\Banco\Hsbc($file_content);
                 break;
             default:
                 throw new \Exception("Banco: {$banco}, inválido");
         }
     } else {
         if (Util::isCnab240($file_content)) {
             /** Cnab 240 */
             if (substr($file_content[0], 142, 1) != '2') {
                 throw new \Exception("Arquivo: {$file}, não é um arquivo retorno");
             }
             $banco = substr($file_content[0], 0, 3);
             switch ($banco) {
                 case Cnab::COD_BANCO_SANTANDER:
                     $instancia = new Cnab240\Banco\Santander($file_content);
                     break;
                 default:
                     throw new \Exception("Banco: {$banco}, inválido");
             }
         }
     }
     return $instancia->processar();
 }
Beispiel #6
0
 private function geraNossoNumero()
 {
     if ($this->getAgencia() && $this->getConta() && $this->getCarteira()) {
         $nossonumero = Util::numberFormatGeral($this->getNumero(), 8, 0);
         $dv = Util::modulo10($this->getAgencia() . $this->getConta() . $this->getCarteira() . $nossonumero);
         $this->nossoNumero = $this->getCarteira() . '/' . $nossonumero . '-' . $dv;
         return $nossonumero . $dv;
     } else {
         throw new Exception('Todos os parâmetros devem ser informados {numero,contaCorrente,agencia}');
     }
 }
Beispiel #7
0
 /**
  * @param $file_content
  *
  * @return mixed
  * @throws \Exception
  */
 private static function getBancoClass($file_content)
 {
     $banco = '';
     $namespace = '';
     if (Util::isCnab400($file_content)) {
         /**  Cnab 400 */
         $banco = substr($file_content[0], 76, 3);
         $namespace = __NAMESPACE__ . '\\Cnab400\\';
     } elseif (Util::isCnab240($file_content)) {
         /** Cnab 240 */
         $banco = substr($file_content[0], 0, 3);
         $namespace = __NAMESPACE__ . '\\Cnab240\\';
     }
     $aBancos = [BoletoContract::COD_BANCO_BB => 'Banco\\Bb', BoletoContract::COD_BANCO_SANTANDER => 'Banco\\Santander', BoletoContract::COD_BANCO_CEF => 'Banco\\Caixa', BoletoContract::COD_BANCO_BRADESCO => 'Banco\\Bradesco', BoletoContract::COD_BANCO_ITAU => 'Banco\\Itau', BoletoContract::COD_BANCO_HSBC => 'Banco\\Hsbc', BoletoContract::COD_BANCO_SICREDI => 'Banco\\Sicredi', BoletoContract::COD_BANCO_BANRISUL => 'Banco\\Banrisul'];
     if (array_key_exists($banco, $aBancos)) {
         $bancoClass = $namespace . $aBancos[$banco];
         return new $bancoClass($file_content);
     }
     throw new \Exception("Banco: {$banco}, inválido");
 }
 protected function processarTrailer(array $trailer)
 {
     $this->getTrailer()->setQuantidadeTitulos((int) $this->count())->setValorTitulos((double) Util::nFloat($this->totais['valor_recebido'], 2, false))->setQuantidadeErros((int) $this->totais['erros'])->setQuantidadeEntradas((int) $this->totais['entradas'])->setQuantidadeLiquidados((int) $this->totais['liquidados'])->setQuantidadeBaixados((int) $this->totais['baixados'])->setQuantidadeAlterados((int) $this->totais['alterados']);
     return true;
 }
Beispiel #9
0
 /**
  * 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;
     }
     $numero = Util::numberFormatGeral($this->getNumero(), 8);
     $carteira = Util::numberFormatGeral($this->getCarteira(), 3);
     $agencia = Util::numberFormatGeral($this->getAgencia(), 4);
     $conta = Util::numberFormatGeral($this->getConta(), 5);
     // Carteira 198 - (Nosso Número com 15 posições) - Anexo 5 do manual
     if (in_array($this->getCarteira(), ['107', '122', '142', '143', '196', '198'])) {
         $codigo = $carteira . $numero . Util::numberFormatGeral($this->getNumeroDocumento(), 7) . Util::numberFormatGeral($this->getCodigoCliente(), 5);
         // Define o DV da carteira para a view
         $this->carteiraDv = $modulo = Util::modulo10($codigo);
         return $this->campoLivre = $codigo . $modulo . '0';
     }
     // Geração do DAC - Anexo 4 do manual
     if (!in_array($this->getCarteira(), ['126', '131', '146', '150', '168'])) {
         // Define o DV da carteira para a view
         $this->carteiraDv = $dvAgContaCarteira = Util::modulo10($agencia . $conta . $carteira . $numero);
     } else {
         // Define o DV da carteira para a view
         $this->carteiraDv = $dvAgContaCarteira = Util::modulo10($carteira . $numero);
     }
     // Módulo 10 Agência/Conta
     $dvAgConta = Util::modulo10($agencia . $conta);
     return $this->campoLivre = $carteira . $numero . $dvAgContaCarteira . $agencia . $conta . $dvAgConta . '000';
 }
Beispiel #10
0
 public function BottomBB($i)
 {
     $this->SetDrawColor('00', '00', '80');
     $this->Image($this->logoPath . $this->boleto[$i]->getBanco() . '.png', 20, $this->GetY() - 2, 28);
     $this->Cell(29, 6, '', '');
     $this->SetFont('', '', 13);
     $this->Cell(15, 6, $this->boleto[$i]->getBanco(true), 'LR', 0, 'C');
     $this->SetFont('', '', 10);
     $this->Cell(0, 6, $this->boleto[$i]->getLinha(), '', 1, 'R');
     $this->Ln(1);
     $this->risco();
     $this->Ln(1);
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(120, $this->desc, $this->_('Local de pagamento'), '');
     $x = $this->GetX();
     $y = $this->GetY();
     $this->Cell(50, $this->desc, $this->_('Vencimento'), '', 1, 'L', true);
     $this->SetFont($this->PadraoFont, 'B', $this->fcel);
     $this->Cell(120, $this->cell, $this->_($this->boleto[$i]->getLocalPagamento()), '');
     $this->Cell(50, $this->cell, $this->_($this->boleto[$i]->getDataVencimento()->format('d/m/Y')), '', 1, 'R', true);
     $this->riscoBB($x, $y);
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(120, $this->desc, $this->_('Beneficiário'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(50, $this->desc, $this->_('Agência/Código beneficiário'), 'T', 1);
     $this->SetFont($this->PadraoFont, 'B', $this->fcel);
     $this->Cell(120, $this->cell, $this->_($this->boleto[$i]->getCedenteNome()), '');
     $this->Cell(50, $this->cell, $this->_($this->boleto[$i]->getBanco(true)), '', 1, '');
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(30, $this->desc, $this->_('Data do documento'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(40, $this->desc, $this->_('Número do documento'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(15, $this->desc, $this->_('Espécie Doc.'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(10, $this->desc, $this->_('Aceite'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(25, $this->desc, $this->_('Data processamento'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(50, $this->desc, $this->_('Nosso número'), 'T', 1);
     $this->SetFont($this->PadraoFont, 'B', $this->fcel);
     $this->Cell(30, $this->cell, $this->_($this->boleto[$i]->getDataDocumento()->format('d/m/Y')), '');
     $this->Cell(40, $this->cell, $this->_($this->boleto[$i]->getNumero()), '');
     $this->Cell(15, $this->cell, $this->_($this->boleto[$i]->getEspecieDocumento()), '');
     $this->Cell(10, $this->cell, $this->_($this->boleto[$i]->getAceite()), '');
     $this->Cell(25, $this->cell, $this->_($this->boleto[$i]->getDataProcessamento()->format('d/m/Y')), '');
     $this->Cell(50, $this->cell, $this->_($this->boleto[$i]->getNossoNumero()), '', 1, 'R');
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $x = $this->GetX();
     $y = $this->GetY();
     $this->Cell(30, $this->desc, $this->_('Uso do Banco'), 'T', 0, '', true);
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(25, $this->desc, $this->_('Carteira'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(12, $this->desc, $this->_('Espécie'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(28, $this->desc, $this->_('Quantidade'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(25, $this->desc, $this->_('Valor Documento'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(50, $this->desc, $this->_('Valor Documento'), 'T', 1);
     $this->SetFont($this->PadraoFont, 'B', $this->fcel);
     $this->Cell(30, $this->cell, $this->_(''), '', 0, '', true);
     $this->riscoBB($x, $y);
     $this->Cell(25, $this->cell, $this->_($this->boleto[$i]->getCarteira()), '');
     $this->Cell(12, $this->cell, $this->_('R$'), '');
     $this->Cell(28, $this->cell, $this->_('1'), '');
     $this->Cell(25, $this->cell, $this->_(Util::nReal($this->boleto[$i]->getValor())), '');
     $this->Cell(50, $this->cell, $this->_(Util::nReal($this->boleto[$i]->getValor())), '', 1, 'R');
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->Cell(120, $this->desc, $this->_('Instruções (Texto de responsabilidade do beneficiário)'), 'T');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(50, $this->desc, $this->_('(-) Desconto / Abatimentos)'), 'T', 1);
     $xInstrucoes = $this->GetX();
     $yInstrucoes = $this->GetY();
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->Cell(120, $this->cell, $this->_(''), '');
     $this->Cell(50, $this->cell, $this->_(''), '', 1);
     $this->Cell(120, $this->desc, $this->_(''), '');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(50, $this->desc, $this->_('(-) Outras deduções'), 'T', 1);
     $this->Cell(120, $this->cell, $this->_(''), '');
     $this->Cell(50, $this->cell, $this->_(''), '', 1);
     $this->Cell(120, $this->desc, $this->_(''), '');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(50, $this->desc, $this->_('(+) Mora / Multa'), 'T', 1);
     $this->Cell(120, $this->cell, $this->_(''), '');
     $this->Cell(50, $this->cell, $this->_(''), '', 1);
     $this->Cell(120, $this->desc, $this->_(''), '');
     $this->riscoBB($this->GetX(), $this->GetY());
     $this->Cell(50, $this->desc, $this->_('(+) Outros acréscimos'), 'T', 1);
     $this->Cell(120, $this->cell, $this->_(''), '');
     $this->Cell(50, $this->cell, $this->_(''), '', 1);
     $this->Cell(120, $this->desc, $this->_(''), '');
     $x = $this->GetX();
     $y = $this->GetY();
     $this->Cell(50, $this->desc, $this->_('(=) Valor cobrado'), 'T', 1, '', true);
     $this->Cell(120, $this->cell, $this->_(''), 'B');
     $this->Cell(50, $this->cell, $this->_(''), 'B', 1, '', true);
     $this->riscoBB($x, $y);
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->riscoBB($this->GetX(), $this->GetY(), 18);
     $this->Cell(0, $this->desc, $this->_('Pagador'), '', 1);
     $this->SetFont($this->PadraoFont, 'B', $this->fcel);
     $this->Cell(0, $this->cell, $this->_($this->boleto[$i]->getSacadoNome()), '', 1);
     $this->Cell(0, $this->cell, $this->_($this->boleto[$i]->getSacadoEndereco()), '', 1);
     $this->Cell(0, $this->cell, $this->_($this->boleto[$i]->getSacadoCidadeUF()), '', 1);
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->Cell(120, $this->cell, $this->_('Pagador/Avalista'), 'TB');
     $this->riscoBB($this->GetX(), $this->GetY(), 3);
     $this->Cell(12, $this->cell, $this->_('Cód. Baixa'), 'BT');
     $this->SetFont($this->PadraoFont, 'B', $this->fcel);
     $this->Cell(38, $this->cell, $this->_($this->boleto[$i]->getCodigoBaixa()), 'BT', 1);
     $this->SetFont($this->PadraoFont, '', $this->fdes);
     $this->Cell(118, $this->desc, $this->_(''), 0);
     $this->Cell(52, $this->desc, $this->_('Autenticação mecânica - Ficha de Compensação'), 0, 1);
     $xOriginal = $this->GetX();
     $yOriginal = $this->GetY();
     if (count($this->boleto[$i]->getInstrucoes()) > 0) {
         $this->SetXY($xInstrucoes, $yInstrucoes);
         $this->Ln(1);
         $this->SetFont($this->PadraoFont, 'B', $this->fcel);
         foreach ($this->boleto[$i]->getInstrucoes() as $in) {
             $this->Cell(0, $this->cell, $this->_($in), 0, 1);
         }
     }
     $this->SetXY($xOriginal, $yOriginal);
     return $this;
 }
Beispiel #11
0
 protected function trailer()
 {
     $this->iniciaTrailer();
     $this->add(1, 1, '9');
     $this->add(2, 394, '');
     $this->add(395, 400, Util::formatCnab('9', $this->getCount(), 6));
     return $this;
 }
Beispiel #12
0
 /**
  * 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;
 }
Beispiel #13
0
 /**
  * Método para gerar o código da posição de 20 a 44
  *
  * @return string
  */
 protected function getCampoLivre()
 {
     if ($this->campoLivre) {
         return $this->campoLivre;
     }
     $ag = Util::numberFormatGeral($this->getAgencia(), 4);
     $cc = Util::numberFormatGeral($this->getConta(), 6);
     $agCc = $ag . $cc . ($this->getContaDv() ? $this->getContaDv() : Util::modulo11($ag . $cc));
     return $this->campoLivre = $this->getNossoNumero() . $agCc . '00' . '1';
     // Codigo do aplicativo
 }
Beispiel #14
0
 protected function processarTrailer(array $trailer)
 {
     $this->trailer->quantidadeTitulos = (int) $this->rem(18, 25, $trailer) + (int) $this->rem(58, 65, $trailer) + (int) $this->rem(178, 185, $trailer);
     $this->trailer->valorTitulos = Util::nFloat($this->rem(221, 234, $trailer) / 100);
     $this->trailer->quantidadeErros = (int) $this->totais['erros'];
     $this->trailer->quantidadeEntradas = (int) $this->totais['entradas'];
     $this->trailer->quantidadeLiquidados = (int) $this->totais['liquidados'];
     $this->trailer->quantidadeBaixados = (int) $this->totais['baixados'];
     $this->trailer->quantidadeAlterados = (int) $this->totais['alterados'];
 }
 /**
  * Função para add valor a linha nas posições informadas.
  *
  * @param $i
  * @param $f
  * @param $value
  *
  * @return array
  * @throws \Exception
  */
 protected function add($i, $f, $value)
 {
     return Util::adiciona($this->atual, $i, $f, $value);
 }
 protected function processarTrailer(array $trailer)
 {
     $this->trailer->quantidadeTitulos = (int) $this->i;
     $this->trailer->valorTitulos = Util::nFloat($this->totais['valor']);
     $this->trailer->avisos = (int) $this->rem(40, 47, $trailer) + (int) $this->rem(120, 137, $trailer) + (int) $this->rem(160, 167, $trailer);
     $this->trailer->quantidadeErros = (int) $this->totais['erros'];
     $this->trailer->quantidadeEntradas = (int) $this->totais['entradas'];
     $this->trailer->quantidadeLiquidados = (int) $this->totais['liquidados'];
     $this->trailer->quantidadeBaixados = (int) $this->totais['baixados'];
     $this->trailer->quantidadeAlterados = (int) $this->totais['alterados'];
 }
Beispiel #17
0
 protected function trailer()
 {
     $this->iniciaTrailer();
     $this->add(1, 1, '9');
     $this->add(2, 2, '1');
     $this->add(3, 5, $this->getCodigoBanco());
     $this->add(6, 10, $this->getConta());
     $this->add(11, 394, '');
     $this->add(395, 400, Util::formatCnab('9', $this->getCount(), 6));
     return $this;
 }
Beispiel #18
0
 /**
  * Retorna o campo CIP do boleto
  *
  * @return int
  */
 public function getCip()
 {
     return Util::numberFormatGeral($this->cip, 3);
 }
 public function getSacadoDocumento($default = ' ')
 {
     return Util::onlyNumbers($this->isEmpty($this->sacadoDocumento) ? $default : $this->sacadoDocumento);
 }
Beispiel #20
0
 /**
  * Verifica se a carteira é uma das seguintes : R, S, X ou alguma a mais passada por parametro
  *
  * @param array $adicional
  *
  * @return bool
  */
 private function isCarteiraRSX(array $adicional = [])
 {
     return in_array(Util::upper($this->getCarteira()), array_merge(['R', 'S', 'X'], $adicional));
 }
Beispiel #21
0
 protected function trailer()
 {
     $this->iniciaTrailer();
     $this->add(1, 1, '9');
     $this->add(2, 7, Util::formatCnab('9', $this->getCount(), 6));
     $this->add(8, 20, Util::formatCnab('9', $this->total, 13, 2));
     $this->add(21, 394, Util::formatCnab('9', 0, 374));
     $this->add(395, 400, Util::formatCnab('9', $this->getCount(), 6));
     return $this;
 }
Beispiel #22
0
 protected function processarTrailer(array $trailer)
 {
     $this->getTrailer()->setQuantidadeTitulos($this->rem(18, 25, $trailer))->setValorTitulos(Util::nFloat($this->rem(26, 39, $trailer) / 100, 2, false))->setQuantidadeErros((int) $this->totais['erros'])->setQuantidadeEntradas((int) $this->totais['entradas'])->setQuantidadeLiquidados((int) $this->totais['liquidados'])->setQuantidadeBaixados((int) $this->totais['baixados'])->setQuantidadeAlterados((int) $this->totais['alterados']);
     return true;
 }
Beispiel #23
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';
 }
Beispiel #24
0
 /**
  * Método para gerar o código da posição de 20 a 44
  *
  * @return string
  */
 protected function getCampoLivre()
 {
     if ($this->campoLivre) {
         return $this->campoLivre;
     }
     return $this->campoLivre = '9' . Util::numberFormatGeral($this->getConta(), 7) . $this->getNossoNumero() . Util::numberFormatGeral($this->getIos(), 1) . Util::numberFormatGeral($this->getCarteira(), 3);
 }
 private function geraNossoNumero()
 {
     $nossonumero = Util::numberFormatGeral($this->getNumero(), 7, 0) . Util::modulo11($this->getNumero());
     $this->nossoNumero = Util::numberFormatGeral($this->getNumero(), 7, 0) . '-' . Util::modulo11($this->getNumero());
     return sprintf('%013s', $nossonumero);
 }
Beispiel #26
0
 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;
 }
Beispiel #27
0
 private function arrumaCodCedente()
 {
     $_4first = substr($this->getCedenteCodigo(), 0, 4);
     $agencia = Util::formatCnab('9', $this->getAgencia(), 4);
     if ($_4first != $agencia) {
         if (strlen($this->getCedenteCodigo()) == 12) {
             $this->cedenteCodigo = $agencia . $this->getCedenteCodigo();
         } else {
             if (strlen($this->getCedenteCodigo()) == 11) {
                 $this->cedenteCodigo = $agencia . $this->getCedenteCodigo();
                 $this->cedenteCodigo .= Util::modulo11($this->getCedenteCodigo());
             } else {
                 throw new \Exception('Codigo de cedente inválido, formato: PPPXXXXXXXXD');
             }
         }
     }
 }
Beispiel #28
0
 protected function processarTrailer(array $trailer)
 {
     $this->trailer->quantidadeTitulos = (int) $this->i;
     $this->trailer->valorTitulos = Util::nFloat(0);
     $this->trailer->quantidadeErros = (int) $this->totais['erros'];
     $this->trailer->quantidadeEntradas = (int) $this->totais['entradas'];
     $this->trailer->quantidadeLiquidados = (int) $this->totais['liquidados'];
     $this->trailer->quantidadeBaixados = (int) $this->totais['baixados'];
     $this->trailer->quantidadeAlterados = (int) $this->totais['alterados'];
 }
 /**
  * Return Boleto Array.
  *
  * @return array
  */
 public function toArray()
 {
     return array_merge(['linha_digitavel' => $this->getLinhaDigitavel(), 'codigo_barras' => $this->getCodigoBarras(), 'beneficiario' => $this->getBeneficiario()->getNome(), 'beneficiario_nome_documento' => $this->getBeneficiario()->getNomeDocumento(), 'beneficiario_cpf_cnpj' => $this->getBeneficiario()->getDocumento(), 'beneficiario_endereco1' => $this->getBeneficiario()->getEndereco(), 'beneficiario_endereco2' => $this->getBeneficiario()->getCepCidadeUf(), 'logo_base64' => $this->getLogoBase64(), 'logo' => $this->getLogo(), 'logo_banco_base64' => $this->getLogoBancoBase64(), 'logo_banco' => $this->getLogoBanco(), 'codigo_banco_com_dv' => $this->getCodigoBancoComDv(), 'especie' => 'R$', 'quantidade' => $this->getQuantidade(), 'data_vencimento' => $this->getDataVencimento()->format('d/m/Y'), 'data_processamento' => $this->getDataProcessamento()->format('d/m/Y'), 'data_documento' => $this->getDataDocumento()->format('d/m/Y'), 'valor_documento' => Util::nReal($this->getValor(), 2, false), 'desconto_abatimento' => Util::nReal($this->getDescontosAbatimentos(), 2, false), 'outras_deducoes' => Util::nReal($this->getOutrasDeducoes(), 2, false), 'multa' => Util::nReal($this->getMulta(), 2, false), 'juros' => Util::nReal($this->getMulta(), 2, false), 'outros_acrescimos' => Util::nReal($this->getOutrosAcrescimos(), 2, false), 'valor_cobrado' => Util::nReal($this->getValorCobrado(), 2, false), 'valor_unitario' => Util::nReal($this->getValorUnitario(), 2, false), 'sacador_avalista' => $this->getSacadorAvalista() ? $this->getSacadorAvalista()->getNomeDocumento() : null, 'pagador' => $this->getPagador()->getNome(), 'pagador_nome_documento' => $this->getPagador()->getNomeDocumento(), 'pagador_documento' => $this->getPagador()->getDocumento(), 'pagador_endereco1' => $this->getPagador()->getEndereco(), 'pagador_endereco2' => $this->getPagador()->getCepCidadeUf(), 'demonstrativo' => array_slice((array) $this->getDescricaoDemonstrativo() + [null, null, null, null, null], 0, 5), 'instrucoes' => array_slice((array) $this->getInstrucoes() + [null, null, null, null, null, null, null, null], 0, 8), 'local_pagamento' => $this->getLocalPagamento(), 'numero_documento' => $this->getNumeroDocumento(), 'agencia_codigo_beneficiario' => $this->getAgenciaCodigoBeneficiario(), 'nosso_numero' => $this->getNossoNumero(), 'nosso_numero_boleto' => $this->getNossoNumeroBoleto(), 'especie_doc' => $this->getEspecieDoc(), 'especie_doc_cod' => $this->getEspecieDocCodigo(), 'aceite' => $this->getAceite(), 'carteira' => $this->getCarteiraNome(), 'uso_banco' => $this->getUsoBanco()], $this->variaveis_adicionais);
 }
Beispiel #30
0
 /**
  * @param array $trailerLote
  *
  * @return boolean
  */
 protected function processarTrailerLote(array $trailer)
 {
     $this->getTrailerLote()->setLoteServico($this->rem(4, 7, $trailer))->setTipoRegistro($this->rem(8, 8, $trailer))->setQtdRegistroLote((int) $this->rem(18, 23, $trailer))->setQtdTitulosCobrancaSimples((int) $this->rem(24, 29, $trailer))->setValorTotalTitulosCobrancaSimples(Util::nFloat($this->rem(30, 46, $trailer)) / 100, 2, false)->setQtdTitulosCobrancaVinculada((int) $this->rem(47, 52, $trailer))->setValorTotalTitulosCobrancaVinculada(Util::nFloat($this->rem(53, 69, $trailer)) / 100, 2, false)->setQtdTitulosCobrancaCaucionada((int) $this->rem(70, 75, $trailer))->setValorTotalTitulosCobrancaCaucionada(Util::nFloat($this->rem(76, 92, $trailer)) / 100, 2, false)->setQtdTitulosCobrancaDescontada((int) $this->rem(93, 98, $trailer))->setValorTotalTitulosCobrancaDescontada(Util::nFloat($this->rem(99, 115, $trailer)) / 100, 2, false)->setNumeroAvisoLancamento($this->rem(116, 123, $trailer));
     return true;
 }