Skip to content

Commit

Permalink
imprime boleto
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardokum committed Sep 8, 2023
1 parent 91b8562 commit c441687
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/Boleto/AbstractBoleto.php
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,11 @@ public function isProtestado()
return $this->isSituacao(self::SITUACAO_PROTESTADO);
}

public function imprimeBoleto()
{
return true;
}

/**
* Render PDF
*
Expand Down
4 changes: 1 addition & 3 deletions src/Boleto/Banco/Bnb.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ public function setDiasBaixaAutomatica($baixaAutomatica)
*/
protected function gerarNossoNumero()
{
$numero_boleto = $this->getNumero();

return Util::numberFormatGeral($numero_boleto, 7).CalculoDV::bnbNossoNumero($this->getNumero());
return Util::numberFormatGeral($this->getNumero(), 7).CalculoDV::bnbNossoNumero($this->getNumero());
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/Boleto/Banco/Fibra.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,12 @@ public function getAgenciaCodigoBeneficiario()
{
return sprintf('%s%s / %s%s', $this->getAgencia(), CalculoDV::fibraAgencia($this->getAgencia()), $this->getConta(), CalculoDV::fibraConta($this->getConta()));
}

/**
* @return bool
*/
public function imprimeBoleto()
{
return Util::upper($this->getModalidadeCarteira()) == 'D';
}
}
8 changes: 8 additions & 0 deletions src/Boleto/Banco/Inter.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,12 @@ public function setNossoNumero($nossoNumero)
}
$this->campoNossoNumero = $nnClean;
}

/**
* @return bool
*/
public function imprimeBoleto()
{
return $this->campoNossoNumero > 0;
}
}
8 changes: 8 additions & 0 deletions src/Boleto/Banco/Ourinvest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,12 @@ public function getAgenciaCodigoBeneficiario()
{
return sprintf('%04s-%s / %07s-%s', $this->getAgencia(), CalculoDV::ourinvestAgencia($this->getAgencia()), $this->getConta(), CalculoDV::ourinvestConta($this->getConta()));
}

/**
* @return bool
*/
public function imprimeBoleto()
{
return $this->isEmissaoPropria();
}
}
9 changes: 9 additions & 0 deletions src/Boleto/Banco/Pine.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,13 @@ public function getAgenciaCodigoBeneficiario()
{
return sprintf('%s%s / %s%s', $this->getAgencia(), CalculoDV::pineAgencia($this->getAgencia()), $this->getConta(), CalculoDV::pineConta($this->getConta()));
}

/**
* @return bool
*/
public function imprimeBoleto()
{
return Util::upper($this->getModalidadeCarteira()) == 'D';
}

}
10 changes: 9 additions & 1 deletion src/Boleto/Banco/Rendimento.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function setModalidadeCarteira($modalidadeCarteira)
protected function gerarNossoNumero()
{
$nn = 0;
if ($this->getModalidadeCarteira() == '6') {
if ($this->getModalidadeCarteira() == 6) {
$nn = ((int) $this->getRange()) + ((int) $this->getNumero());
$nn .= CalculoDV::rendimentoNossoNumero($this->getAgencia(), $this->getCarteira(), $nn);
}
Expand Down Expand Up @@ -212,4 +212,12 @@ public function getAgenciaCodigoBeneficiario()
{
return sprintf('%s / %s', $this->getAgencia(), $this->getCodigoCliente());
}

/**
* @return bool
*/
public function imprimeBoleto()
{
return $this->getModalidadeCarteira() == 6;
}
}
6 changes: 2 additions & 4 deletions src/Boleto/Banco/Santander.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ public function setDiasBaixaAutomatica($baixaAutomatica)
*/
protected function gerarNossoNumero()
{
$numero_boleto = $this->getNumero();

return Util::numberFormatGeral($numero_boleto, 12)
.CalculoDV::santanderNossoNumero($numero_boleto);
return Util::numberFormatGeral($this->getNumero(), 12)
.CalculoDV::santanderNossoNumero($this->getNumero());
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Boleto/Render/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public function addBoletos(array $boletos)
*/
public function addBoleto(BoletoContract $boleto)
{
if (!$boleto->imprimeBoleto()) {
throw new \Exception('Boleto com modalidade/carteira não disponível para impressão');
}
$dados = $boleto->toArray();
$dados['codigo_barras'] = $this->getImagemCodigoDeBarras($dados['codigo_barras']);
$this->boleto[] = $dados;
Expand Down
3 changes: 3 additions & 0 deletions src/Boleto/Render/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ public function addBoletos(array $boletos, $withGroup = true)
*/
public function addBoleto(BoletoContract $boleto)
{
if (!$boleto->imprimeBoleto()) {
throw new \Exception('Boleto com modalidade/carteira não disponível para impressão');
}
$this->totalBoletos += 1;
$this->boleto[] = $boleto;

Expand Down
3 changes: 3 additions & 0 deletions src/Boleto/Render/PdfCaixa.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ public function addBoletos(array $boletos, $withGroup = true)
*/
public function addBoleto(BoletoContract $boleto)
{
if (!$boleto->imprimeBoleto()) {
throw new \Exception('Boleto com modalidade/carteira não disponível para impressão');
}
$this->totalBoletos += 1;
$this->boleto[] = $boleto;

Expand Down
5 changes: 5 additions & 0 deletions src/Contracts/Boleto/Boleto.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,9 @@ public static function parseCampoLivre($campoLivre);
* @return mixed
*/
public function getMostrarEnderecoFichaCompensacao();

/**
* @return bool
*/
public function imprimeBoleto();
}

0 comments on commit c441687

Please sign in to comment.