Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/org/jrimum/bopepo/BancosSuportados.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ public enum BancosSuportados{
*/
BANCO_VOTORANTIM("655", "59588111004443", "BANCO VOTORANTIM S.A.", "BANCO VOTORANTIM S.A."),

/**
* Tipo enumerado que representa o <strong>BANCO FIBRA S.A.</strong>, código de
* compensação <strong><tt>224</tt></strong> <a
* href="https://bancofibra.com.br/">site</a>.
*
* @since 0.2
*/
BANCO_FIBRA("224", "58616418000108", "BANCO FIBRA S.A.", "BANCO FIBRA S.A."),

/**
* Tipo enumerado que representa o <strong>Banco Sofisa</strong>, código de
* compensação <strong><tt>637</tt></strong> <a
Expand Down Expand Up @@ -421,6 +430,7 @@ public enum BancosSuportados{
suportados.put(ABCBRASIL.codigoDeCompensacaoBACEN, ABCBRASIL);
suportados.put(MONEYPLUS.codigoDeCompensacaoBACEN, MONEYPLUS);
suportados.put(BANCO_VOTORANTIM.codigoDeCompensacaoBACEN, BANCO_VOTORANTIM);
suportados.put(BANCO_FIBRA.codigoDeCompensacaoBACEN, BANCO_FIBRA);
suportados.put(BANCO_SOFISA.codigoDeCompensacaoBACEN, BANCO_SOFISA);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.jrimum.bopepo.campolivre;

import org.jrimum.domkee.financeiro.banco.febraban.Titulo;


abstract class AbstractCLBancoFibra extends AbstractCampoLivre {


private static final long serialVersionUID = 1L;

protected AbstractCLBancoFibra(Integer fieldsLength) {

super(fieldsLength);
}

protected static CampoLivre create(Titulo titulo){

return new CLBancoFibra().build(titulo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ protected static CampoLivre create(Titulo titulo) throws NotSupportedBancoExcept
case ABCBRASIL: return AbstractCLABCBrasil.create(titulo);
case MONEYPLUS: return AbstractCLMoneyPlus.create(titulo);
case BANCO_VOTORANTIM: return AbstractCLBancoVotorantim.create(titulo);
case BANCO_FIBRA: return AbstractCLBancoFibra.create(titulo);
case BANCO_SOFISA: return AbstractCLBancoSofisa.create(titulo);

default:
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/org/jrimum/bopepo/campolivre/CLBancoFibra.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.jrimum.bopepo.campolivre;

import org.jrimum.bopepo.parametro.ParametroBancoFibra;
import org.jrimum.domkee.financeiro.banco.febraban.Titulo;
import org.jrimum.texgit.type.component.Fillers;
import org.jrimum.texgit.type.component.FixedField;

public class CLBancoFibra extends AbstractCLBancoFibra {

private static final long serialVersionUID = -5787328473435278119L;

public static final Integer FIELDS_LENGTH = Integer.valueOf(4);

public static final Integer AGENCIA_LENGTH = Integer.valueOf(4);
public static final Integer CARTEIRA_LENGTH = Integer.valueOf(3);
public static final Integer OPERACAO_LENGTH = Integer.valueOf(7);
public static final Integer NOSSO_NUMERO_COM_DV_LENGTH = Integer.valueOf(11);

protected CLBancoFibra() {
super(FIELDS_LENGTH);
}

@Override
protected void checkValues(Titulo titulo) {
checkAgenciaNotNull(titulo);
checkCodigoDaAgencia(titulo);
checkNossoNumero(titulo);
checkTamanhoDoNossoNumero(titulo, NN10);
checkTamanhoDigitoDoNossoNumero(titulo, 1, "Digito do nosso número deve ir de 0 a 9");
checkParametroBancario(titulo, ParametroBancoFibra.OPERACAO);
checkParametroBancarioMenorOuIgualQue(titulo, ParametroBancoFibra.OPERACAO, 9999999);
}


@Override
protected void addFields(Titulo titulo) {
this.add(new FixedField<Integer>(titulo.getContaBancaria().getAgencia().getCodigo(), AGENCIA_LENGTH, Fillers.ZERO_LEFT));
this.add(new FixedField<Integer>(titulo.getContaBancaria().getCarteira().getCodigo(), CARTEIRA_LENGTH, Fillers.ZERO_LEFT));
this.add(new FixedField<Integer>(titulo.getParametrosBancarios().<Integer>getValor(ParametroBancoFibra.OPERACAO), OPERACAO_LENGTH, Fillers.ZERO_LEFT));
this.add(new FixedField<String>(titulo.getNossoNumero() + titulo.getDigitoDoNossoNumero(), NOSSO_NUMERO_COM_DV_LENGTH, Fillers.ZERO_LEFT));
}
}
35 changes: 35 additions & 0 deletions src/main/java/org/jrimum/bopepo/parametro/ParametroBancoFibra.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2014 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* Created at: 21/01/2014 - 13:57:10
*
* ================================================================================
*
* Direitos autorais 2014 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode
* usar esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob esta
* LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER TIPO, sejam
* expressas ou tácitas. Veja a LICENÇA para a redação específica a reger permissões
* e limitações sob esta LICENÇA.
*
* Criado em: 21/01/2014 - 13:57:10
*
*/
package org.jrimum.bopepo.parametro;
import org.jrimum.domkee.financeiro.banco.ParametroBancario;

public enum ParametroBancoFibra implements ParametroBancario<ParametroBancoFibra> {
OPERACAO;
}
Binary file added src/main/resources/img/224.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/test/java/org/jrimum/bopepo/TestBancosSuportados.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void deve_ter_o_codigos_bacen_igual_o_da_especificacao_febraban() {
assertEquals(BancosSuportados.BANCO_B2S.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(), "218");
assertEquals(BancosSuportados.MONEYPLUS.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(),"274");
assertEquals(BancosSuportados.BANCO_VOTORANTIM.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(),"655");
assertEquals(BancosSuportados.BANCO_FIBRA.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(),"224");
assertEquals(BancosSuportados.BANCO_SOFISA.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(),"637");

}
Expand Down
52 changes: 52 additions & 0 deletions src/test/java/org/jrimum/bopepo/campolivre/TestCLBancoFibra.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.jrimum.bopepo.campolivre;

import org.jrimum.bopepo.BancosSuportados;
import org.jrimum.domkee.financeiro.banco.ParametrosBancariosMap;
import org.jrimum.domkee.financeiro.banco.febraban.Agencia;
import org.jrimum.domkee.financeiro.banco.febraban.Carteira;
import org.jrimum.domkee.financeiro.banco.febraban.NumeroDaConta;
import org.junit.Before;
import org.junit.Test;


public class TestCLBancoFibra extends AbstractCampoLivreBaseTest<CLBancoFibra> {

@Before
public void setUp(){

titulo.getContaBancaria().setBanco(BancosSuportados.BANCO_FIBRA.create());
titulo.getContaBancaria().setAgencia(new Agencia(1234, "1"));
titulo.getContaBancaria().setNumeroDaConta(new NumeroDaConta(6789));
titulo.getContaBancaria().setCarteira(new Carteira(500));
titulo.setNossoNumero("123456789");
titulo.setDigitoDoNossoNumero("1");
titulo.setParametrosBancarios(new ParametrosBancariosMap(org.jrimum.bopepo.parametro.ParametroBancoFibra.OPERACAO, 1234567));

createCampoLivreToTest();

setCampoLivreEsperadoComoString("1234567890500123456789100");
}


@Test(expected = CampoLivreException.class)
public void seNaoPermiteNossoNumeroNulo() {
testeSeNaoPermiteNossoNumeroNulo();
}

@Test(expected = CampoLivreException.class)
public void seNaoPermiteNossoNumeroComBrancos() {
testeSeNaoPermiteNossoNumeroComBrancos(CLBancoFibra.NOSSO_NUMERO_COM_DV_LENGTH);
}

@Test(expected = CampoLivreException.class)
public void seNaoPermiteNossoNumeroComEspacos() {

testeSeNaoPermiteNossoNumeroComEspacos(CLBancoFibra.NOSSO_NUMERO_COM_DV_LENGTH);
}

@Test(expected = CampoLivreException.class)
public void seNaoPermiteNossoNumeroComTamanhoDiferenteDe10() {
testeSeNaoPermiteNossoNumeroComTamanhoDiferenteDoEspecificado(CLBancoFibra.NOSSO_NUMERO_COM_DV_LENGTH - 1);
}

}