Skip to content

Commit

Permalink
Carne 3 por folha, Bancoob fim de arquivo
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardokum committed May 3, 2018
1 parent b7f0d67 commit f4064be
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 17 deletions.
Binary file added manuais/BANRISUL/webservice/Banrisul.pdf
Binary file not shown.
Binary file added manuais/BB/webservice/BancoDoBrasil.pdf
Binary file not shown.
Binary file added manuais/CEF/webservice/Caixa.pdf
Binary file not shown.
Binary file added manuais/SANTANDER/webservice/Santander.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions src/Boleto/Render/cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
8 changes: 6 additions & 2 deletions src/Boleto/Render/view/carne.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@extends('BoletoHtmlRender::layout')
@section('boleto')

<style>
.table-boleto .conteudo {
height: 11px;
}
</style>
@foreach($boletos as $i => $boleto)
@php extract($boleto, EXTR_OVERWRITE); @endphp
<div style="width: 863px">
Expand Down Expand Up @@ -113,7 +117,7 @@
<div class="linha-pontilhada">Corte na linha pontilhada</div>
</div>

@if(count($boletos) > 3 && $i > 0 && $i % 3 === 0)
@if(count($boletos) > 3 && $i > 0 && ($i+1) % 3 === 0)
<div style="page-break-before:always"></div>
@endif
@endforeach
Expand Down
20 changes: 13 additions & 7 deletions src/Cnab/Remessa/AbstractRemessa.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
namespace Eduardokum\LaravelBoleto\Cnab\Remessa;

use Eduardokum\LaravelBoleto\Contracts\Boleto\Boleto as BoletoContract;
use Eduardokum\LaravelBoleto\Contracts\Pessoa as PessoaContract;
use Carbon\Carbon;
use Eduardokum\LaravelBoleto\Util;
use Eduardokum\LaravelBoleto\Contracts\Pessoa as PessoaContract;
use Eduardokum\LaravelBoleto\Contracts\Boleto\Boleto as BoletoContract;

abstract class AbstractRemessa
{
Expand Down Expand Up @@ -88,7 +89,7 @@ abstract class AbstractRemessa
/**
* A data que será informada no header da remessa
*
* @var \Carbon\Carbon;
* @var Carbon;
*/
protected $dataRemessa = null;
/**
Expand Down Expand Up @@ -139,9 +140,10 @@ public function __construct($params = [])
Util::fillClass($this, $params);
}

/**
/**
* Informa a data da remessa a ser gerada
*
* @param $data
*/
public function setDataRemessa($data){
$this->dataRemessa = $data;
Expand All @@ -150,11 +152,13 @@ public function setDataRemessa($data){
/**
* Retorna a data da remessa a ser gerada
*
* @return \Carbon\Carbon;
* @param $format
*
* @return string;
*/
public function getDataRemessa($format){
if(is_null($this->dataRemessa)){
return \Carbon\Carbon::now()->format($format);
return Carbon::now()->format($format);
}
return $this->dataRemessa->format($format);
}
Expand Down Expand Up @@ -364,6 +368,8 @@ public function getCarteiras()
/**
* Método que valida se o banco tem todos os campos obrigadotorios preenchidos
*
* @param $messages
*
* @return boolean
*/
public function isValid(&$messages)
Expand Down Expand Up @@ -487,7 +493,7 @@ protected function valida(array $a)
throw new \Exception('Classe remessa deve informar o tamanho da linha');
}

$a = array_filter($a, 'strlen');
$a = array_filter($a, 'mb_strlen');
if (count($a) != $this->tamanho_linha) {
throw new \Exception(sprintf('$a não possui %s posições, possui: %s', $this->tamanho_linha, count($a)));
}
Expand Down
10 changes: 5 additions & 5 deletions src/Cnab/Remessa/Cnab240/Banco/Bancoob.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Bancoob extends AbstractRemessa implements RemessaContract
*
* @var null
*/
protected $fimArquivo = "\r\n";
protected $fimArquivo = "\n";

/**
* @param BoletoContract $boleto
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function segmentoP(BoletoContract $boleto)
$this->add(222, 223, Util::formatCnab('9', $boleto->getDiasProtesto(), 2));
$this->add(224, 224, '0');
$this->add(225, 227, '');
$this->add(227, 229, '09');
$this->add(228, 229, '09');
$this->add(230, 239, '0000000000');
$this->add(240, 240, '');

Expand Down Expand Up @@ -186,14 +186,14 @@ public function segmentoQ(BoletoContract $boleto)
$this->add(152, 153, Util::formatCnab('X', $boleto->getPagador()->getUf(), 2));
$this->add(154, 154, '0');
$this->add(155, 169, '000000000000000');
$this->add(170, 209, '');
$this->add(170, 209, Util::formatCnab('X', '', 40));
$this->add(210, 212, '000');
$this->add(213, 240, '');
$this->add(213, 240, Util::formatCnab('X', '', 28));

if($boleto->getSacadorAvalista()) {
$this->add(154, 154, strlen(Util::onlyNumbers($boleto->getSacadorAvalista()->getDocumento())) == 14 ? 2 : 1);
$this->add(155, 169, Util::formatCnab('9', Util::onlyNumbers($boleto->getSacadorAvalista()->getDocumento()), 15));
$this->add(170, 209, Util::formatCnab('X', $boleto->getSacadorAvalista()->getNome(), 30));
$this->add(170, 209, Util::formatCnab('X', $boleto->getSacadorAvalista()->getNome(), 40));
}

return $this;
Expand Down
16 changes: 15 additions & 1 deletion src/Cnab/Remessa/Cnab400/Banco/Bancoob.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public function setConvenio($convenio)
return $this;
}

/**
* @return $this|mixed
* @throws \Exception
*/
protected function header()
{
$this->iniciaHeader();
Expand All @@ -128,7 +132,7 @@ protected function header()
$this->add(2, 2, '1');
$this->add(3, 9, 'REMESSA');
$this->add(10, 11, '01');
$this->add(12, 26, 'COBRANÇA ');
$this->add(12, 26, Util::formatCnab('X', 'COBRANÇA', 15));
$this->add(27, 30, Util::formatCnab('9', $this->getAgencia(), 4));
$this->add(31, 31, CalculoDv::bancoobAgencia($this->getAgencia()));
$this->add(32, 40, Util::formatCnab('9', $this->getConvenio(), 9));
Expand All @@ -144,6 +148,12 @@ protected function header()
return $this;
}

/**
* @param BoletoContract $boleto
*
* @return mixed|void
* @throws \Exception
*/
public function addBoleto(BoletoContract $boleto)
{
$this->boletos[] = $boleto;
Expand Down Expand Up @@ -225,6 +235,10 @@ public function addBoleto(BoletoContract $boleto)
$this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));
}

/**
* @return $this|mixed
* @throws \Exception
*/
protected function trailer()
{
$this->iniciaTrailer();
Expand Down
2 changes: 1 addition & 1 deletion src/Cnab/Remessa/Cnab400/Banco/Sicredi.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function addBoleto(BoletoContract $boleto)
$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(182, 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, '');
Expand Down
2 changes: 1 addition & 1 deletion src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ public static function adiciona(&$line, $i, $f, $value)
}

$value = sprintf("%{$t}s", $value);
$value = preg_split('//u', $value, -1, PREG_SPLIT_NO_EMPTY);
$value = preg_split('//u', $value, -1, PREG_SPLIT_NO_EMPTY) + array_fill(0, $t, '');

return array_splice($line, $i, $t, $value);
}
Expand Down

0 comments on commit f4064be

Please sign in to comment.