Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/main/java/org/jrimum/bopepo/BancosSuportados.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ public enum BancosSuportados {
* @since 0.2
*/
BANCO_DAYCOVAL("707", "62232889000190", "BANCO DAYCOVAL S.A.", "Banco Múltiplo"),
/**
* Tipo enumerado que representa o <strong>Banco Sofisa</strong>, código de
* compensação <strong>637</strong> <a
* href="https://www.sofisa.com.br/">site</a>.
*
* @since 0.2
*/
BANCO_SOFISA("637", "60889128000180", "BANCO SOFISA S.A.", "Banco Múltiplo"),
/**
* Tipo enumerado que representa o <strong>Bancoob</strong>, código de
* compensação <strong>756</strong> <a
Expand Down Expand Up @@ -336,6 +344,7 @@ public enum BancosSuportados {
suportados.put(CECRED.codigoDeCompensacaoBACEN, CECRED);
suportados.put(UNICRED.codigoDeCompensacaoBACEN, UNICRED);
suportados.put(BANCO_DAYCOVAL.codigoDeCompensacaoBACEN, BANCO_DAYCOVAL);
suportados.put(BANCO_SOFISA.codigoDeCompensacaoBACEN, BANCO_SOFISA);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2010 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.
*
* ================================================================================
*
* Direitos autorais 2008 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.
*
*/

package org.jrimum.bopepo.campolivre;

import org.jrimum.domkee.banco.Titulo;

/**
* <p>
* Interface comum para todos os campos livres do Banco Sofisa que venham a
* existir.
* </p>
*
* @author <a href="https://github.com/lucassolerne">Lucas Solerne</a>
*
* @since 0.1
*
* @version 0.1
*/
abstract class AbstractCLBancoSofisa extends AbstractCampoLivre {

/**
* <p>
* Cria um campo livre com um determinado número de campos
* </p>
*
* @see AbstractCampoLivre
*
* @param fieldsLength - Número de campos
*/
protected AbstractCLBancoSofisa(Integer fieldsLength) {

super(fieldsLength);
}

protected static CampoLivre create(Titulo titulo) {

return new CLBancoSofisa().build(titulo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ protected static CampoLivre create(Titulo titulo) throws NotSupportedBancoExcept
return AbstractCLUnicred.create(titulo);
case BANCO_DAYCOVAL:
return AbstractCLBancoDaycoval.create(titulo);
case BANCO_SOFISA:
return AbstractCLBancoSofisa.create(titulo);

default:
/*
Expand Down
145 changes: 145 additions & 0 deletions src/main/java/org/jrimum/bopepo/campolivre/CLBancoSofisa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright 2010 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.
*
* ================================================================================
*
* Direitos autorais 2008 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.
*
*/

package org.jrimum.bopepo.campolivre;

import org.jrimum.bopepo.parametro.ParametroBancoSofisa;
import org.jrimum.domkee.banco.Titulo;
import org.jrimum.texgit.Fillers;
import org.jrimum.texgit.FixedField;

/**
* O campo livre do Banco Sofisa deve seguir esta forma:
*
* <table border="1" cellpadding="0" cellspacing="0" style="border-collapse:
* collapse" bordercolor="#111111" width="60%" id="campolivre">
* <tr>
* <thead>
* <th>Posição</th>
* <th>Tamanho</th>
* <th>Conteúdo</th>
* </thead>
* </tr>
* <tr>
* <td>20-23</td>
* <td>4</td>
* <td>Código da agência (sem dígito)</td>
* </tr>
* <tr>
* <td>24-26</td>
* <td>3</td>
* <td>Carteira</td>
* </tr>
* <tr>
* <td>27-33</td>
* <td>7</td>
* <td>Número da Operação fornecido pelo banco</td>
* </tr>
* <tr>
* <td>34-43</td>
* <td>10</td>
* <td>Nosso Número (sequencial)</td>
* </tr>
* <tr>
* <td>44-44</td>
* <td>1</td>
* <td>DV do Nosso Número (módulo 10)</td>
* </tr>
* </table>
*
* @author <a href="https://github.com/lucassolerne">Lucas Solerne</a>
*
* @since 0.2
*
* @version 0.2
*/
class CLBancoSofisa extends AbstractCLBancoSofisa {

/**
*
*/
private static final long serialVersionUID = 5142877624309178291L;

/**
* Número de campos = 4.
*/
private static final Integer FIELDS_LENGTH = 4;

/**
* Tamanho do campo Agência = 4.
*/
private static final Integer AGENCIA_LENGTH = Integer.valueOf(4);

/**
* Tamanho do campo Carteira = 3.
*/
private static final Integer CARTEIRA_LENGTH = Integer.valueOf(3);

/**
* Tamanho do campo Operação = 7.
*/
private static final Integer OPERACAO_LENGTH = Integer.valueOf(7);

/**
* Tamanho do campo Nosso Número + DV = 11.
*/
private static final Integer NOSSO_NUMERO_LENGTH = Integer.valueOf(11);

/**
* Cria um campo livre instanciando o número de fields ({@code FIELDS_LENGTH}) deste campo.
*
* @since 0.2
*/
protected CLBancoSofisa() {
super(FIELDS_LENGTH);
}

@Override
protected void addFields(Titulo titulo) {
StringBuilder nossoNumero = new StringBuilder(titulo.getNossoNumero());
nossoNumero.append(titulo.getDigitoDoNossoNumero());

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(ParametroBancoSofisa.OPERACAO), OPERACAO_LENGTH, Fillers.ZERO_LEFT));
this.add(new FixedField<String>(nossoNumero.toString(), NOSSO_NUMERO_LENGTH, Fillers.ZERO_LEFT));
}

@Override
protected void checkValues(Titulo titulo) {
checkAgenciaNotNull(titulo);
checkCodigoDaAgencia(titulo);
checkCodigoDaAgenciaMenorOuIgualQue(titulo, 9999);
checkCarteiraNotNull(titulo);
checkCodigoDaCarteira(titulo);
checkCodigoDaCarteiraMenorOuIgualQue(titulo, 999);
checkParametroBancario(titulo, ParametroBancoSofisa.OPERACAO);
checkParametroBancarioMenorOuIgualQue(titulo, ParametroBancoSofisa.OPERACAO, 9999999);
checkNossoNumero(titulo);
checkTamanhoDoNossoNumero(titulo, NN10);
checkDigitoDoNossoNumero(titulo);
checkTamanhoDigitoDoNossoNumero(titulo, 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2013 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.
*
* ================================================================================
*
* Direitos autorais 2013 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.
*
*/

package org.jrimum.bopepo.parametro;

import org.jrimum.bopepo.BancosSuportados;
import org.jrimum.domkee.banco.ParametroBancario;

/**
* Parâmetros bancários específicos para o
* {@link BancosSuportados#BANCO_SOFISA}.
*
* @author <a href="https://github.com/lucassolerne">Lucas Solerne</a>
*
* @version 0.2.3
*
* @since 0.2
*/
public enum ParametroBancoSofisa implements ParametroBancario<ParametroBancoSofisa> {
/**
* Nome do parâmetro bancário contendo o valor do número de operação da conta.
*/
OPERACAO;
}
Binary file added src/main/resources/img/637.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 @@ -76,5 +76,6 @@ public void deve_ter_o_codigos_bacen_igual_o_da_especificacao_febraban() {
assertEquals(BancosSuportados.CITIBANK.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(), "745");
assertEquals(BancosSuportados.BANCO_DE_BRASILIA.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(), "070");
assertEquals(BancosSuportados.BANCO_DAYCOVAL.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(), "707");
assertEquals(BancosSuportados.BANCO_SOFISA.create().getCodigoDeCompensacaoBACEN().getCodigoFormatado(), "637");
}
}
38 changes: 38 additions & 0 deletions src/test/java/org/jrimum/bopepo/campolivre/TestCLBancoSofisa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.jrimum.bopepo.campolivre;

import org.jrimum.bopepo.BancosSuportados;
import org.jrimum.bopepo.parametro.ParametroBancoSofisa;
import org.jrimum.domkee.banco.Agencia;
import org.jrimum.domkee.banco.Carteira;
import org.jrimum.domkee.banco.NumeroDaConta;
import org.jrimum.domkee.banco.ParametrosBancariosMap;
import org.junit.Before;

/**
* <p>
* Teste unitário do campo livre do Banco Sofisa.
* </p>
*
* @author <a href="https://github.com/lucassolerne">Lucas Solerne</a>
*
*/
public class TestCLBancoSofisa extends AbstractCampoLivreBaseTest<CLBancoSofisa> {

@Before
public void setUp() {

titulo.getContaBancaria().setBanco(BancosSuportados.BANCO_SOFISA.create());
titulo.getContaBancaria().setAgencia(new Agencia(0004, "3"));
titulo.getContaBancaria().setNumeroDaConta(new NumeroDaConta(1234567));
titulo.getContaBancaria().setCarteira(new Carteira(121));
titulo.setParametrosBancarios(new ParametrosBancariosMap(ParametroBancoSofisa.OPERACAO, 1234567));
titulo.setNossoNumero("1234567890");
titulo.setDigitoDoNossoNumero("0");

createCampoLivreToTest();

// campo livre = agência(4) + carteira(3) + operação(7) + nosso número + DV(11)
// = 0004 + 121 + 1234567 + 12345678900 = 25 dígitos
setCampoLivreEsperadoComoString("0004121123456712345678900");
}
}