From 2f0cc26fa088d8eb35af0527879a9feb7616d703 Mon Sep 17 00:00:00 2001 From: fabiorj Date: Sat, 4 Dec 2021 12:15:56 -0300 Subject: [PATCH] commit inicial --- jrimum-domkee/.gitignore | 6 + jrimum-domkee/CHANGELOG.md | 5 + jrimum-domkee/LICENSE | 191 +++++ jrimum-domkee/README.md | 6 + jrimum-domkee/pom.xml | 207 +++++ .../jrimum-domkee-with-dependencies.xml | 22 + .../jrimum/domkee/comum/pessoa/Pessoa.java | 85 ++ .../domkee/comum/pessoa/PessoaFisica.java | 64 ++ .../domkee/comum/pessoa/PessoaJuridica.java | 59 ++ .../domkee/comum/pessoa/contato/Email.java | 73 ++ .../pessoa/contato/NumeroDeTelefone.java | 107 +++ .../comum/pessoa/contato/package-info.java | 33 + .../domkee/comum/pessoa/endereco/CEP.java | 110 +++ .../comum/pessoa/endereco/Endereco.java | 176 ++++ .../pessoa/endereco/UnidadeFederativa.java | 139 ++++ .../comum/pessoa/endereco/package-info.java | 33 + .../org/jrimum/domkee/comum/pessoa/id/RG.java | 121 +++ .../comum/pessoa/id/cprf/AbstractCPRF.java | 330 ++++++++ .../domkee/comum/pessoa/id/cprf/CNPJ.java | 202 +++++ .../comum/pessoa/id/cprf/CNPJException.java | 91 ++ .../domkee/comum/pessoa/id/cprf/CPF.java | 165 ++++ .../comum/pessoa/id/cprf/CPFException.java | 91 ++ .../domkee/comum/pessoa/id/cprf/CPRF.java | 59 ++ .../comum/pessoa/id/cprf/package-info.java | 33 + .../domkee/comum/pessoa/id/package-info.java | 33 + .../domkee/comum/pessoa/package-info.java | 33 + .../domkee/financeiro/banco/Agencia.java | 63 ++ .../jrimum/domkee/financeiro/banco/Banco.java | 135 +++ .../financeiro/banco/ParametroBancario.java | 44 + .../banco/ParametrosBancariosMap.java | 364 ++++++++ .../domkee/financeiro/banco/Pessoa.java | 320 +++++++ .../domkee/financeiro/banco/PessoaFisica.java | 104 +++ .../financeiro/banco/PessoaJuridica.java | 99 +++ .../financeiro/banco/febraban/Agencia.java | 119 +++ .../financeiro/banco/febraban/Banco.java | 444 ++++++++++ .../financeiro/banco/febraban/Carteira.java | 194 +++++ .../financeiro/banco/febraban/Cedente.java | 61 ++ .../febraban/CodigoDeCompensacaoBACEN.java | 130 +++ .../banco/febraban/ContaBancaria.java | 200 +++++ .../banco/febraban/EntidadeDeCobranca.java | 195 +++++ .../financeiro/banco/febraban/Modalidade.java | 102 +++ .../banco/febraban/NumeroDaConta.java | 94 +++ .../financeiro/banco/febraban/Sacado.java | 63 ++ .../banco/febraban/SacadorAvalista.java | 62 ++ .../banco/febraban/TipoDeCobranca.java | 66 ++ .../banco/febraban/TipoDeMoeda.java | 100 +++ .../banco/febraban/TipoDeTitulo.java | 228 +++++ .../financeiro/banco/febraban/Titulo.java | 779 ++++++++++++++++++ .../banco/febraban/package-info.java | 33 + .../banco/hsbc/TipoIdentificadorCNR.java | 132 +++ .../financeiro/banco/hsbc/package-info.java | 33 + .../domkee/financeiro/banco/package-info.java | 33 + .../pessoa/id/cprf/TestAbstractCPRF.java | 346 ++++++++ .../domkee/comum/pessoa/id/cprf/TestCNPJ.java | 159 ++++ .../domkee/comum/pessoa/id/cprf/TestCPF.java | 112 +++ .../banco/ParametrosBancariosMapTest.java | 369 +++++++++ .../banco/febraban/TestAgencia.java | 81 ++ .../financeiro/banco/febraban/TestBanco.java | 58 ++ .../banco/febraban/TestTipoDeTitulo.java | 66 ++ 59 files changed, 7862 insertions(+) create mode 100644 jrimum-domkee/.gitignore create mode 100644 jrimum-domkee/CHANGELOG.md create mode 100644 jrimum-domkee/LICENSE create mode 100644 jrimum-domkee/README.md create mode 100644 jrimum-domkee/pom.xml create mode 100644 jrimum-domkee/src/main/assembly/jrimum-domkee-with-dependencies.xml create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/Pessoa.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaFisica.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaJuridica.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/Email.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/NumeroDeTelefone.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/package-info.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/CEP.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/Endereco.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/UnidadeFederativa.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/package-info.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/RG.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/AbstractCPRF.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJ.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJException.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPF.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPFException.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPRF.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/package-info.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/package-info.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/package-info.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Agencia.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Banco.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametroBancario.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMap.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Pessoa.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaFisica.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaJuridica.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Agencia.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Banco.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Carteira.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Cedente.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/CodigoDeCompensacaoBACEN.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/ContaBancaria.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/EntidadeDeCobranca.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Modalidade.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/NumeroDaConta.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Sacado.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/SacadorAvalista.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeCobranca.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeMoeda.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeTitulo.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Titulo.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/package-info.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/TipoIdentificadorCNR.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/package-info.java create mode 100644 jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/package-info.java create mode 100644 jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestAbstractCPRF.java create mode 100644 jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCNPJ.java create mode 100644 jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCPF.java create mode 100644 jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMapTest.java create mode 100644 jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestAgencia.java create mode 100644 jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestBanco.java create mode 100644 jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestTipoDeTitulo.java diff --git a/jrimum-domkee/.gitignore b/jrimum-domkee/.gitignore new file mode 100644 index 0000000..700e479 --- /dev/null +++ b/jrimum-domkee/.gitignore @@ -0,0 +1,6 @@ +/bin +/target +.classpath +.DS_Store +.project +.settings \ No newline at end of file diff --git a/jrimum-domkee/CHANGELOG.md b/jrimum-domkee/CHANGELOG.md new file mode 100644 index 0000000..5c362b2 --- /dev/null +++ b/jrimum-domkee/CHANGELOG.md @@ -0,0 +1,5 @@ +Domkee Changelog +============================= + +0.2.3 (2014/02/01) suport bopepo-0.2.3 +--------------------------------------- \ No newline at end of file diff --git a/jrimum-domkee/LICENSE b/jrimum-domkee/LICENSE new file mode 100644 index 0000000..37ec93a --- /dev/null +++ b/jrimum-domkee/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/jrimum-domkee/README.md b/jrimum-domkee/README.md new file mode 100644 index 0000000..8040335 --- /dev/null +++ b/jrimum-domkee/README.md @@ -0,0 +1,6 @@ +Domkee +====== + +[![Build Status](https://ci-jrimum.rhcloud.com/buildStatus/icon?job=Domkee)](https://ci-jrimum.rhcloud.com) + +Objetos de domínio usados no projeto [Lançado embutido, incubado] diff --git a/jrimum-domkee/pom.xml b/jrimum-domkee/pom.xml new file mode 100644 index 0000000..4369328 --- /dev/null +++ b/jrimum-domkee/pom.xml @@ -0,0 +1,207 @@ + + + 4.0.0 + br.com.rjconsultores + jrimum-domkee + jar + Projeto Domkee + 1.0.0 + Projeto open source de componentes de software para o domínio de negócios do Brasil. + http://www.jrimum.org/domkee + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + Projeto JRimum + http://www.jrimum.org + + + + GitHub + http://github.com/jrimum/domkee/issues + + + + http://github.com/jrimum/domkee + + + + + Gilmar P. S. L. + gilmatryx@gmail.com + + + Misael Barreto + misaelbarreto@gmail.com + + + Rômulo Augusto + romulomail@gmail.com + + + + + UTF-8 + UTF-8 + + + + + disable-java8-doclint + + [1.8,) + + + -Xdoclint:none + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.5 + 1.5 + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + 1.6 + + + org.codehaus.mojo.signature + java15 + 1.0 + + + + + animal-sniffer + compile + + check + + + + + + maven-assembly-plugin + 2.4 + + + src/main/assembly/jrimum-domkee-with-dependencies.xml + + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + false + + org/jrimum/domkee/**/* + + + org/jrimum/domkee/excludes/**/* + org/jrimum/domkee/**/*$* + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + package + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadoc + package + + jar + + + + + UTF-8 + UTF-8 + true + private + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.1 + + + + + + + br.com.rjconsultores + jrimum-vallia + 1.0.0 + + + + junit + junit + 4.11 + test + + + com.google.guava + guava-jdk5 + 14.0.1 + test + + + org.hamcrest + hamcrest-all + 1.3 + test + + + + + + rj-releases + http://52.5.53.15:8081/nexus/content/repositories/releases/ + + + \ No newline at end of file diff --git a/jrimum-domkee/src/main/assembly/jrimum-domkee-with-dependencies.xml b/jrimum-domkee/src/main/assembly/jrimum-domkee-with-dependencies.xml new file mode 100644 index 0000000..76b72ff --- /dev/null +++ b/jrimum-domkee/src/main/assembly/jrimum-domkee-with-dependencies.xml @@ -0,0 +1,22 @@ + + dep + + jar + + false + + + / + true + true + runtime + + commons-lang:commons-lang + log4j:log4j + + + + \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/Pessoa.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/Pessoa.java new file mode 100644 index 0000000..0bd6777 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/Pessoa.java @@ -0,0 +1,85 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:59:24 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:59:24 + * + */ + + +package org.jrimum.domkee.comum.pessoa; + +import java.util.Collection; + +import org.jrimum.domkee.comum.pessoa.contato.NumeroDeTelefone; +import org.jrimum.domkee.comum.pessoa.endereco.Endereco; +import org.jrimum.domkee.comum.pessoa.id.cprf.CPRF; +import org.jrimum.domkee.financeiro.banco.febraban.ContaBancaria; + + +/** + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @see org.jrimum.domkee.financeiro.banco.Pessoa + * + * @since 0.2 + * + * @version 0.2 + */ +public interface Pessoa{ + + public String getNome(); + + public void setNome(String nome); + + public CPRF getCPRF(); + + public void setCPRF(CPRF cprf); + + public Collection getTelefones(); + + public void setTelefones(Collection telefones); + + public void addTelefone(NumeroDeTelefone telefone); + + public Collection getEnderecos(); + + public void setEnderecos(Collection enderecos); + + public void addEndereco(Endereco endereco); + + public Collection getContasBancarias(); + + public void setContasBancarias(Collection contasBancarias); + + public void addContaBancaria(ContaBancaria contaBancaria); + + public boolean isFisica(); + + public boolean isJuridica(); + + public boolean hasContaBancaria(); +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaFisica.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaFisica.java new file mode 100644 index 0000000..06c149f --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaFisica.java @@ -0,0 +1,64 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:59:31 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:59:31 + * + */ + + +package org.jrimum.domkee.comum.pessoa; + +import java.util.Collection; + +import org.jrimum.domkee.comum.pessoa.id.RG; + + + +/** + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @see org.jrimum.domkee.financeiro.banco.PessoaFisica + * + * @since 0.2 + * + * @version 0.2 + */ +public interface PessoaFisica extends Pessoa { + + public PessoaFisica getConjuge(); + + public void setConjuge(PessoaFisica conjuge); + + public String getEstadoCivil(); + + public void setEstadoCivil(String estadoCivil); + + public Collection getRgs(); + + public void setRgs(Collection rgs); +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaJuridica.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaJuridica.java new file mode 100644 index 0000000..c626c04 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/PessoaJuridica.java @@ -0,0 +1,59 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:59:41 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:59:41 + * + */ + + +package org.jrimum.domkee.comum.pessoa; + + +/** + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @see org.jrimum.domkee.financeiro.banco.PessoaJuridica + * + * @since 0.2 + * + * @version 0.2 + */ +public interface PessoaJuridica extends Pessoa { + + public String getNomeFantasia(); + + public void setNomeFantasia(String nomeFantasia); + + public Long getInscricaoEstadual(); + + public void setInscricaoEstadual(Long inscricaoEstadual); + + public Long getInscricaoMunicipal(); + + public void setInscricaoMunicipal(Long inscricaoMunicipal); +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/Email.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/Email.java new file mode 100644 index 0000000..f4a5af2 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/Email.java @@ -0,0 +1,73 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:07:30 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:07:30 + * + */ + + +package org.jrimum.domkee.comum.pessoa.contato; + +import org.jrimum.utilix.Objects; + + +/** + * + *

+ * Representação básica de um e-mail. + *

+ * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public class Email { + + private String email; + + public Email() {} + + public Email(String email) { + this.email = email; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/NumeroDeTelefone.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/NumeroDeTelefone.java new file mode 100644 index 0000000..306169d --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/NumeroDeTelefone.java @@ -0,0 +1,107 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:10:26 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:10:26 + * + */ + +package org.jrimum.domkee.comum.pessoa.contato; + +import org.jrimum.utilix.Objects; + +/** + * + *

+ * Representação particio + *

+ * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public class NumeroDeTelefone{ + + private int ddi; + + private int ddd; + + private int prefixo; + + private int sufixo; + + private String telefone; + + public NumeroDeTelefone() {} + + public int getDDI() { + return ddi; + } + + public void setDDI(int ddi) { + this.ddi = ddi; + } + + public int getDDD() { + return ddd; + } + + public void setDDD(int ddd) { + this.ddd = ddd; + } + + public int getPrefixo() { + return prefixo; + } + + public void setPrefixo(int prefixo) { + this.prefixo = prefixo; + } + + public int getSufixo() { + return sufixo; + } + + public void setSufixo(int sufixo) { + this.sufixo = sufixo; + } + + public String getTelefone() { + return telefone; + } + + public void setTelefone(String telefone) { + this.telefone = telefone; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/package-info.java new file mode 100644 index 0000000..55b48fc --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/contato/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.comum.pessoa.contato; \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/CEP.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/CEP.java new file mode 100644 index 0000000..31bf0da --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/CEP.java @@ -0,0 +1,110 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:07:05 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:07:05 + * + */ + + +package org.jrimum.domkee.comum.pessoa.endereco; + +import org.jrimum.utilix.Objects; + + +/** + * + *

+ * Representação básica de um CEP. + *

+ * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public class CEP { + + /** + * Primeiros cinco dígitos. + * Exemplo: Para o CEP 59.020-300 o prefixo é o 59020. + */ + private Integer prefixo; + + /** + * Últimos dois dígitos. + * Exemplo: Para o CEP 59.020-300 o sufixo é o 300. + */ + private Integer sufixo; + + /** + * CEP completo (prefixo+sufixo). + * Exemplo: Para o CEP 59.020-300 o cep pode ser: + *
    + *
  • 59.020-300
  • + *
  • 59020300
  • + *
+ */ + private String cep; + + public CEP() {} + + public CEP(String cep) { + + this.cep = cep; + } + + public Integer getPrefixo() { + return prefixo; + } + + public void setPrefixo(Integer prefixo) { + this.prefixo = prefixo; + } + + public Integer getSufixo() { + return sufixo; + } + + public void setSufixo(Integer sufixo) { + this.sufixo = sufixo; + } + + public String getCep() { + return cep; + } + + public void setCep(String cep) { + this.cep = cep; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/Endereco.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/Endereco.java new file mode 100644 index 0000000..140dd9a --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/Endereco.java @@ -0,0 +1,176 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:07:43 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:07:43 + * + */ + + +package org.jrimum.domkee.comum.pessoa.endereco; + +import org.jrimum.utilix.Objects; + + +/** + *

+ * Entidade que encapsula dados do endereço de uma pessoa, como também + * facilidades na manipulação dos seus atributos. + *

+ * + * @author Gilmar P.S.L + * @author Misael Barreto + * @author Rômulo Augusto + * @author Nordeste Fomento Mercantil + * @author Samuel Valério + * + * @since 0.2 + * @version 0.2 + */ +public class Endereco { + + /** + * Nome da rua, avenida, etc. + */ + private String logradouro; + + /** + * Número que identifica o lugar no logradouro (ex: número da casa). + */ + private String numero; + + /** + * Informação adicional para identificar o estabelecimento na rua. + */ + private String complemento; + + /** + * Cada uma das divisões de uma cidade ou povoação. + */ + private String bairro; + + /** + * Cidade, município, etc. + */ + private String localidade; + + /** + * @see CEP + */ + private CEP cep; + + /** + * @see UnidadeFederativa + */ + private UnidadeFederativa uf; + + private String pais; + + public Endereco() {} + + public String getBairro() { + return bairro; + } + + public void setBairro(String bairro) { + this.bairro = bairro; + } + + /** + * @return the localidade + */ + public String getLocalidade() { + return localidade; + } + + /** + * @param localidade the localidade to set + */ + public void setLocalidade(String localidade) { + this.localidade = localidade; + } + + public String getLogradouro() { + return logradouro; + } + + public void setLogradouro(String logradouro) { + this.logradouro = logradouro; + } + + public String getNumero() { + return numero; + } + + public void setNumero(String numero) { + this.numero = numero; + } + + public UnidadeFederativa getUF() { + return uf; + } + + public void setUF(UnidadeFederativa uf) { + this.uf = uf; + } + + public String getComplemento() { + return complemento; + } + + public void setComplemento(String complemento) { + this.complemento = complemento; + } + + public CEP getCEP() { + return cep; + } + + public void setCep(CEP cep) { + this.cep = cep; + } + + public void setCep(String cep) { + setCep(new CEP(cep)); + } + + /** + * @return the pais + */ + public String getPais() { + return pais; + } + + /** + * @param pais the pais to set + */ + public void setPais(String pais) { + this.pais = pais; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/UnidadeFederativa.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/UnidadeFederativa.java new file mode 100644 index 0000000..0b035a7 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/UnidadeFederativa.java @@ -0,0 +1,139 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:09:23 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:09:23 + * + */ + + +package org.jrimum.domkee.comum.pessoa.endereco; + +import static java.lang.String.format; + +import org.jrimum.utilix.text.Strings; + + +/** + *

+ * Enumera as unidades federativas do Brasil. + *

+ * + * @author Gilmar P.S.L + * @author Misael Barreto + * @author Rômulo Augusto + * @author Nordeste Fomento Mercantil + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public enum UnidadeFederativa { + + AM("Amazonas","AM","Manaus"), + PA("Pará","PA","Belém"), + MT("Mato Grosso","MT","Cuiabá"), + MG("Minas Gerais","MG","Belo Horizonte"), + BA("Bahia","BA","Salvador"), + MS("Mato Grosso do Sul","MS","Campo Grande"), + GO("Goiás","GO","Goiânia"), + MA("Maranhão","MA","São Luís"), + RS("Rio Grande do Sul","RS","Porto Alegre"), + TO("Tocantins","TO","Palmas"), + PI("Piauí","PI","Teresina"), + SP("São Paulo","SP","São Paulo"), + RO("Rondônia","RO","Porto Velho"), + RR("Roraima","RR","Boa Vista"), + PR("Paraná","PR","Curitiba"), + AC("Acre","AC","Rio Branco"), + CE("Ceará","CE","Fortaleza"), + AP("Amapá","AP","Macapá"), + PE("Pernambuco","PE","Recife"), + SC("Santa Catarina","SC","Florianópolis"), + PB("Paraíba","PB","João Pessoa"), + RN("Rio Grande do Norte","RN","Natal"), + ES("Espírito Santo","ES","Vitória"), + RJ("Rio de Janeiro","RJ","Rio de Janeiro"), + AL("Alagoas","AL","Maceió"), + SE("Sergipe","SE","Aracaju"), + DF("Distrito Federal","DF","Brasília"), + DESCONHECIDO("","",""); + + private String nome; + + private String sigla; + + private String capital; + + UnidadeFederativa(String nome,String sigla,String capital){ + this.nome = nome; + this.sigla = sigla; + this.capital = capital; + } + + /** + * @return the nome + */ + public String getNome() { + return nome; + } + + /** + * @return the sigla + */ + public String getSigla() { + return sigla; + } + + /** + * @return the capital + */ + public String getCapital() { + return capital; + } + + /** + *

+ * Retorna uma instância que corresponde com a sigla informada, ao contrário + * do método {@link UnidadeFederativa#valueOf(String)}, este não diferencia + * maiúsculas de minúsculas. Caso não exista um tipo associado a sigla ou + * seja informada uma string vazia, uma {@code IllegalArgumentException} + * será lançada. + *

+ * + * @param sigla + * - Sigla correspondente a um estado + * @return UnidadeFederativa + * + * @since 0.2 + */ + public static UnidadeFederativa valueOfSigla(String sigla) { + + Strings.checkNotBlank(sigla, format( + "Não existe Unidade Federativa com sigla vazia \"%s\"", sigla)); + + return valueOf(sigla.toUpperCase()); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/package-info.java new file mode 100644 index 0000000..2688571 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/endereco/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.comum.pessoa.endereco; \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/RG.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/RG.java new file mode 100644 index 0000000..99461eb --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/RG.java @@ -0,0 +1,121 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:10:19 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:10:19 + * + */ + + +package org.jrimum.domkee.comum.pessoa.id; + +import java.util.Date; + +import org.jrimum.domkee.financeiro.banco.PessoaFisica; +import org.jrimum.utilix.Objects; + + + +/** + * + *

+ * Representação básica de um Registro Geral (RG). + *

+ * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public class RG{ + + private long numero; + + private String orgaoExpedidor; + + private String filiacaoPai; + + private String filiacaoMae; + + private Date dataNascimento; + + private PessoaFisica pessoa; + + public long getNumero() { + return numero; + } + + public void setNumero(long numero) { + this.numero = numero; + } + + public String getOrgaoExpedidor() { + return orgaoExpedidor; + } + + public void setOrgaoExpedidor(String orgaoExpedidor) { + this.orgaoExpedidor = orgaoExpedidor; + } + + public String getFiliacaoPai() { + return filiacaoPai; + } + + public void setFiliacaoPai(String filiacaoPai) { + this.filiacaoPai = filiacaoPai; + } + + public String getFiliacaoMae() { + return filiacaoMae; + } + + public void setFiliacaoMae(String filiacaoMae) { + this.filiacaoMae = filiacaoMae; + } + + public Date getDataNascimento() { + return dataNascimento; + } + + public void setDataNascimento(Date dataNascimento) { + this.dataNascimento = dataNascimento; + } + + public PessoaFisica getPessoa() { + return pessoa; + } + + public void setPessoa(PessoaFisica pessoa) { + this.pessoa = pessoa; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/AbstractCPRF.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/AbstractCPRF.java new file mode 100644 index 0000000..94359d0 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/AbstractCPRF.java @@ -0,0 +1,330 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:03:20 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:03:20 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + +import static org.apache.commons.lang.StringUtils.EMPTY; +import static org.jrimum.utilix.text.Strings.fillWithZeroLeft; + +import org.jrimum.utilix.Exceptions; +import org.jrimum.vallia.AbstractCPRFValidator; +import org.jrimum.vallia.AbstractCPRFValidator.TipoDeCPRF; + + + +/** + * + *

+ * Classe que representa um Cadastro de Pessoas na Receita Federal, esse + * cadastro pode ser o de pessoas físicas ou jurídicas. + *

+ * + *

+ * O cadastro tem a finalidade de identificadar cada pessoa no país, seja ela de natureza física + * ou jurídica. O Cadastro de Pessoa Física é o CPF, já o de Pessoa Jurídica é o CNPJ. + *

+ * + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ + +public abstract class AbstractCPRF implements CPRF{ + + /** + * + */ + private String codigoFormatado; + + /** + * + */ + private Long codigo; + + /** + * + */ + protected AbstractCPRFValidator autenticadorCP; + + /** + * Cria um {@linkplain CPRF} através de um long e seu + * {@linkplain TipoDeCPRF}. + * + * @param cadastroDePessoa + * @param tipoDeCadastro + * @return AbstractCPRF (CPF ou CNPJ) + * @throws IllegalArgumentException + */ + @SuppressWarnings("unchecked") + public static C create(Long cadastroDePessoa, TipoDeCPRF tipoDeCadastro) throws IllegalArgumentException { + + return (C) create(String.valueOf(cadastroDePessoa),tipoDeCadastro); + } + + /** + * Cria um {@linkplain CPRF} através de uma string não formatada e seu + * {@linkplain TipoDeCPRF}. + * + * @param cadastroDePessoa + * não formatado + * @param tipoDeCadastro + * tipo + * @return AbstractCPRF (CPF ou CNPJ) + * @throws IllegalArgumentException + */ + @SuppressWarnings("unchecked") + public static C create(String cadastroDePessoa, TipoDeCPRF tipoDeCadastro) throws IllegalArgumentException { + + String codigo = null; + + if (AbstractCPRFValidator.isParametrosValidos(cadastroDePessoa, tipoDeCadastro)) { + + switch_Cadastro: { + + if (tipoDeCadastro == TipoDeCPRF.CPF) { + + codigo = fillWithZeroLeft(cadastroDePessoa, 11); + break switch_Cadastro; + + } + + if (tipoDeCadastro == TipoDeCPRF.CNPJ) { + + codigo = fillWithZeroLeft(cadastroDePessoa, 14); + break switch_Cadastro; + + } + } + } + + return (C) create(codigo); + } + + /** + * Cria um {@linkplain CPRF} através de uma string formatada ou não. + * + * @param cadastroDePessoa + * - identificador do cadastro de pessoa formatado ou não. + * @return uma instância de AbstractCPRF. + * @throws IllegalArgumentException + * - caso o parâmetro não esteja em um formatador válido de + * cadastro de pessoa. + */ + @SuppressWarnings("unchecked") + public static C create(String cadastroDePessoa) + throws IllegalArgumentException { + + AbstractCPRF cp = null; + AbstractCPRFValidator autenticadorCP = AbstractCPRFValidator.create(cadastroDePessoa); + + if (autenticadorCP.isValido()) { + + if (autenticadorCP.isFisica()) { + + cp = new CPF(autenticadorCP + .getCodigoDoCadastro()); + + } else if (autenticadorCP.isJuridica()) { + + cp = new CNPJ(autenticadorCP + .getCodigoDoCadastro()); + } + + cp.autenticadorCP = autenticadorCP; + + } else { + + Exceptions.throwIllegalArgumentException( + "O cadastro de pessoa [ \""+cadastroDePessoa+"\" ] não é válido."); + } + + return (C) cp; + } + + /** + * @return boolean + */ + public boolean isFisica(){ + return autenticadorCP.isFisica(); + } + + /** + * @return boolean + */ + public boolean isJuridica(){ + return autenticadorCP.isJuridica(); + } + + protected void setCodigoFormatado(String codigoFormatado) { + + this.codigoFormatado = codigoFormatado; + } + + protected void setCodigo(Long codigo) { + + this.codigo = codigo; + } + public Long getCodigo() { + return codigo; + } + + public String getCodigoComZeros() { + + if(isFisica()){ + return fillWithZeroLeft(getCodigo(), 11); + }else{ + return fillWithZeroLeft(getCodigo(), 14); + } + } + + public String getCodigoFormatado() { + + return codigoFormatado; + } + + public Long getRaiz(){ + + if(isFisica()){ + return Long.valueOf(codigoFormatado.split("-")[0].replaceAll("\\.", EMPTY)); + }else{ + return Long.valueOf(codigoFormatado.split("/")[0].replaceAll("\\.", EMPTY)); + } + } + + public String getRaizComZeros(){ + + if(isFisica()){ + return fillWithZeroLeft(getRaiz(), 9); + }else{ + return fillWithZeroLeft(getRaiz(), 8); + } + } + + public String getRaizFormatada(){ + + if(isFisica()){ + return codigoFormatado.split("-")[0]; + }else{ + return codigoFormatado.split("/")[0]; + } + } + + public Integer getDv(){ + + return Integer.valueOf(codigoFormatado.split("-")[1]); + } + + public String getDvComZeros(){ + + return codigoFormatado.split("-")[1]; + } + + /** + * Realizado através da ordem natural do {@linkplain #getCodigo()}. + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(Object other) { + + if(other != null){ + if(other instanceof AbstractCPRF){ + AbstractCPRF cprf = (AbstractCPRF) other; + if(this.autenticadorCP.getTipoDeCadastro().equals(cprf.autenticadorCP.getTipoDeCadastro())){ + return this.codigo.compareTo(cprf.codigo); + }else{ + return this.autenticadorCP.getTipoDeCadastro().compareTo(cprf.autenticadorCP.getTipoDeCadastro()); + } + }else{ + return -1; + } + }else{ + return 1; + } + } + + /** + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); + result = prime * result + + ((codigoFormatado == null) ? 0 : codigoFormatado.hashCode()); + return result; + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof AbstractCPRF)) { + return false; + } + AbstractCPRF other = (AbstractCPRF) obj; + if (codigo == null) { + if (other.codigo != null) { + return false; + } + } else if (!codigo.equals(other.codigo)) { + return false; + } + if (codigoFormatado == null) { + if (other.codigoFormatado != null) { + return false; + } + } else if (!codigoFormatado.equals(other.codigoFormatado)) { + return false; + } + return true; + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + + return getCodigoFormatado(); + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJ.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJ.java new file mode 100644 index 0000000..7305be1 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJ.java @@ -0,0 +1,202 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:06:56 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:06:56 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + +import static org.apache.commons.lang.StringUtils.isNumeric; +import static org.jrimum.utilix.text.Strings.fillWithZeroLeft; + +import org.jrimum.utilix.Exceptions; +import org.jrimum.utilix.Objects; +import org.jrimum.utilix.text.Strings; +import org.jrimum.vallia.AbstractCPRFValidator; +import org.jrimum.vallia.AbstractCPRFValidator.TipoDeCPRF; + +/** + * + *

+ * Representa o cadastro nacional de pssoa jurídica (CNPJ), um número + * identificador de uma pessoa jurídica junto à Receita Federal, necessário para + * que a pessoa jurídica tenha capacidade de fazer contratos e processar ou ser + * processada. + *

+ * + *

+ * O formato do CNPJ é "##.###.###/####-XX", onde XX é o dígito verificador + * do número. + *

+ * + * + * @author Gilmar P.S.L + * @author Misael Barreto + * @author Rômulo Augusto + * @author Nordeste Fomento + * Mercantil + * + * @since 0.2 + * + * @version 0.2 + */ +public class CNPJ extends AbstractCPRF { + + public CNPJ(Long numCNPJ) { + + try { + + if (AbstractCPRFValidator.isParametrosValidos( + String.valueOf(numCNPJ), TipoDeCPRF.CNPJ)) { + + this.autenticadorCP = AbstractCPRFValidator.create(fillWithZeroLeft(numCNPJ, 14)); + + if (autenticadorCP.isValido()){ + + initFromNumber(numCNPJ); + + }else{ + + Exceptions.throwIllegalArgumentException("O cadastro de pessoa [ \"" + numCNPJ+ "\" ] não é válido."); + } + } + + } catch (Exception e) { + if (!(e instanceof CNPJException)) + throw new CNPJException(e); + } + + } + + public CNPJ(String strCNPJ) { + + this.autenticadorCP = AbstractCPRFValidator.create(strCNPJ); + + if (autenticadorCP.isValido()) { + + if(isNumeric(strCNPJ)){ + + initFromNotFormattedString(strCNPJ); + + }else{ + + initFromFormattedString(strCNPJ); + + } + + } else { + throw new CNPJException(new IllegalArgumentException( + "O cadastro de pessoa [ \"" + strCNPJ + "\" ] não é válido.")); + } + } + + public boolean isMatriz(){ + + return getSufixoFormatado().equals("0001"); + } + + public boolean isSufixoEquals(String sufixoFormatado){ + + Strings.checkNotNumeric(sufixoFormatado, String.format("O sufixo [%s] deve ser um número natural diferente de zero!", sufixoFormatado)); + + return isSufixoEquals(Integer.valueOf(sufixoFormatado)); + } + + public boolean isSufixoEquals(Integer sufixo){ + + Objects.checkNotNull(sufixo,"Sufixo nulo!"); + Objects.checkArgument(sufixo > 0, String.format("O sufixo [%s] deve ser um número natural diferente de zero!", sufixo)); + + return getSufixo().equals(sufixo); + } + + public Integer getSufixo(){ + + return Integer.valueOf(getSufixoFormatado()); + } + + public String getSufixoFormatado(){ + + return getCodigoFormatado().split("-")[0].split("/")[1]; + } + + private void initFromNumber(Long numCNPJ) { + + try { + + this.setCodigoFormatado(format(fillWithZeroLeft(numCNPJ, 14))); + this.setCodigo(numCNPJ); + + } catch (Exception e) { + throw new CNPJException(e); + } + } + private void initFromFormattedString(String strCNPJ) { + + try { + + this.setCodigoFormatado(strCNPJ); + this.setCodigo(Long.parseLong(removeFormat(strCNPJ))); + + } catch (Exception e) { + throw new CNPJException(e); + } + } + + private void initFromNotFormattedString(String strCNPJ) { + + try { + + this.setCodigoFormatado(format(strCNPJ)); + this.setCodigo(Long.parseLong(strCNPJ)); + + } catch (Exception e) { + throw new CNPJException(e); + } + } + + private String format(String strCNPJ) { + + StringBuilder codigoFormatado = new StringBuilder(strCNPJ); + + codigoFormatado.insert(2, '.'); + codigoFormatado.insert(6, '.'); + codigoFormatado.insert(10, '/'); + codigoFormatado.insert(15, '-'); + + return codigoFormatado.toString(); + } + + private String removeFormat(String codigo) { + + codigo = codigo.replace(".", ""); + codigo = codigo.replace("/", ""); + codigo = codigo.replace("-", ""); + + return codigo; + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJException.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJException.java new file mode 100644 index 0000000..8c3e70a --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CNPJException.java @@ -0,0 +1,91 @@ + +/* + * Copyright 2008 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: 23/04/2008 - 01:06:14 + * + * ================================================================================ + * + * 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. + * + * Criado em: 23/04/2008 - 01:06:14 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + + + +/** + * + *

+ * Qualquer falha na geração ou operações próprias da classe CNPJ. + *

+ * + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ + +public class CNPJException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 7253144254681596414L; + + /** + * + */ + public CNPJException() { + + } + + /** + * @param message + * @param cause + */ + public CNPJException(String message, Throwable cause) { + super(message, cause); + + } + + /** + * @param message + */ + public CNPJException(String message) { + super(message); + + } + + /** + * @param cause + */ + public CNPJException(Throwable cause) { + super(cause); + + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPF.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPF.java new file mode 100644 index 0000000..6c33a6e --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPF.java @@ -0,0 +1,165 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:07:16 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:07:16 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + +import static org.apache.commons.lang.StringUtils.isNumeric; +import static org.jrimum.utilix.text.Strings.fillWithZeroLeft; + +import org.jrimum.utilix.Exceptions; +import org.jrimum.vallia.AbstractCPRFValidator; +import org.jrimum.vallia.AbstractCPRFValidator.TipoDeCPRF; + +/** + *

+ * Representa o cadastro de pessoa física (CPF), um número identificador de todo + * contribuinte (pessoas físicas brasileiras ou estrangeiras com negócios no + * Brasil). + *

+ *

+ * O formatador do CPF é "###.###.###-XX", onde XX é o dígito verificador do + * número. + *

+ * + * + * @author Gilmar P.S.L + * @author Misael Barreto + * @author Rômulo Augusto + * @author Nordeste Fomento + * Mercantil + * + * @since 0.2 + * + * @version 0.2 + */ +public class CPF extends AbstractCPRF { + + public CPF(Long numCPF) { + + try { + + if (AbstractCPRFValidator.isParametrosValidos(String.valueOf(numCPF), + TipoDeCPRF.CPF)) { + + this.autenticadorCP = AbstractCPRFValidator.create(fillWithZeroLeft(numCPF, 11)); + + if (autenticadorCP.isValido()){ + + initFromNumber(numCPF); + + }else{ + + Exceptions.throwIllegalArgumentException("O cadastro de pessoa [ \"" + numCPF+ "\" ] não é válido."); + } + + } + + } catch (Exception e) { + if (!(e instanceof CPFException)) + throw new CPFException(e); + } + } + + public CPF(String strCPF) { + + this.autenticadorCP = AbstractCPRFValidator.create(strCPF); + + if (autenticadorCP.isValido()) { + + if(isNumeric(strCPF)){ + + initFromNotFormattedString(strCPF); + + }else{ + + initFromFormattedString(strCPF); + + } + + } else { + throw new CPFException(new IllegalArgumentException( + "O cadastro de pessoa [ \"" + strCPF + "\" ] não é válido.")); + } + } + + private void initFromNumber(Long numCPF) { + + try { + + this.setCodigoFormatado(format(fillWithZeroLeft(numCPF, 11))); + this.setCodigo(numCPF); + + } catch (Exception e) { + throw new CPFException(e); + } + } + private void initFromFormattedString(String strCPF) { + + try { + + this.setCodigoFormatado(strCPF); + this.setCodigo(Long.parseLong(removeFormat(strCPF))); + + } catch (Exception e) { + throw new CPFException(e); + } + } + + private void initFromNotFormattedString(String strCPF) { + + try { + + this.setCodigoFormatado(format(strCPF)); + this.setCodigo(Long.parseLong(strCPF)); + + } catch (Exception e) { + throw new CPFException(e); + } + } + + private String format(String strCPF) { + + StringBuilder codigoFormatado = new StringBuilder(strCPF); + + codigoFormatado.insert(3, '.'); + codigoFormatado.insert(7, '.'); + codigoFormatado.insert(11, '-'); + + return codigoFormatado.toString(); + } + + private String removeFormat(String codigo) { + + codigo = codigo.replace(".", ""); + codigo = codigo.replace("-", ""); + + return codigo; + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPFException.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPFException.java new file mode 100644 index 0000000..1e4ed56 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPFException.java @@ -0,0 +1,91 @@ + +/* + * Copyright 2008 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: 23/04/2008 - 01:05:45 + * + * ================================================================================ + * + * 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. + * + * Criado em: 23/04/2008 - 01:05:45 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + + + +/** + * + *

+ * Qualquer falha na geração ou operações próprias da classe CPF. + *

+ + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ + +public class CPFException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -3614884453255335650L; + + /** + * + */ + public CPFException() { + + } + + /** + * @param message + * @param cause + */ + public CPFException(String message, Throwable cause) { + super(message, cause); + + } + + /** + * @param message + */ + public CPFException(String message) { + super(message); + + } + + /** + * @param cause + */ + public CPFException(Throwable cause) { + super(cause); + + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPRF.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPRF.java new file mode 100644 index 0000000..7633482 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/CPRF.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 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: 26/10/2011 - 21:00:23 + * + * ================================================================================ + * + * Direitos autorais 2011 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: 26/10/2011 - 21:00:23 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + +/** + * Interface comum entre Cadastro de Pessoa na Receita Federal de pessoas + * Físicas ou Jurídicas. + * + * @author Gilmar P.S.L. + */ +public interface CPRF extends Comparable{ + + public boolean isFisica(); + + public boolean isJuridica(); + + public Long getCodigo(); + + public String getCodigoComZeros(); + + public String getCodigoFormatado(); + + public Long getRaiz(); + + public String getRaizComZeros(); + + public String getRaizFormatada(); + + public Integer getDv(); + + public String getDvComZeros(); +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/package-info.java new file mode 100644 index 0000000..3d9e7b5 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/cprf/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.comum.pessoa.id.cprf; \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/package-info.java new file mode 100644 index 0000000..cb818ad --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/id/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.comum.pessoa.id; \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/package-info.java new file mode 100644 index 0000000..778e014 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/comum/pessoa/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.comum.pessoa; \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Agencia.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Agencia.java new file mode 100644 index 0000000..7e51323 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Agencia.java @@ -0,0 +1,63 @@ +/* + * Copyright 2008 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: 04/04/2009 - 16:36:30 + * + * ================================================================================ + * + * 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. + * + * Criado em: 04/04/2009 - 16:36:30 + * + */ +package org.jrimum.domkee.financeiro.banco; + + +/** + * + *

+ * Define o contrato para classes Agencia. Esse contrato é baseado na especificação FEBRABAN: + *

+ *

+ * Invariantes: + *

    + *
  • Código: deve ser um inteiro natural (incluindo zero) entre 1 e 5 dígitos
  • + *
  • Dígito Verificador: alpha-numérico sendo um inteiro natural (incluindo zero) + * ou caracter não vazio (' ') com um dígito.
  • + *
+ *

+ * + * @author Gilmar P.S.L. + * @author Rômulo Augusto + * + * @version 0.2 + */ +public interface Agencia{ + + /** + * @return Número da agência + */ + C getCodigo(); + + /** + * @return Dígito verificador + */ + D getDigitoVerificador(); +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Banco.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Banco.java new file mode 100644 index 0000000..09e5663 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Banco.java @@ -0,0 +1,135 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:59:18 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:59:18 + * + */ + +package org.jrimum.domkee.financeiro.banco; + +import java.awt.Image; + +import org.jrimum.domkee.comum.pessoa.PessoaJuridica; +import org.jrimum.domkee.financeiro.banco.febraban.CodigoDeCompensacaoBACEN; + + + +/** + * + *

+ * Interface que define o contrato para a criação de um novo banco (instituição + * financeira) supervisionada pelo BACEN. + *

+ * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ + +public interface Banco extends PessoaJuridica { + + + /** + @see #setCodigoDeCompensacaoBACEN(CodigoDeCompensacaoBACEN) + * + * @return CodigoDeCompensacaoBACEN + * + * @since 0.2 + */ + + CodigoDeCompensacaoBACEN getCodigoDeCompensacaoBACEN(); + + /** + @see #setSegmento(String) + * + * @return Segmento + * + * @since 0.2 + */ + + String getSegmento(); + + + + /** + * @see #setImgLogo(Image) + * + * @return Imagem + * + * @since 0.2 + */ + + Image getImgLogo(); + + + /** *

+ * Código de compensação BACEN + *

> + * + * @param codigoDeCompensacaoBACEN + * + * @since 0.2 + */ + + void setCodigoDeCompensacaoBACEN(CodigoDeCompensacaoBACEN codigoDeCompensacaoBACEN); + + /** *

+ * Segmento registrado no BACEN. + *

+ * + *

+ * Exemplos: + *

    + *
  • Banco Comercial Estrangeiro - Filial no país
  • + *
  • Banco Múltiplo
  • + *
  • Banco Comercial
  • + *
  • Banco Múltiplo Cooperativo
  • + *
+ *

> + * + * @param segmento + * + * @since 0.2 + */ + + void setSegmento(String segmento); + + /** +

+ * Imagem da logo-marca do banco. + *

> + * + * @param imgLogo + * + * @since 0.2 + */ + + void setImgLogo(Image imgLogo); +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametroBancario.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametroBancario.java new file mode 100644 index 0000000..d76a3d1 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametroBancario.java @@ -0,0 +1,44 @@ +/* + * 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. + * + * Created at: 20/09/2013 - 18:28:00 + * + * ================================================================================ + * + * 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. + * + * Criado em: 20/09/2013 - 18:28:00 + * + */ + +package org.jrimum.domkee.financeiro.banco; + +/** + * Key de um {@link ParametrosBancariosMap} na qual sua representacao é uma + * nome em uma Enumeração. + * + * + * @author Gilmar P.S.L. + * + * @param

+ * Enum usado como key do parâmetro bancário. + */ +public interface ParametroBancario

> { + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMap.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMap.java new file mode 100644 index 0000000..6833bb3 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMap.java @@ -0,0 +1,364 @@ +/* + * 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. + * + * Created at: 14/02/2010 - 18:00:18 + * + * ================================================================================ + * + * 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. + * + * Criado em: 14/02/2010 - 18:00:18 + * + */ + +package org.jrimum.domkee.financeiro.banco; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.jrimum.utilix.Objects; + +/** + * Mapa de parâmetros com dados bancário para condições específicas de + * determinados bancos ou implementações. PARÂMETROS NULOS NÃO SÃO + * PERMITIDOS. + * + *

+ * Mais dados bancários podem ser necessários a um título para gerar um boleto, + * por exemplo. Assim, dependendo do banco, talvez seja necessário informar mais + * dados além de: + *

+ * + *
    + *
  • Valor do título;
  • + *
  • Vencimento;
  • + *
  • Nosso número;
  • + *
  • Código do banco;
  • + *
  • Data de vencimento;
  • + *
  • Agência/Código do cedente
  • ; + *
  • Código da carteira;
  • + *
  • Código da moeda;
  • + *
+ * + *

+ * Definidos como padrão pela FEBRABAN. + *

+ * + * @author Gilmar P.S.L. + * + * @version 0.2 + * @since 0.2 + */ +public final class ParametrosBancariosMap { + + private Map, Number> dadosMap; + + /** + * Instancia um mapa sem parâmetros. + * + * @since 0.2 + */ + public ParametrosBancariosMap() { + getInstance(); + } + + /** + * Instancia o mapa com um mapeamento já especificado. Nomes e valores nulos + * não são permitidos, o nome deve ser único. + * + * @param nome + * do parâmetro a ser associado + * @param valor + * do parâmetro a ser associado + * + * @throws IllegalArgumentException + * se nome ou valor == NULL + * + * @since 0.2 + */ + public ParametrosBancariosMap(ParametroBancario nome, Number valor) { + + adicione(nome, valor); + } + + /** + * Verifica se o {@code ParametrosBancariosMap} passado por parâmetro + * não é null e possui elementos. + * + * + * @param params + * - Instância de {@code ParametrosBancariosMap} testada. + * @return {@code params != null && params.isNaoVazio()} + * + * @since 0.2 + */ + public static boolean hasElement(ParametrosBancariosMap params){ + + return params != null && params.isNaoVazio(); + } + + /** + * Indica se o mapa contém um mapeamento para o nome de parâmetro + * especificado. + * + * @param nome + * do parâmetro cuja existência no mapa será testada. + * + * @return true se o mapa contém um mapeamento para parâmetro + * + * @throws NullPointerException + * se nome == NULL + * + * @since 0.2 + */ + public boolean contemComNome(ParametroBancario nome) { + + Objects.checkNotNull(nome); + + return dadosMap.containsKey(nome); + } + + /** + * Indica se o mapa contém o valor especificado. + * + * @param valor + * cuja existência no mapa será testada + * + * @return true se o mapa contém uma ou mais associações de parâmetros ao + * valor especificado + * + * @throws IllegalArgumentException + * se valor == NULL + * + * @since 0.2 + */ + public boolean contemComValor(V valor) { + + Objects.checkNotNull(valor); + + return dadosMap.containsValue(valor); + } + + /** + * Retorna o valor para o qual o parâmetro bancário especificada está + * mapeado, ou nulo, se este mapa contém não contém nenhum mapeamento para + * tal parâmetro. Nomes nulos não são permitidos. + * + * @param + * Tipo de retorno genérico do valor contido no mapa com nome + * especificado + * @param nome + * do parâmetro especificado + * @return o valor associado com o parâmetro bancário especificado, ou nulo + * se não houver nenhum mapeamento para o mesmo + * + * @throws IllegalArgumentException + * se nome == NULL + * + * @since 0.2 + */ + @SuppressWarnings("unchecked") + public V getValor(ParametroBancario nome) { + + Objects.checkNotNull(nome); + + return (V) dadosMap.get(nome); + } + + /** + * Indica se o mapa não contém associações (parâmetro,valor) + * + * @return true se vazio + * + * @since 0.2 + */ + public boolean isVazio() { + + return dadosMap.isEmpty(); + } + + /** + * Indica se o mapa contém alguma associação (parâmetro,valor) + * + * @return !isVazio() + * + * @since 0.2 + */ + public boolean isNaoVazio() { + + return !isVazio(); + } + + /** + * Retorna um conjuto de nomes de parâmetro do mapa. + * + * @return conjuto de nomes de parâmetro do mapa. + * + * @since 0.2 + */ + public Set> nomes() { + + return dadosMap.keySet(); + } + + /** + * Retorna uma coleção com os valores contidos no mapa. + * + * @return coleção de valores do mapa. + * + * @since 0.2 + */ + public Collection valores() { + + return dadosMap.values(); + } + + /** + * Retorna um conjuto de entradas (parâmetro,valor) do mapa. Assim qualquer + * modificação nestes valores também reflete no mapa de parâmetros + * bancários. + * + * @return conjunto dos mapeamentos contidos. + * + * @since 0.2 + */ + public Set,Number>> entradas() { + return dadosMap.entrySet(); + } + + /** + * Associa o valor especificado a um nome de parâmetro também especificado + * que deve ser único neste mapa. Nomes e valores nulos não são permitidos. + * + * @param nome + * do parâmetro a ser associado + * @param valor + * do parâmetro a ser associado + * @return referência a este mapa + * + * @throws NullPointerException + * se nome ou valor == NULL + * + * @since 0.2 + */ + public ParametrosBancariosMap adicione(ParametroBancario nome, Number valor) { + + Objects.checkNotNull(nome); + Objects.checkNotNull(valor); + + getInstance(); + + dadosMap.put(nome, valor); + + return this; + } + + /** + * Adiciona todos os dados bancários de um outro mapeamento neste mapeamento. + * Parâmetros nulos não são permitidos. + * + *

+ * O efeito desta chamada é equivalente a de adiciona("parametro", Valor) + * neste mapa, só que uma vez para cada mapeamento. + *

+ * + * @param dados + * - outros parâmetros bancários a serem mapeados neste mapa. + * @return referência a este mapa + * + * @throws NullPointerException + * se dados == NULL + * + * @since 0.2 + */ + public ParametrosBancariosMap adicione(ParametrosBancariosMap dados) { + + Objects.checkNotNull(dados); + + this.dadosMap.putAll(dados.dadosMap); + + return this; + } + + /** + * Retorna o valor removido associado ao nome do parâmetro bancário + * informado, ou nulo se o mapa não contiver nenhum mapeamento. Nomes nulos + * não são permitidos. + * + *

+ * Um retorno nulo indica necessariamente que não existia nenhum mapeamento + * para o nome do parâmetro bancário. + *

+ * + * @param + * Tipo de retorno genérico do valor + * @param nome + * do parâmetro bancário que deve ser removido do mapa + * @return o valor anterior associado com o parâmetro bancário, ou nulo se + * não houver nenhum mapeamento para o mesmo + * + * @throws NullPointerException + * se nome == NULL + * + * @since 0.2 + */ + @SuppressWarnings("unchecked") + public V remova(ParametroBancario nome) { + + Objects.checkNotNull(nome); + + return (V) dadosMap.remove(nome); + } + + /** + * Remove todos os os parâmetros desta instância. + * + * @since 0.2 + */ + public void limpe() { + + dadosMap.clear(); + } + + /** + * @return retorna o número de parâmetros contidos na instância. + * + * @since 0.2 + */ + public int quantidade() { + + return dadosMap.size(); + } + + /** + * Instancia um HashMap para uso da deste map bancário. + * + * @since 0.2 + */ + private void getInstance() { + + if (dadosMap == null) { + dadosMap = new HashMap, Number>(); + } + } + +} \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Pessoa.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Pessoa.java new file mode 100644 index 0000000..8f1c35b --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/Pessoa.java @@ -0,0 +1,320 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:58:13 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:58:13 + * + */ + +package org.jrimum.domkee.financeiro.banco; + +import static org.jrimum.utilix.Collections.hasElement; +import static org.jrimum.utilix.Objects.isNull; + +import java.util.ArrayList; +import java.util.Collection; + +import org.jrimum.domkee.comum.pessoa.contato.NumeroDeTelefone; +import org.jrimum.domkee.comum.pessoa.endereco.Endereco; +import org.jrimum.domkee.comum.pessoa.id.cprf.AbstractCPRF; +import org.jrimum.domkee.comum.pessoa.id.cprf.CPRF; +import org.jrimum.domkee.financeiro.banco.febraban.ContaBancaria; +import org.jrimum.utilix.Objects; + + + +/** + * + *

+ * Representa uma pessoa no negócio de boletos bancários. + * Ela pode assumir três papéis diferentes: + *

    + *
  • Cedente
  • + *
  • Sacador
  • + *
  • Sacador Avalista
  • + *
+ *

+ * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public class Pessoa implements org.jrimum.domkee.comum.pessoa.Pessoa { + + private String nome; + + /** + * @see CPRF + */ + private CPRF cprf; + + /** + * @see NumeroDeTelefone + */ + private Collection telefones; + + /** + * @see Endereco + */ + private Collection enderecos; + + /** + * @see ContaBancaria + */ + private Collection contasBancarias; + + public Pessoa() {} + + public Pessoa(String nome) { + + this.nome = nome; + } + + public Pessoa(String nome, String cadastroDePessoa) { + + this.nome = nome; + this.cprf = AbstractCPRF.create(cadastroDePessoa); + } + + public Pessoa(String nome, CPRF cadastroDePessoa) { + + this.nome = nome; + this.cprf = cadastroDePessoa; + } + + /** + * @see ContaBancaria + */ + public void addContaBancaria(ContaBancaria contaBancaria) { + + if(isNull(contasBancarias)){ + + contasBancarias = new ArrayList(); + } + + contasBancarias.add(contaBancaria); + } + + /** + * Verifica se esta pessoa tem alguma conta bancária. + * + * @see ContaBancaria + */ + + public boolean hasContaBancaria(){ + + return hasElement(getContasBancarias()); + } + + /** + * @see Endereco + */ + public void addEndereco(Endereco endereco) { + + if(isNull(enderecos)){ + + enderecos = new ArrayList(); + } + + enderecos.add(endereco); + } + + /** + * @see NumeroDeTelefone + */ + public void addTelefone(NumeroDeTelefone telefone) { + + if(isNull(telefones)){ + + telefones = new ArrayList(); + } + + telefones.add(telefone); + } + + /** + * @see CPRF + */ + + public CPRF getCPRF() { + + return cprf; + } + + /** + * Retorna o resultado de uma chamada a {@code iterator.next()} de + * {@linkplain #getContasBancarias()}, caso exista alguma conta, ou null, caso + * não exista {@linkplain #contasBancarias}. + * + * @return Chamada a {@code iterator.next()}, caso exista algum endereço ou + * null. + */ + public ContaBancaria getNextContaBancaria(){ + + if(hasElement(getContasBancarias())){ + + return getContasBancarias().iterator().next(); + } + + return null; + } + + /** + * @see ContaBancaria + * @see Collection + */ + public Collection getContasBancarias() { + + return contasBancarias; + } + + /** + * Retorna o resultado de uma chamada a {@code iterator.next()} de + * {@linkplain #getEnderecos()}, caso exista algum endereço, ou null, caso + * não exista {@linkplain #enderecos}. + * + * @return Chamada a {@code iterator.next()}, caso exista algum endereço ou + * null. + */ + public Endereco getNextEndereco(){ + + if(hasElement(getEnderecos())){ + + return getEnderecos().iterator().next(); + } + + return null; + } + + /** + * @see Endereco + * @see Collection + */ + public Collection getEnderecos() { + + return enderecos; + } + + public String getNome() { + + return nome; + } + + /** + * Retorna o resultado de uma chamada a {@code iterator.next()} de + * {@linkplain #getTelefones()}, caso exista algum telefone, ou null, caso + * não exista {@linkplain #telefones}. + * + * @return Chamada a {@code iterator.next()}, caso exista algum endereço ou + * null. + */ + public NumeroDeTelefone getNextTelefone(){ + + if(hasElement(getTelefones())){ + + return getTelefones().iterator().next(); + } + + return null; + } + + /** + * @see NumeroDeTelefone + * @see Collection + */ + public Collection getTelefones() { + + return telefones; + } + + /** + * @see CPRF + */ + public void setCPRF(CPRF cprf) { + + this.cprf = cprf; + } + + /** + * @see ContaBancaria + * @see Collection + */ + public void setContasBancarias(Collection contasBancarias) { + + this.contasBancarias = contasBancarias; + } + + /** + * @see Endereco + * @see Collection + */ + public void setEnderecos(Collection enderecos) { + + this.enderecos = enderecos; + } + + public void setNome(String nome) { + + this.nome = nome; + } + + /** + * @see NumeroDeTelefone + * @see Collection + */ + public void setTelefones(Collection telefones) { + + this.telefones = telefones; + } + + /** + * Verifica se esta pessoa é uma instância de PessoaFisica. + * + * @see org.jrimum.domkee.comum.pessoa.Pessoa#isFisica() + */ + public boolean isFisica() { + + return (this instanceof PessoaFisica); + } + + /** + * Verifica se esta pessoa é uma instância de PessoaJuridica. + * + * @see org.jrimum.domkee.comum.pessoa.Pessoa#isJuridica() + */ + public boolean isJuridica() { + + return (this instanceof PessoaJuridica); + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaFisica.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaFisica.java new file mode 100644 index 0000000..cfdbe9e --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaFisica.java @@ -0,0 +1,104 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:58:20 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:58:20 + * + */ + +package org.jrimum.domkee.financeiro.banco; + +import static org.jrimum.utilix.Objects.isNotNull; +import static org.jrimum.utilix.Objects.isNull; + +import java.util.Collection; + +import org.jrimum.domkee.comum.pessoa.id.RG; + + +/** + *

+ * Representação básica de uma Pessoa Física. + *

+ * + * @see Pessoa + * @see org.jrimum.domkee.comum.pessoa.id.cprf.CPRF + * @see org.jrimum.domkee.comum.pessoa.id.cprf.CPF + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ + +public class PessoaFisica extends Pessoa implements + org.jrimum.domkee.comum.pessoa.PessoaFisica { + + private org.jrimum.domkee.comum.pessoa.PessoaFisica conjuge; + + private String estadoCivil; + + private Collection rgs; + + public PessoaFisica() { + } + + public org.jrimum.domkee.comum.pessoa.PessoaFisica getConjuge() { + + return conjuge; + } + + public String getEstadoCivil() { + + return estadoCivil; + } + + public Collection getRgs() { + + return rgs; + } + + public void setConjuge( + org.jrimum.domkee.comum.pessoa.PessoaFisica conjuge) { + + this.conjuge = conjuge; + + if (isNotNull(conjuge) && isNull(conjuge.getConjuge())) + conjuge.setConjuge(this); + } + + public void setEstadoCivil(String estadoCivil) { + + this.estadoCivil = estadoCivil; + } + + public void setRgs(Collection rgs) { + + this.rgs = rgs; + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaJuridica.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaJuridica.java new file mode 100644 index 0000000..bdefd51 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/PessoaJuridica.java @@ -0,0 +1,99 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:58:26 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:58:26 + * + */ + + +package org.jrimum.domkee.financeiro.banco; + + + +/** + *

+ * Representação básica de uma Pessoa Jurídica. + *

+ * + * @see Pessoa + * @see org.jrimum.domkee.comum.pessoa.id.cprf.CPRF + * @see org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ +public class PessoaJuridica extends Pessoa implements org.jrimum.domkee.comum.pessoa.PessoaJuridica { + + private Long inscricaoEstadual; + + private Long inscricaoMunicipal; + + /** + * Título do estabelecimento, diferente do nome (NOME EMPRESARIAL). + */ + private String nomeFantasia; + + + public Long getInscricaoEstadual() { + + return inscricaoEstadual; + } + + + public Long getInscricaoMunicipal() { + + return inscricaoMunicipal; + } + + + public String getNomeFantasia() { + + return nomeFantasia; + } + + + public void setInscricaoEstadual(Long inscricaoEstadual) { + + this.inscricaoEstadual = inscricaoEstadual; + } + + + public void setInscricaoMunicipal(Long inscricaoMunicipal) { + + this.inscricaoMunicipal = inscricaoMunicipal; + } + + + public void setNomeFantasia(String nomeFantasia) { + + this.nomeFantasia = nomeFantasia; + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Agencia.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Agencia.java new file mode 100644 index 0000000..9753bf5 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Agencia.java @@ -0,0 +1,119 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:57:33 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:57:33 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import static org.apache.commons.lang.StringUtils.EMPTY; + +import org.apache.commons.lang.StringUtils; +import org.jrimum.utilix.Exceptions; +import org.jrimum.utilix.Objects; + + +/** + *

+ * Esta classe segue o padrão especificado pela FEBRABAN: + *
+ * Invariantes: + *

    + *
  • Código: deve ser um inteiro natural (incluindo zero) entre 1 e 5 dígitos
  • + *
  • Dígito Verificador: alpha-numérico sendo um inteiro natural (incluindo zero) + * ou caracter não vazio (' ') com um dígito.
  • + *
+ *

+ * + * @author Gilmar P.S.L. + * @author Rômulo Augusto + * @author Misael Barreto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public class Agencia implements org.jrimum.domkee.financeiro.banco.Agencia { + + private final Integer codigo; + + private final String digitoVerificador; + + public Agencia(Integer codigo) { + + this.codigo = codigo; + verifyCodigo(); + this.digitoVerificador = EMPTY; + } + + public Agencia(Integer codigo, String digito) { + + this.codigo = codigo; + verifyCodigo(); + this.digitoVerificador = digito; + verifyDv(); + } + + public void verifyCodigo() { + + if (codigo < 0 ) { + Exceptions.throwIllegalArgumentException("O código da agência deve ser um inteiro natural (incluindo zero)"); + } + + if (String.valueOf(codigo).length() > 5) { + Exceptions.throwIllegalArgumentException("O código da agência deve possuir de 1 a 5 dígitos"); + } + } + + public void verifyDv(){ + + if (StringUtils.isBlank(digitoVerificador)) { + Exceptions.throwIllegalArgumentException("O dígito verificador da agência não pode ser null ou apenas espaços em branco"); + } + + if (digitoVerificador.length() > 1) { + Exceptions.throwIllegalArgumentException("O dígito verificador da agência deve possuir apenas um dígito"); + } + + if (!StringUtils.isAlphanumeric(digitoVerificador)) { + Exceptions.throwIllegalArgumentException("O dígito verificador da agência deve ser letra ou dígito"); + } + } + + public Integer getCodigo() { + return codigo; + } + + public String getDigitoVerificador() { + return digitoVerificador; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Banco.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Banco.java new file mode 100644 index 0000000..0fe0caa --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Banco.java @@ -0,0 +1,444 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:57:43 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:57:43 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import static org.jrimum.utilix.Objects.isNotNull; + +import java.awt.Image; +import java.util.Collection; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.log4j.Logger; +import org.jrimum.domkee.comum.pessoa.contato.NumeroDeTelefone; +import org.jrimum.domkee.comum.pessoa.endereco.Endereco; +import org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ; +import org.jrimum.domkee.comum.pessoa.id.cprf.CPRF; +import org.jrimum.domkee.financeiro.banco.Pessoa; +import org.jrimum.domkee.financeiro.banco.PessoaJuridica; + + + +/** + * + *

+ * Um Banco (instituição financeira) supervisionada pelo BACEN. + *

+ * + * @author Gilmar P.S.L. + * + * @since 0.2 + * + * @version 0.2 + */ + +public class Banco implements org.jrimum.domkee.financeiro.banco.Banco { + + private static Logger log = Logger.getLogger(Banco.class); + + private CodigoDeCompensacaoBACEN codigoDeCompensacaoBACEN; + + private String segmento; + + private Image imgLogo; + + private PessoaJuridica pessoaJuridica; + + /** + * + */ + public Banco() { + super(); + } + + + /** + * @param codigoDeCompensacaoBACEN + * @param instituicao + */ + public Banco(CodigoDeCompensacaoBACEN codigoDeCompensacaoBACEN, String instituicao) { + super(); + + this.codigoDeCompensacaoBACEN = codigoDeCompensacaoBACEN; + + pessoaJuridica = new PessoaJuridica(); + pessoaJuridica.setNome(instituicao); + pessoaJuridica.setNomeFantasia(instituicao); + } + + /** + * @param codigoDeCompensacaoBACEN + * @param instituicao + * @param cnpj + */ + public Banco(CodigoDeCompensacaoBACEN codigoDeCompensacaoBACEN, String instituicao, CNPJ cnpj) { + super(); + + this.codigoDeCompensacaoBACEN = codigoDeCompensacaoBACEN; + + pessoaJuridica = new PessoaJuridica(); + + pessoaJuridica.setCPRF(cnpj); + pessoaJuridica.setNome(instituicao); + pessoaJuridica.setNomeFantasia(instituicao); + } + + /** + * @param codigoDeCompensacaoBACEN + * @param instituicao + * @param cnpj + * @param segmento + */ + public Banco(CodigoDeCompensacaoBACEN codigoDeCompensacaoBACEN, String instituicao, CNPJ cnpj, String segmento) { + + super(); + + this.codigoDeCompensacaoBACEN = codigoDeCompensacaoBACEN; + this.segmento = segmento; + + pessoaJuridica = new PessoaJuridica(); + pessoaJuridica.setCPRF(cnpj); + pessoaJuridica.setNome(instituicao); + pessoaJuridica.setNomeFantasia(instituicao); + } + + /** + * @param codigoDeCompensacaoBACEN + * @param instituicao + * @param cnpj + * @param segmento + * @param imgLogo + */ + public Banco(CodigoDeCompensacaoBACEN codigoDeCompensacaoBACEN, String instituicao, CNPJ cnpj, String segmento, Image imgLogo) { + + super(); + + this.codigoDeCompensacaoBACEN = codigoDeCompensacaoBACEN; + this.segmento = segmento; + this.imgLogo = imgLogo; + + pessoaJuridica = new PessoaJuridica(); + pessoaJuridica.setCPRF(cnpj); + } + + /** + *

+ * Verifica se o código passado está ok em relação as regras: + *

    + *
  1. Não nulo
  2. + *
  3. Numérico
  4. + *
  5. Com 3 digitos
  6. + *
+ *

+ * + * @param codigo - Código de compensação BACEN do banco + * + * @return se ok + * + * @throws IllegalArgumentException + * + * @since 0.2 + * + */ + public static boolean isCodigoDeCompensacaoOK(String codigo) { + + boolean ok = false; + + if (isNotNull(codigo)) { + + if (StringUtils.isNumeric(codigo)) { + + if (codigo.length() == 3) { + + ok = true; + + } else { + log.warn("O código é de apenas 3 digitos!"); + } + + } else { + log.warn("O código de compensação deve ser numérico!"); + } + } + + return ok; + } + + + /** + * @return the codigoDeCompensacaoBACEN + */ + public CodigoDeCompensacaoBACEN getCodigoDeCompensacaoBACEN() { + return codigoDeCompensacaoBACEN; + } + + + /** + * @param codigoDeCompensacaoBACEN the codigoDeCompensacaoBACEN to set + */ + public void setCodigoDeCompensacaoBACEN( + CodigoDeCompensacaoBACEN codigoDeCompensacaoBACEN) { + this.codigoDeCompensacaoBACEN = codigoDeCompensacaoBACEN; + } + + + public CNPJ getCNPJ() { + return (CNPJ)pessoaJuridica.getCPRF(); + } + + public void setCNPJ(CNPJ cnpj) { + pessoaJuridica.setCPRF(cnpj); + } + + public String getSegmento() { + return segmento; + } + + public void setSegmento(String segmento) { + this.segmento = segmento; + } + + public Image getImgLogo() { + return imgLogo; + } + + public void setImgLogo(Image imgLogo) { + this.imgLogo = imgLogo; + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#addEndereco(org.jrimum.domkee.comum.pessoa.endereco.Endereco) + */ + + public void addEndereco(Endereco endereco) { + + pessoaJuridica.addEndereco(endereco); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#addTelefone(org.jrimum.domkee.comum.pessoa.contato.NumeroDeTelefone) + */ + + public void addTelefone(NumeroDeTelefone telefone) { + + pessoaJuridica.addTelefone(telefone); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#getCPRF() + */ + + public CPRF getCPRF() { + + return pessoaJuridica.getCPRF(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#getEnderecos() + */ + public Collection getEnderecos() { + + return pessoaJuridica.getEnderecos(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#getNome() + */ + + public String getNome() { + + return pessoaJuridica.getNome(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#getTelefones() + */ + + public Collection getTelefones() { + + return pessoaJuridica.getTelefones(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#isFisica() + */ + + public boolean isFisica() { + + return pessoaJuridica.isFisica(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#isJuridica() + */ + + public boolean isJuridica() { + + return pessoaJuridica.isJuridica(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#setCPRF(org.jrimum.domkee.comum.pessoa.id.cprf.CPRF) + */ + + public void setCPRF(CPRF cprf) { + + pessoaJuridica.setCPRF(cprf); + } + + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#setEnderecos(java.util.Collection) + */ + public void setEnderecos(Collection enderecos) { + + pessoaJuridica.setEnderecos(enderecos); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#setNome(java.lang.String) + */ + + public void setNome(String nome) { + + pessoaJuridica.setNome(nome); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#setTelefones(java.util.Collection) + */ + + public void setTelefones(Collection telefones) { + + pessoaJuridica.setTelefones(telefones); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.PessoaJuridica#getInscricaoEstadual() + */ + + public Long getInscricaoEstadual() { + + return pessoaJuridica.getInscricaoEstadual(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.PessoaJuridica#getInscricaoMunicipal() + */ + + public Long getInscricaoMunicipal() { + + return pessoaJuridica.getInscricaoMunicipal(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.PessoaJuridica#getNomeFantasia() + */ + + public String getNomeFantasia() { + + return pessoaJuridica.getNome(); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.PessoaJuridica#setInscricaoEstadual(java.lang.Long) + */ + + public void setInscricaoEstadual(Long inscricaoEstadual) { + + pessoaJuridica.setInscricaoEstadual(inscricaoEstadual); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.PessoaJuridica#setInscricaoMunicipal(java.lang.Long) + */ + + public void setInscricaoMunicipal(Long inscricaoMunicipal) { + + pessoaJuridica.setInscricaoMunicipal(inscricaoMunicipal); + } + + /** + * @see org.jrimum.domkee.comum.pessoa.PessoaJuridica#setNomeFantasia(java.lang.String) + */ + + public void setNomeFantasia(String nomeFantasia) { + + pessoaJuridica.setNomeFantasia(nomeFantasia); + } + + /** + * @see Pessoa#addContaBancaria(ContaBancaria) + */ + public void addContaBancaria(ContaBancaria contaBancaria) { + pessoaJuridica.addContaBancaria(contaBancaria); + + } + + + /** + * @see Pessoa#getContasBancarias() + */ + + public Collection getContasBancarias() { + + return pessoaJuridica.getContasBancarias(); + } + + /** + * @see Pessoa#hasContaBancaria() + */ + public boolean hasContaBancaria() { + + return pessoaJuridica.hasContaBancaria(); + } + + + /** + * @see org.jrimum.domkee.comum.pessoa.Pessoa#setContasBancarias(java.util.Collection) + */ + + public void setContasBancarias(Collection contasBancarias) { + + pessoaJuridica.setContasBancarias(contasBancarias); + } + + @Override + public String toString() { + + ToStringBuilder tb = new ToStringBuilder(this); + tb.append(codigoDeCompensacaoBACEN); + tb.append(segmento); + tb.append(pessoaJuridica); + + return tb.toString(); + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Carteira.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Carteira.java new file mode 100644 index 0000000..c25ef7a --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Carteira.java @@ -0,0 +1,194 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:57:33 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:57:33 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.jrimum.utilix.Objects; + +/** + * + *

+ * Carteira de Cobrança de uma Conta Corrente. + *

+ * + * + * @author Gilmar P.S.L. + * + * @since 0.2 + * + * @version 0.2 + */ + +public class Carteira { + + /** + * @see #setNome(String) + */ + private String nome; + + /** + * + * + */ + private Integer codigo; + + /** + * @see #setTipoCobranca(TipoDeCobranca) + */ + private TipoDeCobranca tipoDeCobranca; + + /** + * + */ + public Carteira() { + super(); + } + + /** + * @param codigo + */ + public Carteira(Integer codigo) { + super(); + this.codigo = codigo; + } + + + /** + * @param codigo + * @param cobranca + */ + public Carteira(Integer codigo, TipoDeCobranca cobranca) { + super(); + this.codigo = codigo; + this.tipoDeCobranca = cobranca; + } + + + /** + * @param codigo + * @param cobranca + * @param nome + */ + public Carteira(Integer codigo, TipoDeCobranca cobranca, String nome) { + super(); + this.nome = nome; + this.codigo = codigo; + this.tipoDeCobranca = cobranca; + } + + /** + * @see #setNome(String) + * + * @return the nome + */ + public String getNome() { + return nome; + } + + /** + *

+ * Nome da modalidade de cobrança (ou serviços) atribuído a carteira. + *

+ * + * @param nome the nome to set + */ + public void setNome(String nome) { + this.nome = nome; + } + + /** + * @see #setCodigo(Integer) + * + * @return the codigo + */ + public Integer getCodigo() { + return codigo; + } + + /** + *

+ * Código adotado pela FEBRABAN, para identificar a característica dos + * títulos dentro das modalidades de cobrança existentes no banco. + *

+ * + * @param codigo the codigo to set + */ + public void setCodigo(Integer codigo) { + this.codigo = codigo; + } + + /** + * @return the tipoCobranca + */ + public TipoDeCobranca getTipoCobranca() { + return tipoDeCobranca; + } + + + + /** + *

+ * Define o tipo de cobrança da carteira (Registrada ou não-registrada). + *

+ * + * @param cobranca + * + * @since 0.2 + */ + public void setTipoCobranca(TipoDeCobranca cobranca) { + this.tipoDeCobranca = cobranca; + } + + /** + *

+ * Indica se é uma carteira registrada. + *

+ * + * @return true se registrada + */ + public boolean isComRegistro() { + return (this.tipoDeCobranca == TipoDeCobranca.COM_REGISTRO); + } + + /** + *

+ * Indica se é uma carteira não registrada. + *

+ * + * @return true se sem registro + */ + public boolean isSemRegistro() { + return (this.tipoDeCobranca == TipoDeCobranca.SEM_REGISTRO); + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Cedente.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Cedente.java new file mode 100644 index 0000000..78b6fb8 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Cedente.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 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: Jan 28, 2010 - 1:36:56 PM + * + * ================================================================================ + * + * 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. + * + * Criado em: Jan 28, 2010 - 1:36:56 PM + * + */ +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.jrimum.domkee.comum.pessoa.id.cprf.CPRF; + +/** + *

+ * Representa um Cedente no modelo de negócio financeiro, que é + * aquele que realiza a cobrança do título. + *

+ *

+ * Cliente que entrega os títulos ao Banco para serem cobrados. + *

+ * + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ +public class Cedente extends EntidadeDeCobranca { + + public Cedente(String nome) { + super(nome); + } + + public Cedente(String nome, String cadastroDePessoa) { + super(nome, cadastroDePessoa); + } + + public Cedente(String nome, CPRF cadastroDePessoa) { + super(nome, cadastroDePessoa); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/CodigoDeCompensacaoBACEN.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/CodigoDeCompensacaoBACEN.java new file mode 100644 index 0000000..2e9cf68 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/CodigoDeCompensacaoBACEN.java @@ -0,0 +1,130 @@ +/* + * Copyright 2008 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: 15/06/2008 - 16:11:16 + * + * ================================================================================ + * + * 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. + * + * Criado em: 15/06/2008 - 16:11:16 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import static org.jrimum.utilix.text.Strings.fillWithZeroLeft; + +import org.jrimum.utilix.Objects; +import org.jrimum.vallia.digitoverificador.CodigoDeCompensacaoBancosBACENDV; + +/** + *

+ * Código de compensação para bancos supervisionados pelo BACEN + *

+ * + * @author Gilmar P.S.L. + * + * @since 0.2 + * + * @version 0.2 + */ +public class CodigoDeCompensacaoBACEN { + + private static final CodigoDeCompensacaoBancosBACENDV dv4Compensacao = new CodigoDeCompensacaoBancosBACENDV(); + + private Integer codigo; + + private Integer digito; + + /** + * @param codigo + */ + public CodigoDeCompensacaoBACEN(Integer codigo) { + super(); + + setCodigo(codigo); + } + + /** + * @param codigo + */ + public CodigoDeCompensacaoBACEN(String codigo) { + super(); + + setCodigo(codigo); + } + + private void initDV(){ + + if(dv4Compensacao.isCodigoValido(codigo)){ + this.digito = dv4Compensacao.calcule(codigo); + } + } + + /** + * @return the codigo formatado ex: "001" + */ + public String getCodigoFormatado() { + return fillWithZeroLeft(getCodigo(), 3); + } + + /** + * @return the codigo + */ + public Integer getCodigo() { + return codigo; + } + + /** + * @param codigo the codigo to set + */ + public void setCodigo(Integer codigo) { + + if(dv4Compensacao.isCodigoValido(codigo)){ + this.codigo = codigo; + initDV(); + } + } + + /** + * @param codigo the codigo to set + */ + public void setCodigo(String codigo) { + + if(dv4Compensacao.isCodigoValido(codigo)){ + this.codigo = Integer.valueOf(codigo); + initDV(); + } + } + + /** + * @return the digito + */ + public Integer getDigito() { + return digito; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/ContaBancaria.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/ContaBancaria.java new file mode 100644 index 0000000..66eb48c --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/ContaBancaria.java @@ -0,0 +1,200 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:57:59 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:57:59 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import java.util.Collection; + +import org.jrimum.domkee.financeiro.banco.Banco; +import org.jrimum.domkee.financeiro.banco.Pessoa; +import org.jrimum.utilix.Objects; + + +/** + * + *

+ * É um vínculo entre uma Pessoa e um Banco que agrega a agência, o número da conta + * ou o código do cedente e a carteira. + *

+ * + * @author Gilmar P.S.L. + * + * @since 0.2 + * + * @version 0.2 + * + * @see org.jrimum.domkee.comum.pessoa.Pessoa + * @see Banco + */ +public class ContaBancaria { + + /** + * @see Banco + */ + private Banco banco; + + /** + * @see Agencia + */ + private Agencia agencia; + + /** + * @see NumeroDaConta + */ + private NumeroDaConta numeroDaConta; + + /** + * @see Carteira + */ + private Carteira carteira; + + /** + * @see Pessoa + */ + private Collection titulares; + + /** + * @see Titulo + */ + private Collection titulos; + + /** + * @see Modalidade + */ + private Modalidade modalidade; + + + public ContaBancaria() {} + + public ContaBancaria(Banco banco) { + + this.banco = banco; + } + + /** + * @see Carteira + */ + public Carteira getCarteira() { + return carteira; + } + + /** + * @see Carteira + */ + public void setCarteira(Carteira carteira) { + this.carteira = carteira; + } + + /** + * @see Banco + */ + public Banco getBanco() { + return banco; + } + + /** + * @see Banco + */ + public void setBanco(Banco banco) { + this.banco = banco; + } + + /** + * @see Pessoa + * @see Collection + */ + public Collection getTitulares() { + return titulares; + } + + /** + * @see Pessoa + * @see Collection + */ + public void setTitulares(Collection titulares) { + this.titulares = titulares; + } + + /** + * @see Titulo + * @see Collection + */ + public Collection getTitulos() { + return titulos; + } + + /** + * @see Titulo + * @see Collection + */ + public void setTitulos(Collection titulos) { + this.titulos = titulos; + } + + /** + * @see Agencia + */ + public Agencia getAgencia() { + return agencia; + } + + /** + * @see Agencia + */ + public void setAgencia(Agencia agencia) { + this.agencia = agencia; + } + + /** + * @see NumeroDaConta + */ + public NumeroDaConta getNumeroDaConta() { + return numeroDaConta; + } + + /** + * @see NumeroDaConta + */ + public void setNumeroDaConta(NumeroDaConta numeroDaConta) { + this.numeroDaConta = numeroDaConta; + } + + public Modalidade getModalidade() { + return modalidade; + } + + public void setModalidade(Modalidade modalidade) { + this.modalidade = modalidade; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/EntidadeDeCobranca.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/EntidadeDeCobranca.java new file mode 100644 index 0000000..7e2a919 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/EntidadeDeCobranca.java @@ -0,0 +1,195 @@ +/* + * Copyright 2008 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: Jan 28, 2010 - 1:29:53 PM + * + * ================================================================================ + * + * 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. + * + * Criado em: Jan 28, 2010 - 1:29:53 PM + * + */ +package org.jrimum.domkee.financeiro.banco.febraban; + +import java.util.Collection; + +import org.jrimum.domkee.comum.pessoa.contato.NumeroDeTelefone; +import org.jrimum.domkee.comum.pessoa.endereco.Endereco; +import org.jrimum.domkee.comum.pessoa.id.cprf.CPRF; +import org.jrimum.domkee.financeiro.banco.Pessoa; + + +/** + * Supertipo para as entidades de cobrança (Sacado, Cedente, SacadorAvalista). Encapsula + * a composição com o objeto Pessoa deixando apenas as particularidades de cada entidade nos subtipos. + * + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ +public class EntidadeDeCobranca{ + + /** + * Utilizado como composição + */ + private Pessoa pessoa; + + public EntidadeDeCobranca(String nome) { + pessoa = new Pessoa(nome); + } + + public EntidadeDeCobranca(String nome, String cadastroDePessoa) { + pessoa = new Pessoa(nome, cadastroDePessoa); + } + + public EntidadeDeCobranca(String nome, CPRF cadastroDePessoa) { + pessoa = new Pessoa(nome, cadastroDePessoa); + } + + /** + * @return Nome da entidade + */ + public String getNome() { + return pessoa.getNome(); + } + + public void setNome(String nome) { + pessoa.setNome(nome); + } + + /** + * @see CPRF + */ + public CPRF getCPRF() { + return pessoa.getCPRF(); + } + + /** + * @see CPRF + */ + public void setCPRF(CPRF cprf) { + pessoa.setCPRF(cprf); + } + + /** + * @see ContaBancaria + */ + public void addContaBancaria(ContaBancaria contaBancaria) { + pessoa.addContaBancaria(contaBancaria); + } + + /** + * Verifica se esta pessoa tem alguma conta bancária. + * + * @see ContaBancaria + */ + public boolean hasContaBancaria(){ + return pessoa.hasContaBancaria(); + } + + /** + * @return A próxima conta bancária + */ + public ContaBancaria getNextContaBancaria(){ + + return pessoa.getNextContaBancaria(); + } + + /** + * @see ContaBancaria + * @see Collection + */ + public Collection getContasBancarias() { + return pessoa.getContasBancarias(); + } + + /** + * @see ContaBancaria + * @see Collection + */ + public void setContasBancarias(Collection contasBancarias) { + pessoa.setContasBancarias(contasBancarias); + } + + /** + * @see Endereco + */ + public void addEndereco(Endereco endereco) { + pessoa.addEndereco(endereco); + } + + /** + * @return O próximo endereço da entidade. + */ + public Endereco getNextEndereco(){ + + return pessoa.getNextEndereco(); + } + + /** + * @see Endereco + * @see Collection + */ + public Collection getEnderecos() { + return pessoa.getEnderecos(); + } + + /** + * @see Endereco + * @see Collection + */ + public void setEnderecos(Collection enderecos) { + pessoa.setEnderecos(enderecos); + } + + /** + * @see NumeroDeTelefone + */ + public void addTelefone(NumeroDeTelefone telefone) { + pessoa.addTelefone(telefone); + } + + /** + * @return O próximo telefone da entidade. + */ + public NumeroDeTelefone getNextTelefone(){ + + return pessoa.getNextTelefone(); + } + + /** + * @see NumeroDeTelefone + * @see Collection + */ + public Collection getTelefones() { + return pessoa.getTelefones(); + } + + /** + * @see NumeroDeTelefone + * @see Collection + */ + public void setTelefones(Collection telefones) { + pessoa.setTelefones(telefones); + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Modalidade.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Modalidade.java new file mode 100644 index 0000000..305e922 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Modalidade.java @@ -0,0 +1,102 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:59:18 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:59:18 + * + */ + + +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.apache.commons.lang.StringUtils; +import org.jrimum.utilix.Objects; + + +/** + * @author Misael Barreto + * + */ +public class Modalidade { + + private String codigo; + + private String nome; + + public Modalidade() { + } + + public Modalidade(String codigo) { + this.codigo = codigo; + } + + public Modalidade(Integer codigo) { + this.codigo = String.valueOf(codigo); + } + + public Modalidade(String codigo, String nome) { + this.codigo = codigo; + this.nome = nome; + } + + public Modalidade(Integer codigo, String nome) { + this.codigo = String.valueOf(codigo); + this.nome = nome; + } + + public String getCodigo() { + return codigo; + } + + public Integer getCodigoAsInteger() { + + if (StringUtils.isNumeric(codigo)) { + return Integer.parseInt(codigo); + + } else { + return null; + } + } + + public void setCodigo(String codigo) { + this.codigo = codigo; + } + + public void setCodigo(Integer codigo) { + this.codigo = String.valueOf(codigo); + } + + public String getNome() { + return nome; + } + + public void setNome(String nome) { + this.nome = nome; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/NumeroDaConta.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/NumeroDaConta.java new file mode 100644 index 0000000..66e977f --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/NumeroDaConta.java @@ -0,0 +1,94 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:58:07 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:58:07 + * + */ + + +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.jrimum.utilix.Objects; + + +/** + * + *

+ * Identifica uma conta bancária e assume os sinônimos: + *

    + *
  • Código do cedente
  • + *
  • Convênio
  • + *
+ *

+ * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ +public class NumeroDaConta { + + private Integer codigoDaConta = 0; + + private String digitoDaConta = ""; + + public NumeroDaConta() {} + + public NumeroDaConta(Integer codigoDaConta) { + + this.codigoDaConta = codigoDaConta; + } + + public NumeroDaConta(Integer codigoDaConta, String digitoDaConta) { + + this.codigoDaConta = codigoDaConta; + this.digitoDaConta = digitoDaConta; + } + + public Integer getCodigoDaConta() { + return codigoDaConta; + } + + public void setCodigoDaConta(Integer codigoDaConta) { + this.codigoDaConta = codigoDaConta; + } + + public String getDigitoDaConta() { + return digitoDaConta; + } + + public void setDigitoDaConta(String digitoDaConta) { + this.digitoDaConta = digitoDaConta; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Sacado.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Sacado.java new file mode 100644 index 0000000..0c875fb --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Sacado.java @@ -0,0 +1,63 @@ +/* + * Copyright 2008 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: Jan 26, 2010 - 1:27:20 PM + * + * ================================================================================ + * + * 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. + * + * Criado em: Jan 26, 2010 - 1:27:20 PM + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.jrimum.domkee.comum.pessoa.id.cprf.CPRF; + +/** + *

+ * Representa um Sacado no modelo de negócio financeiro, que é + * aquele que emite um título de crédito a favor de alguém. + *

+ *

+ * Pessoa física ou jurídica a que se destina a cobrança do compromisso, é o cliente do Cedente. + *

+ * + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ +public class Sacado extends EntidadeDeCobranca { + + public Sacado(String nome) { + super(nome); + } + + public Sacado(String nome, String cadastroDePessoa) { + super(nome, cadastroDePessoa); + } + + public Sacado(String nome, CPRF cadastroDePessoa) { + super(nome, cadastroDePessoa); + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/SacadorAvalista.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/SacadorAvalista.java new file mode 100644 index 0000000..f95755e --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/SacadorAvalista.java @@ -0,0 +1,62 @@ +/* + * Copyright 2008 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: Jan 28, 2010 - 1:43:30 PM + * + * ================================================================================ + * + * 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. + * + * Criado em: Jan 28, 2010 - 1:43:30 PM + * + */ +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.jrimum.domkee.comum.pessoa.id.cprf.CPRF; + +/** + *

+ * Representa um Sacador Avalista no modelo de negócio financeiro, que é o co-responsável + * pelo título emitido pelo avalizado (Sacado), ou seja, caso a dívida não seja liquidada pelo Sacado, + * cabe ao Sacador Avalista liquidá-la. + *

+ *

+ * Cedente original do Título. + *

+ * + * @author Rômulo Augusto + * + * @since 0.2 + * + * @version 0.2 + */ +public class SacadorAvalista extends EntidadeDeCobranca { + + public SacadorAvalista(String nome) { + super(nome); + } + + public SacadorAvalista(String nome, String cadastroDePessoa) { + super(nome, cadastroDePessoa); + } + + public SacadorAvalista(String nome, CPRF cadastroDePessoa) { + super(nome, cadastroDePessoa); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeCobranca.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeCobranca.java new file mode 100644 index 0000000..490f586 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeCobranca.java @@ -0,0 +1,66 @@ + +/* + * Copyright 2008 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: 19/04/2008 - 21:12:40 + * + * ================================================================================ + * + * 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. + * + * Criado em: 19/04/2008 - 21:12:40 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + + + +/** + * + *

+ * Representação dos tipos básicos de cobrança:
+ *

    + *
  • Registrada (ou com registro)
  • + *
  • Não Registrada (ou sem registro)
  • + *
+ *

+ * + * + * @author Gilmar P.S.L. + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério Valerio + * + * @since 0.2 + * + * @version 0.2 + */ + +public enum TipoDeCobranca{ + /** + *

Tipo onde os títulos emitidos são sempre registrados no banco antes de seu vencimento ou pagamento.

+ */ + COM_REGISTRO, + /** + *

Tipo onde os títulos emitidos só são registrados pelo banco quando são pagos.

+ */ + SEM_REGISTRO; +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeMoeda.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeMoeda.java new file mode 100644 index 0000000..5add3e6 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeMoeda.java @@ -0,0 +1,100 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:08:53 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:08:53 + * + */ + + +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.apache.commons.lang.StringUtils; + +/** + *

+ * Representa as moedas existentes que fazem parte do universo de um título, segundo a FEBRABAN. + *

+ * + * + * @author Gilmar P.S.L + * @author Misael Barreto + * @author Rômulo Augusto + * @author Nordeste Fomento Mercantil + * + * @since 0.2 + * + * @version 0.2 + */ +public enum TipoDeMoeda { + + /** + * Padrão FEBRABAN + */ + + DOLAR_AMERICANO_COMERCIAL_VENDA(2), + DOLAR_AMERICANO_TURISMO_VENDA(3), + ITRD(4), + IDTR(5), + UFIR_DIARIA(6), + UFIR_MENSAL(7), + FAJ_TR(8), + REAL(9), + TR(10), + IGPM(11), + CDI(12), + PERCENTUAL_DO_CDI(13), + EURO(14); + + private int codigo; + + /** + * @param codigo + */ + private TipoDeMoeda(int codigo) { + this.codigo = codigo; + } + + public int getCodigo() { + + return this.codigo; + } + + public String write(){ + + String s = StringUtils.EMPTY; + + switch (this) { + + case REAL: + s = "R$"; + break; + + default: + s += this.getCodigo(); + } + + return s; + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeTitulo.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeTitulo.java new file mode 100644 index 0000000..b27e900 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/TipoDeTitulo.java @@ -0,0 +1,228 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:09:13 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:09:13 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import static java.lang.String.format; + +import org.jrimum.utilix.Exceptions; + +/** + * + *

+ * Enumeração de códigos adotados pela FEBRABAN para identificar o tipo de + * título de cobrança. Domínio: + *

+ * + *

+ * + *

    + *
  • '01' = CH Cheque
  • + *
  • '02' = DM Duplicata Mercantil
  • + *
  • '03' = DMI Duplicata Mercantil p/ Indicação
  • + *
  • '04' = DS Duplicata de Serviço
  • + *
  • '05' = DSI Duplicata de Serviço p/ Indicação
  • + *
  • '06' = DR Duplicata Rural
  • + *
  • '07' = LC Letra de Câmbio
  • + *
  • '08' = NCC Nota de Crédito Comercial
  • + *
  • '09' = NCE Nota de Crédito a Exportação
  • + *
  • '10' = NCI Nota de Crédito Industrial
  • + *
  • '11' = NCR Nota de Crédito Rural
  • + *
  • '12' = NP Nota Promissória
  • + *
  • '13' = NPR Nota Promissória Rural
  • + *
  • '14' = TM Triplicata Mercantil
  • + *
  • '15' = TS Triplicata de Serviço
  • + *
  • '16' = NS Nota de Seguro
  • + *
  • '17' = RC Recibo
  • + *
  • '18' = FAT Fatura
  • + *
  • '19' = ND Nota de Débito
  • + *
  • '20' = AP Apólice de Seguro
  • + *
  • '21' = ME Mensalidade Escolar
  • + *
  • '22' = PC Parcela de Consórcio
  • + *
  • '23' = NF Nota Fiscal
  • + *
  • '24' = DD Documento de Dívida
  • + *
  • ‘25’ = Cédula de Produto Rural
  • + *
  • ‘26’ = Warrant
  • + *
  • ‘27’ = Dívida Ativa de Estado
  • + *
  • ‘28’ = Dívida Ativa de Município
  • + *
  • ‘29’ = Dívida Ativa da União
  • + *
  • ‘30’ = Cota Condominial
  • + *
  • '99' = Outros
  • + *
+ *

+ * + * + * @author Gilmar P.S.L + * @author Misael Barreto + * @author Rômulo Augusto + * @author Samuel Valério + * + * @since 0.2 + * + * @version 0.2 + */ + +public enum TipoDeTitulo{ + + CH_CHEQUE(1,"CH"), + DM_DUPLICATA_MERCANTIL(2,"DM"), + DMI_DUPLICATA_MERCANTIL_PARA_INDICACAO(3,"DMI"), + DS_DUPLICATA_DE_SERVICO(4,"DS"), + DSI_DUPLICATA_DE_SERVICO_PARA_INDICACAO(5,"DSI"), + DR_DUPLICATA_RURAL(6,"DR"), + LC_LETRA_DE_CAMBIO(7,"LC"), + NCC_NOTA_DE_CREDITO_COMERCIAL(8,"NCC"), + NCE_NOTA_DE_CREDITO_A_EXPORTACAO(9,"NCE"), + NCI_NOTA_DE_CREDITO_INDUSTRIAL(10,"NCI"), + NCR_NOTA_DE_CREDITO_RURAL(11,"NCR"), + NP_NOTA_PROMISSORIA(12,"NP"), + NPR_NOTA_PROMISSORIA_RURAL(13,"NPR"), + TM_TRIPLICATA_MERCANTIL(14,"TM"), + TS_TRIPLICATA_DE_SERVICO(15,"TS"), + NS_NOTA_DE_SEGURO(16,"NS"), + RC_RECIBO(17,"RC"), + FAT_FATURA(18,"FAT"), + ND_NOTA_DE_DEBITO(19,"ND"), + AP_APOLICE_DE_SEGURO(20,"AP"), + ME_MENSALIDADE_ESCOLAR(21,"ME"), + PC_PARCELA_DE_CONSORCIO(22,"PC"), + NF_NOTA_FISCAL(23,"NF"), + DD_DOCUMENTO_DE_DIVIDA(24,"DD"), + CEDULA_DE_PRODUTO_RURAL(25,"CPR"), + WARRANT(26,"W"), + DIVIDA_ATIVA_DE_ESTADO(27,"DAE"), + DIVIDA_ATIVA_DE_MUNICIPIO(28,"DAM"), + DIVIDA_ATIVA_DA_UNIAO(29,"DAU"), + COTA_CONDOMINIAL(30,"CC"), + OUTROS(99,"O"); + + /** + *

+ * Código adotado pela FEBRABAN para identificar o tipo de título de + * cobrança. + *

+ */ + private int codigo; + + /** + *

+ * Sigla ou nome compelto de um tipo de título de cobrança. + *

+ */ + private String sigla; + + + /** + *

+ * Instancia os tipos de a cordo com os valores passados. + *

+ * + * @param codigo + * @param sigla + * + * @since 0.2 + */ + private TipoDeTitulo(int codigo, String sigla) { + this.codigo = codigo; + this.sigla = sigla; + } + + /** + *

+ * Apesar do nome, este método pode retornar não uma sigla, e sim, um nome + * compelto de uma espécie de título de cobrança. Isto se justifica pelo + * fato de que não há uma sigla determinada pela FEBRABAN para alguns casos. + *

+ * + * @return sigla ou descrição completa. + * + * @since 0.2 + */ + public String getSigla(){ + + return sigla; + } + + /** + *

+ * Código adotado pela FEBRABAN para identificar o tipo de título de + * cobrança. + *

+ * + * @return código FEBRABAN + * + * @since 0.2 + */ + public int getCodigo() { + + return codigo; + } + + /** + * Retorna uma instância que corresponde com a sigla do tipo de título. + * Caso não exista um tipo associado a sigla determinada uma {@code + * IllegalArgumentException} será lançada. + * + * @param sigla + * - Sigla do tipo de título procurado + * @return tipo de título correspondente a sigla + * + * @since 0.2 + */ + public static TipoDeTitulo valueOfSigla(String sigla){ + for(TipoDeTitulo t : values()){ + if(t.getSigla().equals(sigla)){ + return t; + } + } + return Exceptions.throwIllegalArgumentException(format("Nenhuma constante enum %s com sigla igual a %s!", TipoDeTitulo.class, sigla)); + } + + /** + * Retorna uma instância que corresponde com o código do tipo de título. + * Caso não exista um tipo associado ao código determinado uma {@code + * IllegalArgumentException} será lançada. + * + * @param codigo + * - Código do tipo de título procurado + * @return tipo de título correspondente ao código + * + * @since 0.2 + */ + public static TipoDeTitulo valueOf(int codigo){ + for(TipoDeTitulo t : values()){ + if(t.getCodigo() == codigo){ + return t; + } + } + return Exceptions.throwIllegalArgumentException(format("Nenhuma constante enum %s com código igual a %s!", TipoDeTitulo.class, codigo)); + } + +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Titulo.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Titulo.java new file mode 100644 index 0000000..030a748 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/Titulo.java @@ -0,0 +1,779 @@ +/* + * Copyright 2008 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: 30/03/2008 - 18:58:42 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 18:58:42 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import static org.jrimum.utilix.Objects.isNotNull; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; + +import org.jrimum.domkee.financeiro.banco.ParametroBancario; +import org.jrimum.domkee.financeiro.banco.ParametrosBancariosMap; +import org.jrimum.utilix.Exceptions; +import org.jrimum.utilix.Objects; + + +/** + * Representa um título em cobrança, tais como: + * + *
+ * + *
    + *
  • Cheque
  • + *
  • Duplicata Mercantil
  • + *
  • Duplicata de Serviço
  • + *
  • Duplicata Rural
  • + *
  • Letra de Câmbio
  • + *
  • Nota de Crédito Comercial
  • + *
  • Nota de Crédito Industrial
  • + *
  • Nota de Crédito Rural
  • + *
  • E outras espécies pagáveis através da rede bancária.
  • + * + * @see TipoDeTitulo + * + * + * @author Gilmar P.S.L + * @author Misael Barreto + * @author Rômulo Augusto + * @author Nordeste Fomento + * Mercantil + * + * @since 0.2 + * + * @version 0.2 + */ +public class Titulo { + + /** + * @see #setNumeroDoDocumento(String) + */ + private String numeroDoDocumento; + + /** + * @see #setDataDoDocumento(Date) + */ + private Date dataDoDocumento; + + /** + * @see #setDataDoVencimento(Date) + */ + private Date dataDoVencimento; + + /** + * @see org.jrimum.domkee.financeiro.banco.febraban.TipoDeMoeda + */ + private TipoDeMoeda tipoDeMoeda = TipoDeMoeda.REAL; + + /** + * @see #setValor(BigDecimal) + */ + private BigDecimal valor; + + /** + * @see #setDesconto(BigDecimal) + */ + private BigDecimal desconto; + + /** + * @see #setMora(BigDecimal) + */ + private BigDecimal mora; + + /** + * @see #setDeducao(BigDecimal) + */ + private BigDecimal deducao; + + /** + * @see #setAcrecimo(BigDecimal) + */ + private BigDecimal acrecimo; + + /** + * @see #setValorCobrado(BigDecimal) + */ + private BigDecimal valorCobrado; + + /** + * @see org.jrimum.domkee.financeiro.banco.febraban.TipoDeTitulo + */ + private TipoDeTitulo tipoDeDocumento; + + /** + * @see #setNossoNumero(String) + */ + private String nossoNumero; + + /** + * @see #setDigitoDoNossoNumero(String) + */ + private String digitoDoNossoNumero; + + /** + * @see #setContaBancaria(ContaBancaria) + */ + private ContaBancaria contaBancaria; + + /** + * @see #setCedente(Cedente) + */ + private Cedente cedente; + + /** + * @see #setSacado(Sacado) + */ + private Sacado sacado; + + /** + * @see #setSacadorAvalista(SacadorAvalista) + */ + private SacadorAvalista sacadorAvalista; + + /** + * @see #setParametrosBancarios(ParametrosBancariosMap) + */ + private ParametrosBancariosMap parametrosBancariosMap; + + /** + *

    + * Identificação de Título Aceito / Não Aceito Código adotado pela FEBRABAN + * para identificar se o título de cobrança foi aceito (reconhecimento da + * dívida pelo Sacado). Domínio: + *

    + *
      + *
    • 'A' = Aceite
    • + *
    • 'N' = Não Aceite
    • + *
    + * + * @since 0.2 + * + * @version 0.2 + */ + public enum Aceite { + /** + * 'A' = Título Aceite. + */ + A, + /** + * 'N' = Título Não Aceite. + */ + N; + } + + /** + * @see #setAceite(org.jrimum.domkee.financeiro.banco.febraban.Titulo.Aceite) + * + * @see Aceite + */ + private Aceite aceite; + + /** + *

    + * Cria uma instância de título. + *

    + * + * @param contaBancaria + * @param sacado + * @param cedente + * + */ + public Titulo(ContaBancaria contaBancaria, Sacado sacado, Cedente cedente) { + this.setContaBancaria(contaBancaria); + this.setSacado(sacado); + this.setCedente(cedente); + } + + /** + *

    + * Cria uma instância de título com sacador avalista. + *

    + * + * @param contaBancaria + * @param sacado + * @param cedente + * @param sacadorAvalista + * + */ + public Titulo(ContaBancaria contaBancaria, Sacado sacado, Cedente cedente, SacadorAvalista sacadorAvalista) { + this(contaBancaria, sacado, cedente); + this.setSacadorAvalista(sacadorAvalista); + } + + /** + *

    + * Cria uma instância de título acrescentado outros dados bancários ao + * mesmo. + *

    + * + * @param contaBancaria + * @param sacado + * @param cedente + * @param parametrosBancariosMap + * + */ + public Titulo(ContaBancaria contaBancaria, Sacado sacado, Cedente cedente, + ParametrosBancariosMap parametrosBancariosMap) { + this.setContaBancaria(contaBancaria); + this.setSacado(sacado); + this.setCedente(cedente); + this.setParametrosBancarios(parametrosBancariosMap); + } + + /** + *

    + * Cria uma instância de título com sacador avalista e acrescentado outros + * dados bancários além do título. + *

    + * + * @param contaBancaria + * @param sacado + * @param cedente + * @param parametrosBancariosMap + * @param sacadorAvalista + * + */ + public Titulo(ContaBancaria contaBancaria, Sacado sacado, Cedente cedente, + ParametrosBancariosMap parametrosBancariosMap, SacadorAvalista sacadorAvalista) { + this(contaBancaria, sacado, cedente, parametrosBancariosMap); + this.setSacadorAvalista(sacadorAvalista); + } + + /** + *

    + * Indica se o título possuem sacador avalista na instância + *

    + * + * @return true se tem + */ + public boolean hasSacadorAvalista() { + + boolean has = false; + + if (isNotNull(this.sacadorAvalista)) { + has = true; + } + + return has; + } + + /** + * @see #setAceite(org.jrimum.domkee.financeiro.banco.febraban.Titulo.Aceite) + * + * @return the aceite + */ + public Aceite getAceite() { + return aceite; + } + + /** + *

    + * Indicação de aceite. + *

    + * + * @param aceite + * the aceite to set + */ + public void setAceite(Aceite aceite) { + this.aceite = aceite; + } + + /** + * @see #setDataDoDocumento(Date) + * + * @return the dataDoDocumento + */ + public Date getDataDoDocumento() { + return dataDoDocumento; + } + + /** + *

    + * Data de emissão do documento. + *

    + * + * @param dataDoDocumento + * the dataDoDocumento to set + */ + public void setDataDoDocumento(Date dataDoDocumento) { + this.dataDoDocumento = dataDoDocumento; + } + + /** + * @see #setDataDoVencimento(Date) + * + * @return the dataDoVencimento + */ + public Date getDataDoVencimento() { + return dataDoVencimento; + } + + /** + *

    + * Data de vencimento nominal do título de cobrança, ou melhor, data limite + * para pagamento do título. + *

    + * + * @param dataDoVencimento + * the dataDoVencimento to set + */ + public void setDataDoVencimento(Date dataDoVencimento) { + this.dataDoVencimento = dataDoVencimento; + } + + /** + * @see #setDigitoDoNossoNumero(String) + * + * @return the dígitoDoNossoNúmero + */ + public String getDigitoDoNossoNumero() { + return digitoDoNossoNumero; + } + + /** + *

    + * Dígito verificador do nosso número, caso exista. + *

    + * + * @param digitoDoNossoNumero + * the dígitoDoNossoNúmero to set + */ + public void setDigitoDoNossoNumero(String digitoDoNossoNumero) { + this.digitoDoNossoNumero = digitoDoNossoNumero; + } + + /** + * @see org.jrimum.domkee.financeiro.banco.febraban.TipoDeMoeda + * + * @return the enumMoeda + */ + public TipoDeMoeda getTipoDeMoeda() { + return tipoDeMoeda; + } + + /** + * @see org.jrimum.domkee.financeiro.banco.febraban.TipoDeMoeda + * + * @param tipoDeMoeda + * the enumMoeda to set + */ + public void setTipoDeMoeda(TipoDeMoeda tipoDeMoeda) { + this.tipoDeMoeda = tipoDeMoeda; + } + + /** + * @see #setNossoNumero(String) + * + * @return the nossoNúmero + */ + public String getNossoNumero() { + return nossoNumero; + } + + /** + *

    + * Código fornecido pelo Banco correspondente para identificação do título + * ou identificação do título atribuído pelo esmissor do título de cobrança. + *

    + * + * @param nossoNumero + * the nossoNúmero to set + */ + public void setNossoNumero(String nossoNumero) { + this.nossoNumero = nossoNumero; + } + + /** + * @see #setNumeroDoDocumento(String) + * + * @return the númeroDoDocumento + */ + public String getNumeroDoDocumento() { + return numeroDoDocumento; + } + + /** + *

    + * Número de controle do cedente para o referido título. Não confundir com o + * nosso número. + *

    + * + * @param numeroDoDocumento + * the númeroDoDocumento to set + */ + public void setNumeroDoDocumento(String numeroDoDocumento) { + this.numeroDoDocumento = numeroDoDocumento; + } + + /** + * @see #setContaBancaria(ContaBancaria) + * + * @return the contaBancaria + */ + public ContaBancaria getContaBancaria() { + return contaBancaria; + } + + /** + *

    + * Conta na qual o título se encontra, conta do favorecido (Cedente). + *

    + * + * @param contaBancaria + * the contaBancaria to set + */ + public void setContaBancaria(ContaBancaria contaBancaria) { + + if (isNotNull(contaBancaria)) { + this.contaBancaria = contaBancaria; + } else { + Exceptions.throwIllegalArgumentException("ContaBancaria não pode ser nula!"); + } + } + + /** + * @see #setCedente(Cedente) + * + * @return the cedente + */ + public Cedente getCedente() { + return cedente; + } + + /** + *

    + * Cliente que entrega os títulos ao Banco para serem cobrados. + *

    + * + * @param cedente + * the cedente to set + */ + public void setCedente(Cedente cedente) { + if (isNotNull(cedente)) { + this.cedente = cedente; + } else { + Exceptions.throwIllegalArgumentException("Cedente não pode ser nulo!"); + } + } + + /** + * @see #setSacado(Sacado) + * + * @return the sacado + */ + public Sacado getSacado() { + return sacado; + } + + /** + *

    + * Pessoa física ou jurídica a que se destina a cobrança do compromisso, é o + * cliente do Cedente. + *

    + * + * @param sacado + * the sacado to set + */ + public void setSacado(Sacado sacado) { + if (isNotNull(sacado)) { + this.sacado = sacado; + } else { + Exceptions.throwIllegalArgumentException("Sacado não pode ser nulo!"); + } + } + + /** + * @see #setSacadorAvalista(SacadorAvalista) + * + * @return the sacadorAvalista + */ + public SacadorAvalista getSacadorAvalista() { + return sacadorAvalista; + } + + /** + *

    + * Cedente original do Título. + *

    + * + * @param sacadorAvalista + * the sacadorAvalista to set + */ + public void setSacadorAvalista(SacadorAvalista sacadorAvalista) { + if (isNotNull(sacadorAvalista)) { + this.sacadorAvalista = sacadorAvalista; + } else { + Exceptions.throwIllegalArgumentException("SacadorAvalista não pode ser nulo!"); + } + } + + /** + * @return the tipoDeDocumento + */ + public TipoDeTitulo getTipoDeDocumento() { + return tipoDeDocumento; + } + + /** + * @param tipoDeDocumento + * the tipoDeDocumento to set + */ + public void setTipoDeDocumento(TipoDeTitulo tipoDeDocumento) { + this.tipoDeDocumento = tipoDeDocumento; + } + + /** + * @see #setValor(BigDecimal) + * + * @return the valor + */ + public BigDecimal getValor() { + return valor; + } + + /** + *

    + * Atribui um valor (original do Título) expresso em moeda corrente e + * arredondanda em duas casas decimais para baixo. + *

    + *

    + * Exemplo: Para o valor 12,349 ele definirá o valor para 12,34. + *

    + * + * @param valor + * the valor to set + */ + public void setValor(BigDecimal valor) { + valor = valor.setScale(2, RoundingMode.DOWN); + this.valor = valor; + } + + /** + * @see #setDesconto(BigDecimal) + * + * @return the desconto + */ + public BigDecimal getDesconto() { + return desconto; + } + + /** + *

    + * Atribui um valor de descontos/abatimentos ao valor original do título expresso em + * moeda corrente e arredondanda em duas casas decimais para baixo. + *

    + *

    + * Exemplo: Para o valor 12,349 ele definirá o valor para 12,34. + *

    + * + * @param desconto + * the desconto to set + */ + public void setDesconto(BigDecimal desconto) { + + if (desconto != null) { + desconto = desconto.setScale(2, RoundingMode.DOWN); + } + this.desconto = desconto; + } + + /** + * @see #setMora(BigDecimal) + * + * @return the mora + */ + public BigDecimal getMora() { + return mora; + } + + /** + *

    + * Atribui um valor de mora/multa ao título expresso em moeda corrente e + * arredondanda em duas casas decimais para baixo. + *

    + *

    + * Exemplo: Para o valor 12,349 ele definirá o valor para 12,34. + *

    + * + * @param mora + */ + public void setMora(BigDecimal mora) { + if (mora != null) { + mora = mora.setScale(2, RoundingMode.DOWN); + } + this.mora = mora; + } + + /** + * @see #setDeducao(BigDecimal) + * + * @return the deducao + */ + public BigDecimal getDeducao() { + return deducao; + } + + /** + *

    + * Atribui um valor para outras deduções ao título expresso em moeda + * corrente e arredondanda em duas casas decimais para baixo. + *

    + *

    + * Exemplo: Para o valor 12,349 ele definirá o valor para 12,34. + *

    + * + * @param deducao + */ + public void setDeducao(BigDecimal deducao) { + if (deducao != null) { + deducao = deducao.setScale(2, RoundingMode.DOWN); + } + this.deducao = deducao; + } + + /** + * @see #setAcrecimo(BigDecimal) + * + * @return the acrecimo + */ + public BigDecimal getAcrecimo() { + + return acrecimo; + } + + /** + *

    + * Atribui um valor para outros acrécimos ao título expresso em moeda + * corrente e arredondanda em duas casas decimais para baixo. + *

    + *

    + * Exemplo: Para o valor 12,349 ele definirá o valor para 12,34. + *

    + * + * @param acrecimo + */ + public void setAcrecimo(BigDecimal acrecimo) { + if (acrecimo != null) { + acrecimo = acrecimo.setScale(2, RoundingMode.DOWN); + } + this.acrecimo = acrecimo; + } + + /** + * @see #setValorCobrado(BigDecimal) + * + * @return the valorCobrado + */ + public BigDecimal getValorCobrado() { + return valorCobrado; + } + + /** + *

    + * Atribui um "valor cobrardo" ao título expresso em moeda corrente e + * arredondanda em duas casas decimais para baixo. + *

    + *

    + * Exemplo: Para o valor 12,349 ele definirá o valor para 12,34. + *

    + * + *

    + * Note que o valor cobrado não é o valor de face do título e sim um valor + * resultante de deduções ou acrécimos. + *

    + * + * @param valorCobrado + */ + public void setValorCobrado(BigDecimal valorCobrado) { + if (valorCobrado != null) { + valorCobrado = valorCobrado.setScale(2, RoundingMode.DOWN); + } + this.valorCobrado = valorCobrado; + } + + /** + *

    + * Indica se existe parâmetros bancários no título. + *

    + * + * @return parametrosBancarios + * + * @see #getParametrosBancarios() + * + * @since 0.2 + */ + + public boolean hasParametrosBancarios() { + return ParametrosBancariosMap.hasElement(getParametrosBancarios()); + } + + /** + *

    + * Retorna os parâmetros bancários usados no título. + *

    + * + * @return parametrosBancarios + * + * @see #setParametrosBancarios(ParametrosBancariosMap) + * + * @since 0.2 + */ + public ParametrosBancariosMap getParametrosBancarios() { + return parametrosBancariosMap; + } + + /** + *

    + * Atribui Parâmetros bancários necessários ao título. + *

    + * + *

    + * Em alguns casos, talvez seja necessário utilizar este campo para fornecer + * mais informações a um título. Seja para simplesmente gerar um boleto ou + * quando se desejar implementar um campo livre ou banco ainda não + * suportado. + *

    + * + * @see org.jrimum.domkee.financeiro.banco.ParametrosBancariosMap + * + * @param parametrosBancariosMap + * + * @since 0.2 + */ + + public

    > void setParametrosBancarios(ParametrosBancariosMap parametrosBancariosMap) { + this.parametrosBancariosMap = parametrosBancariosMap; + } + + @Override + public String toString() { + return Objects.toString(this); + } +} diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/package-info.java new file mode 100644 index 0000000..6325b22 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/febraban/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.financeiro.banco.febraban; \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/TipoIdentificadorCNR.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/TipoIdentificadorCNR.java new file mode 100644 index 0000000..5bed144 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/TipoIdentificadorCNR.java @@ -0,0 +1,132 @@ +/* + * 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. + * + * Created at: 14/02/2010 - 15:00:00 + * + * ================================================================================ + * + * 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. + * + * Criado em: 14/02/2010 - 15:00:00 + * + */ + +package org.jrimum.domkee.financeiro.banco.hsbc; + +import static java.lang.String.format; + +import org.jrimum.utilix.Exceptions; + +/** + * + *

    + * Tipo do identificador do nosso número utilizado nos títulos de boletos + * bancários de Cobrança Não Registrada (CNR). + *

    + * + *

    + * Basicamente são dois os tipos de nosso número (NN): + *

    + * + *
      + *
    • O que vincula “vencimento”, “código do cedente” e “código do documento”. + * Enumerado como {@link #COM_VENCIMENTO } (constante 4);
    • + *
    • O que vincula “código do cedente” e “código do documento”. Enumerado como + * {@link #SEM_VENCIMENTO } (constante 5).
    • + *
    + * + *

    + * OBS: vale lembrar que é o tipo do identificador que + * determina se o boleto HSBC CNR tem vencimento ou se é do tipo com vencimento + * “À Vista” ou “Contra Apresentação”. + *

    + * + * @author Gilmar P.S.L. + * + * @since 0.2 + * + * @version 0.2 + */ + +public enum TipoIdentificadorCNR { + + /** + * Identificador do "tipo 4" que vincula “vencimento”, + * “código do cedente” e “código do documento”. + * + * @since 0.2 + */ + COM_VENCIMENTO { + /** + * @see org.jrimum.domkee.financeiro.banco.hsbc.TipoIdentificadorCNR#getConstante() + */ + @Override + public int getConstante() { + return VALOR_COM_VENCIMENTO; + } + }, + + /** + * Identificador do "tipo 5" que vincula “código do + * cedente” e “código do documento”. + * + * @since 0.2 + */ + SEM_VENCIMENTO { + /** + * @see org.jrimum.domkee.financeiro.banco.hsbc.TipoIdentificadorCNR#getConstante() + */ + @Override + public int getConstante() { + return VALOR_SEM_VENCIMENTO; + } + }; + + private static final int VALOR_SEM_VENCIMENTO = 5; + private static final int VALOR_COM_VENCIMENTO = 4; + + /** + *

    + * Retorna a constante numérica bancária do tipo (4 ou 5) + *

    + * + * @return constante do tipo (4 ou 5) + * + * @since 0.2 + */ + public abstract int getConstante(); + + + public static TipoIdentificadorCNR valueOf(int valor) { + switch (valor) { + + case VALOR_SEM_VENCIMENTO: + + return SEM_VENCIMENTO; + + case VALOR_COM_VENCIMENTO: + + return COM_VENCIMENTO; + + default: + return Exceptions.throwIllegalStateException(format( + "Tipo de identificador CNR \"%d\" desconhecido!", valor)); + } + } +} \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/package-info.java new file mode 100644 index 0000000..16c9908 --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/hsbc/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.financeiro.banco.hsbc; \ No newline at end of file diff --git a/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/package-info.java b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/package-info.java new file mode 100644 index 0000000..390956e --- /dev/null +++ b/jrimum-domkee/src/main/java/org/jrimum/domkee/financeiro/banco/package-info.java @@ -0,0 +1,33 @@ +/* + * 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. + * + * Created at: 15/08/2010 - 15:37:49 + * + * ================================================================================ + * + * Direitos autorais 2010 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: 15/08/2010 - 15:37:49 + * + */ + +/** + * @author Gilmar P.S.L + */ +package org.jrimum.domkee.financeiro.banco; \ No newline at end of file diff --git a/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestAbstractCPRF.java b/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestAbstractCPRF.java new file mode 100644 index 0000000..b278b71 --- /dev/null +++ b/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestAbstractCPRF.java @@ -0,0 +1,346 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:11:04 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:11:04 + * + */ + + +package org.jrimum.domkee.comum.pessoa.id.cprf; + +import static org.jrimum.utilix.text.Strings.fillWithZeroLeft; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.jrimum.vallia.AbstractCPRFValidator.TipoDeCPRF; +import org.junit.Test; + + +/** + * Teste da classe {@linkplain AbstractCPRF} e base para as sublcasses {@linkplain CPF} e {@linkplain CNPJ}. + * + * @author Gilmar P.S.L. + * + * @since 0.2 + * + * @version 0.2 + */ +public abstract class TestAbstractCPRF{ + + private TipoDeCPRF tipo; + private String cprfStringFormatada; + private String cprfStringFormatadaErr; + private String cprfString; + private String cprfStringErr; + private Long cprfLong; + private Long cprfLongErr; + private Long cprfRaizLong; + private Long cprfRaizLongErr; + private String cprfRaizFormatada; + private String cprfRaizFormatadaErr; + private Integer cprfDv; + private Integer cprfDvErr; + + private CPRF cprf; + private CPRF cprfOutro; + + @Test + public final void testCreateLongTipoDeCPRF() { + assertNotNull(AbstractCPRF.create(cprfLong, tipo)); + } + + @Test(expected=IllegalArgumentException.class) + public final void testDoNotCreateLongTipoDeCPRF() { + assertNotNull(AbstractCPRF.create(cprfLongErr, tipo)); + } + + @Test + public void testCreateStringTipoDeCPRF() { + assertNotNull(AbstractCPRF.create(cprfString, tipo)); + } + + @Test(expected=IllegalArgumentException.class) + public void testDoNotCreateStringTipoDeCPRF() { + assertNotNull(AbstractCPRF.create(cprfStringErr, tipo)); + } + + @Test(expected=IllegalArgumentException.class) + public void testDoNotCreateStringFormatadaTipoDeCPRF() { + assertNotNull(AbstractCPRF.create(cprfStringFormatada, tipo)); + } + + @Test + public void testCreateString() { + assertNotNull(AbstractCPRF.create(cprfString)); + } + + @Test(expected=IllegalArgumentException.class) + public void testDoNotCreateString() { + assertNotNull(AbstractCPRF.create(cprfStringErr)); + } + + @Test + public void testCreateStringFormatada() { + assertNotNull(AbstractCPRF.create(cprfStringFormatada)); + } + + @Test(expected=IllegalArgumentException.class) + public void testDoNotCreateStringFormatada() { + assertNotNull(AbstractCPRF.create(cprfStringFormatadaErr)); + } + + @Test + public void testIsFisica() { + assertTipo(); + } + + @Test + public void testIsJuridica() { + assertTipo(); + } + + @Test + public void testGetCodigo() { + assertEquals(cprfLong, cprf.getCodigo()); + } + + @Test + public void testGetCodigoComZeros() { + + int tamanho = -1; + + if(cprf.isFisica()){ + tamanho = 11; + }else{ + tamanho = 14; + } + + assertEquals(fillWithZeroLeft(cprfLong, tamanho), cprf.getCodigoComZeros()); + assertTrue(!cprf.getCodigoComZeros().equals(fillWithZeroLeft(cprfLongErr, tamanho))); + } + + @Test + public void testGetCodigoFormatado() { + assertEquals(cprfStringFormatada, cprf.getCodigoFormatado()); + assertTrue(!cprf.getCodigoFormatado().equals(cprfStringFormatadaErr)); + } + + @Test + public void testGetRaiz() { + assertEquals(cprfRaizLong, cprf.getRaiz()); + assertTrue(cprf.getRaiz().longValue() == cprfRaizLong.longValue()); + assertTrue(!cprf.getRaiz().equals(cprfLongErr)); + } + + @Test + public void testGetRaizComZeros() { + + int tamanho = -1; + + if(cprf.isFisica()){ + tamanho = 9; + }else{ + tamanho = 8; + } + + assertEquals(fillWithZeroLeft(cprfRaizLong, tamanho), cprf.getRaizComZeros()); + assertTrue(!cprf.getRaizComZeros().equals(fillWithZeroLeft(cprfRaizLongErr,tamanho))); + } + + @Test + public void testGetRaizFormatada() { + assertEquals(cprfRaizFormatada, cprf.getRaizFormatada()); + assertTrue(!cprf.getRaizComZeros().equals(cprfRaizFormatadaErr)); + } + + @Test + public void testGetDv() { + assertEquals(cprfDv, cprf.getDv()); + assertTrue(!cprf.getDv().equals(cprfDvErr)); + } + + @Test + public void testGetDvComZeros() { + assertEquals(fillWithZeroLeft(cprf.getDv(),2), cprf.getDvComZeros()); + assertTrue(!cprf.getDvComZeros().equals(fillWithZeroLeft(cprfDvErr,2))); + } + + @Test + public void testCompareTo() { + int c1 = this.cprf.compareTo(this.cprfOutro); + int c2 = this.cprfOutro.compareTo(this.cprf); + assertTrue(c1 != c2); + assertTrue(cprf.compareTo(AbstractCPRF.create(cprf.getCodigoFormatado())) == 0); + } + + @Test + public void testEqualsObject() { + assertEquals(cprf, AbstractCPRF.create(cprf.getCodigoFormatado())); + assertTrue(!cprf.equals(cprfOutro)); + } + + @Test + public void testHashCode() { + assertEquals(cprf.hashCode(), AbstractCPRF.create(cprf.getCodigoFormatado()).hashCode()); + assertTrue(cprf.hashCode() != cprfOutro.hashCode()); + } + + @Test + public void testToString() { + + assertEquals(cprfStringFormatada, cprf.getCodigoFormatado()); + assertTrue(!cprf.getCodigoFormatado().equals(cprfStringFormatadaErr)); + } + /* + * HELPERS + */ + + private void assertTipo(){ + + if(tipo.equals(TipoDeCPRF.CPF)){ + assertTrue(cprf.isFisica()); + assertTrue(!cprf.isJuridica()); + }else{ + + if(tipo.equals(TipoDeCPRF.CNPJ)){ + assertTrue(cprf.isJuridica()); + assertTrue(!cprf.isFisica()); + }else{ + fail("TIPO NÃO PREVISTO PELO PROGRAMA!"); + } + } + } + + /* + * DEFINERS + */ + + /** + * @param tipo the tipo to set + */ + public final void setTipo(TipoDeCPRF tipo) { + this.tipo = tipo; + } + + /** + * @param cprfStringFormatada the cprfStringFormatada to set + */ + public final void setCprfStringFormatada(String cprfStringFormatada) { + this.cprfStringFormatada = cprfStringFormatada; + } + + /** + * @param cprfStringFormatadaErr the cprfStringFormatadaErr to set + */ + public final void setCprfStringFormatadaErr(String cprfStringFormatadaErr) { + this.cprfStringFormatadaErr = cprfStringFormatadaErr; + } + + /** + * @param cprfString the cprfString to set + */ + public final void setCprfString(String cprfString) { + this.cprfString = cprfString; + } + + /** + * @param cprfStringErr the cprfStringErr to set + */ + public final void setCprfStringErr(String cprfStringErr) { + this.cprfStringErr = cprfStringErr; + } + + /** + * @param cprfLong the cprfLong to set + */ + public final void setCprfLong(Long cprfLong) { + this.cprfLong = cprfLong; + } + + /** + * @param cprfLongErr the cprfLongErr to set + */ + public final void setCprfLongErr(Long cprfLongErr) { + this.cprfLongErr = cprfLongErr; + } + + /** + * @param cprfRaizLong the cprfRaizLong to set + */ + public final void setCprfRaizLong(Long cprfRaizLong) { + this.cprfRaizLong = cprfRaizLong; + } + + /** + * @param cprfRaizLongErr the cprfRaizLongErr to set + */ + public final void setCprfRaizLongErr(Long cprfRaizLongErr) { + this.cprfRaizLongErr = cprfRaizLongErr; + } + + /** + * @param cprfRaizFormatada the cprfRaizFormatado to set + */ + public final void setCprfRaizFormatada(String cprfRaizFormatada) { + this.cprfRaizFormatada = cprfRaizFormatada; + } + + /** + * @param cprfRaizFormatadaErr the cprfRaizFormatadoErr to set + */ + public final void setCprfRaizFormatadaErr(String cprfRaizFormatadaErr) { + this.cprfRaizFormatadaErr = cprfRaizFormatadaErr; + } + + /** + * @param cprfDv the cprfDv to set + */ + public final void setCprfDv(Integer cprfDv) { + this.cprfDv = cprfDv; + } + + /** + * @param cprfDvErr the cprfDvErr to set + */ + public final void setCprfDvErr(Integer cprfDvErr) { + this.cprfDvErr = cprfDvErr; + } + + /** + * @param cprf the cprf to set + */ + public final void setCprf(CPRF cprf) { + this.cprf = cprf; + } + + /** + * @param cprfOutro the cprfOutro to set + */ + public final void setCprfOutro(CPRF cprfOutro) { + this.cprfOutro = cprfOutro; + } +} diff --git a/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCNPJ.java b/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCNPJ.java new file mode 100644 index 0000000..d7e2647 --- /dev/null +++ b/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCNPJ.java @@ -0,0 +1,159 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:11:13 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:11:13 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.jrimum.vallia.AbstractCPRFValidator.TipoDeCPRF; +import org.junit.Before; +import org.junit.Test; + +/** + * Teste da classe CNPJ. + * + * @author Gilmar P.S.L. + * + * @since 2.0 + * + * @version 2.0 + */ +public class TestCNPJ extends TestAbstractCPRF{ + + /* + * CNPJ: 60.746.948/0001-12 | BANCO BRADESCO + */ + private final String cnpjBradescoFilialStrFmt = "60.746.948/0005-46"; + private final String cnpjBradescoStrFmt = "60.746.948/0001-12"; + private final String cnpjBradescoStr = "60746948000112"; + private final Long cnpjBradesco = 60746948000112L; + + @Before + public void setUp() { + + setTipo(TipoDeCPRF.CNPJ); + setCprfLong(cnpjBradesco); + setCprfLongErr(60746948000113L); + setCprfString(cnpjBradescoStr); + setCprfStringErr("60746948000113"); + setCprfStringFormatada(cnpjBradescoStrFmt); + setCprfStringFormatadaErr("60.746.948/0001-13"); + setCprfRaizLong(60746948L); + setCprfRaizLongErr(60746941L); + setCprfRaizFormatada("60.746.948"); + setCprfRaizFormatadaErr("60.746.941"); + setCprfDv(12); + setCprfDvErr(13); + setCprf(new CNPJ(cnpjBradescoStrFmt)); + //BANCO DO NORDESTE + setCprfOutro(new CNPJ("07.237.373/0001-20")); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#CNPJ(java.lang.Long)}. + */ + @Test + public void testCNPJLong() { + CNPJ cnpj = new CNPJ(cnpjBradesco); + assertConsistent(cnpj); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#CNPJ(java.lang.String)}. + */ + @Test + public void testCNPJStringWithZeros() { + CNPJ cnpj = new CNPJ(cnpjBradescoStr); + assertConsistent(cnpj); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#CNPJ(java.lang.String)}. + */ + @Test + public void testCNPJStringWithFormat() { + CNPJ cnpj = new CNPJ(cnpjBradescoStrFmt); + assertConsistent(cnpj); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#getSufixo()}. + */ + @Test + public void testGetSufixo() { + assertEquals(Integer.valueOf(1), new CNPJ(cnpjBradescoStrFmt).getSufixo()); + + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#getSufixoFormatado()}. + */ + @Test + public void testGetSufixoFormatado() { + assertEquals("0001", new CNPJ(cnpjBradescoStrFmt).getSufixoFormatado()); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#isMatriz()}. + */ + @Test + public void testIsMatriz() { + assertTrue(new CNPJ(cnpjBradescoStrFmt).isMatriz()); + assertTrue(!new CNPJ(cnpjBradescoFilialStrFmt).isMatriz()); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#isSufixoEquals(java.lang.String)}. + */ + @Test + public void testIsSufixoEqualsString() { + + assertTrue(new CNPJ(cnpjBradescoStrFmt).isSufixoEquals("0001")); + assertTrue(!new CNPJ(cnpjBradescoFilialStrFmt).isSufixoEquals("0001")); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CNPJ#isSufixoEquals(java.lang.Integer)}. + */ + @Test + public void testIsSufixoEqualsInteger() { + assertTrue(new CNPJ(cnpjBradescoFilialStrFmt).isSufixoEquals(5)); + assertTrue(!new CNPJ(cnpjBradescoStrFmt).isSufixoEquals(5)); + } + + private void assertConsistent(CNPJ cnpj) { + + assertNotNull(cnpj); + assertEquals(cnpjBradesco, cnpj.getCodigo()); + assertEquals(cnpjBradescoStr, cnpj.getCodigoComZeros()); + assertEquals(cnpjBradescoStrFmt, cnpj.getCodigoFormatado()); + } +} diff --git a/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCPF.java b/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCPF.java new file mode 100644 index 0000000..901a44b --- /dev/null +++ b/jrimum-domkee/src/test/java/org/jrimum/domkee/comum/pessoa/id/cprf/TestCPF.java @@ -0,0 +1,112 @@ +/* + * Copyright 2008 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: 30/03/2008 - 19:11:24 + * + * ================================================================================ + * + * 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. + * + * Criado em: 30/03/2008 - 19:11:24 + * + */ + +package org.jrimum.domkee.comum.pessoa.id.cprf; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.jrimum.vallia.AbstractCPRFValidator.TipoDeCPRF; +import org.junit.Before; +import org.junit.Test; + +/** + * Teste da classe CPF. + * + * @author Gilmar P.S.L. + * + * @since 0.2 + * + * @version 0.2 + */ +public class TestCPF extends TestAbstractCPRF{ + + /* + * CPF: 070.680.938-68 | LUIZ INACIO LULA DA SILVA + */ + private final String cpfLulaStrFmt = "070.680.938-68"; + private final String cpfLulaStr = "07068093868"; + private final Long cpfLula = 7068093868L; + + @Before + public void setUp() { + + setTipo(TipoDeCPRF.CPF); + setCprfLong(cpfLula); + setCprfLongErr(7068093867L); + setCprfString(cpfLulaStr); + setCprfStringErr("07068093867"); + setCprfStringFormatada(cpfLulaStrFmt); + setCprfStringFormatadaErr("070.680.938-67"); + setCprfRaizLong(70680938L); + setCprfRaizLongErr(70680936L); + setCprfRaizFormatada("070.680.938"); + setCprfRaizFormatadaErr("070.680.936"); + setCprfDv(68); + setCprfDvErr(67); + setCprf(new CPF(cpfLulaStrFmt)); + //FICTICIO + setCprfOutro(new CPF("222.222.222-22")); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CPF#CPF(java.lang.Long)}. + */ + @Test + public void testCPFLong() { + CPF cpf = new CPF(cpfLula); + assertConsistent(cpf); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CPF#CPF(java.lang.String)}. + */ + @Test + public void testCPFStringWithZeros() { + CPF cpf = new CPF(cpfLulaStr); + assertConsistent(cpf); + } + + /** + * Test method for {@link org.jrimum.domkee.comum.pessoa.id.cprf.CPF#CPF(java.lang.String)}. + */ + @Test + public void testCPFStringWithFormat() { + CPF cpf = new CPF(cpfLulaStrFmt); + assertConsistent(cpf); + } + + private void assertConsistent(CPF cpf) { + + assertNotNull(cpf); + assertEquals(cpfLula, cpf.getCodigo()); + assertEquals(cpfLulaStr, cpf.getCodigoComZeros()); + assertEquals(cpfLulaStrFmt, cpf.getCodigoFormatado()); + } +} diff --git a/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMapTest.java b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMapTest.java new file mode 100644 index 0000000..04dd59c --- /dev/null +++ b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/ParametrosBancariosMapTest.java @@ -0,0 +1,369 @@ +/* + * 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. + * + * Created at: 26/09/2013 - 19:06:06 + * + * ================================================================================ + * + * 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. + * + * Criado em: 26/09/2013 - 19:06:06 + * + */ + + +package org.jrimum.domkee.financeiro.banco; + +import static org.hamcrest.Matchers.arrayContainingInAnyOrder; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.math.BigDecimal; +import java.util.Collection; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +/** + * + * @author Gilmar P.S.L + * + * @since 0.2 + * + * @version 0.2 + */ +public class ParametrosBancariosMapTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private int V1 = 1; + private Integer V2 = 1; + private Double V3 = 3d; + private BigDecimal V4 = BigDecimal.ONE; + + @Test + public void deve_estar_vazio_na_instanciacao_sem_parametros(){ + ParametrosBancariosMap parametrosBancariosMap = new ParametrosBancariosMap(); + + assertTrue(parametrosBancariosMap.isVazio()); + assertFalse(parametrosBancariosMap.isNaoVazio()); + } + + @Test + public void deve_conter_um_parametro_na_instanciacao_com_parametros(){ + ParametrosBancariosMap parametrosBancariosMap = new ParametrosBancariosMap(ParamBancTest.P1,V1); + + Set> nomes = parametrosBancariosMap.nomes(); + + assertEquals(ParamBancTest.P1, nomes.iterator().next()); + assertEquals(V1, parametrosBancariosMap.getValor(ParamBancTest.P1)); + assertFalse(parametrosBancariosMap.isVazio()); + assertTrue(parametrosBancariosMap.isNaoVazio()); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_caso_o_nome_do_parametro_seja_nulo(){ + new ParametrosBancariosMap(null,V1); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_caso_o_valor_do_parametro_seja_nulo(){ + new ParametrosBancariosMap(ParamBancTest.P1,null); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_caso_os_parametros_sejam_nulos(){ + new ParametrosBancariosMap(null,null); + } + + @Test + public void deve_indicar_que_nao_tem_elementos_quando_o_map_passado_eh_nulo(){ + ParametrosBancariosMap map = null; + + assertFalse(ParametrosBancariosMap.hasElement(map)); + } + + @Test + public void deve_indicar_que_nao_tem_elementos_quando_o_map_passado_eh_vazio(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(); + + assertFalse(ParametrosBancariosMap.hasElement(map)); + } + + @Test + public void deve_indicar_que_tem_elementos_quando_o_map_passado_tem__apenas_um_elemento(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(ParamBancTest.P1,V1); + + assertTrue(ParametrosBancariosMap.hasElement(map)); + } + + @Test + public void deve_indicar_que_tem_elementos_quando_o_map_passado_tem_mais_de_um_elementos(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + + assertTrue(ParametrosBancariosMap.hasElement(map)); + } + + @Test + public void deve_indicar_que_contem_um_parametro_que_estah_no_mapa(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + + assertTrue(map.contemComNome(ParamBancTest.P1)); + } + + @Test + public void deve_indicar_que__nao_contem_um_parametro_que_nao_estah_no_mapa(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + + assertFalse(map.contemComNome(ParamBancTest.P3)); + } + + @Test + public void deve_indicar_que_contem_um_valor_que_estah_no_mapa(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + + assertTrue(map.contemComValor(V1)); + } + + @Test + public void deve_indicar_que__nao_contem_um_valor_que_nao_estah_no_mapa(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + + assertFalse(map.contemComValor(V3)); + } + + @Test + public void deve_retornar_um_valor_que_esteja_no_map(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2) + .adicione(ParamBancTest.P3,V3); + + assertEquals(V2, map.getValor(ParamBancTest.P2)); + } + + @Test + public void deve_retornar_null_quando_o_valor_nao_existe_no_map(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P3,V3); + + assertNull(map.getValor(ParamBancTest.P2)); + } + + public void deve_lancar_excecao_quando_o_nome_passado_eh_nulo(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P3,V3); + + thrown.expect(IllegalArgumentException.class); + map.getValor(null); + } + + @Test + public void deve_indicar_que_eh_vazio_quando_nao_existem_parametros_no_map(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(); + + assertTrue(map.isVazio()); + } + + @Test + public void deve_indicar_que_nao_eh_vazio_quando_existem_parametros_no_map(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(ParamBancTest.P1,V1); + + assertFalse(map.isVazio()); + } + + @Test + public void deve_indicar_o_oposto_que_eh_vazio_quando_nao_existem_parametros_no_map(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(); + + assertFalse(map.isNaoVazio()); + } + + @Test + public void deve_indicar_o_oposto_que_nao_eh_vazio_quando_existem_parametros_no_map(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(ParamBancTest.P1,V1); + + assertTrue(map.isNaoVazio()); + } + + @Test + public void deve_retornar_os_nomes_contidos_no_map(){ + Set nomesEsperados = Sets.newHashSet(ParamBancTest.P1,ParamBancTest.P2,ParamBancTest.P3); + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V1) + .adicione(ParamBancTest.P3,V3); + + Set> nomes = map.nomes(); + + assertThat(nomes.size(), is(equalTo(nomesEsperados.size()))); + assertEquals(nomesEsperados, nomes); + } + + @Test + public void deve_retornar_os_valores_contidos_no_map(){ + @SuppressWarnings("unchecked") + Collection valoresEsperados = Lists.newArrayList(V3,V1,V4,V2); + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2) + .adicione(ParamBancTest.P3,V3) + .adicione(ParamBancTest.P4,V4); + + Collection valores = map.valores(); + + assertThat(valores.size(), is(equalTo(valoresEsperados.size()))); + assertThat(valores.toArray(), arrayContainingInAnyOrder(valoresEsperados.toArray())); + } + + @Test + public void deve_retornar_o_conjunto_de_entradas_do_map(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + Map,Number> mapEsperado = Maps.newHashMap(); + mapEsperado.put(ParamBancTest.P1,V1); + mapEsperado.put(ParamBancTest.P2,V2); + Set,Number>> entradasEsperadas = mapEsperado.entrySet(); + + Set,Number>> entradas = map.entradas(); + + assertThat(entradas, is(equalTo(entradasEsperadas))); + } + + @Test + public void deve_adicionar_um_parametro_e_um_valor_corretamente(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(); + + map = map.adicione(ParamBancTest.P1,V1); + + assertThat(map.getValor(ParamBancTest.P1), is(equalTo((Number)V1))); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_ao_adicionar_nome_nulo(){ + new ParametrosBancariosMap().adicione(null,V1); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_ao_adicionar_valor_nulo(){ + new ParametrosBancariosMap().adicione(ParamBancTest.P1,null); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_ao_adicionar_nome_e_valor_nulos(){ + new ParametrosBancariosMap().adicione(null,null); + } + + @Test + public void deve_adicionar_todos_os_parametros_de_um_outro_objeto_parametro_bancario_map_corretamente(){ + ParametrosBancariosMap mapA = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + ParametrosBancariosMap mapB = new ParametrosBancariosMap() + .adicione(ParamBancTest.P3,V3) + .adicione(ParamBancTest.P4,V4); + final Integer totalEsperadoA = 4; + final Integer totalEsperadoB = 2; + + mapA = mapA.adicione(mapB); + + assertThat(mapA.quantidade(), is(equalTo(totalEsperadoA))); + assertThat(mapB.quantidade(), is(equalTo(totalEsperadoB))); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excecao_ao_tentar_adicionar_um_outro_objeto_parametro_bancario_map_null(){ + new ParametrosBancariosMap().adicione(null); + } + + @Test + public void deve_remover_o_parametro_do_map_corretamente(){ + ParametrosBancariosMap map = new ParametrosBancariosMap(ParamBancTest.P1,V1); + + Integer valor = map.remova(ParamBancTest.P1); + + assertTrue(map.isVazio()); + assertThat(valor, is(equalTo(V1))); + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excecao_ao_tentar_remover_parametro_null(){ + new ParametrosBancariosMap().remova(null); + } + + @Test + public void deve_remover_todos_os_parametros_do_map_corretamente(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + + map.limpe(); + + assertTrue(map.isVazio()); + } + + @Test + public void deve_retornar_o_numero_de_parametros_correto(){ + ParametrosBancariosMap map = new ParametrosBancariosMap() + .adicione(ParamBancTest.P1,V1) + .adicione(ParamBancTest.P2,V2); + final int quantidadeEsperada = 2; + + assertThat(map.quantidade(), is(equalTo(quantidadeEsperada))); + } + + /** + * Enum utilizado para uso apenas nesta classe de teste. + * + * @author Gilmar P.S.L + * + * @since 0.2 + * + * @version 0.2 + */ + private enum ParamBancTest implements ParametroBancario{ + P1,P2,P3,P4; + } +} diff --git a/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestAgencia.java b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestAgencia.java new file mode 100644 index 0000000..9f73cab --- /dev/null +++ b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestAgencia.java @@ -0,0 +1,81 @@ +/* + * Copyright 2008 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: 04/04/2009 - 12:31:48 + * + * ================================================================================ + * + * 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. + * + * Criado em: 04/04/2009 - 12:31:48 + * + */ +package org.jrimum.domkee.financeiro.banco.febraban; + +import org.junit.Test; + +/** + * + *

    + * OBJETIVO/PROPÓSITO + *

    + * + * @author Rômulo Augusto + * + * @version 0.2 + */ +public class TestAgencia { + + @Test(expected = IllegalArgumentException.class) + public void testCodigoMenorQueZero() { + + new Agencia(-1, "x"); + } + + @Test(expected = IllegalArgumentException.class) + public void testCodigoMaiorQueCincoDigitos() { + + new Agencia(123456, "x"); + } + + @Test(expected = IllegalArgumentException.class) + public void testDigitoCharVazio() { + + new Agencia(1, " "); + } + + @Test(expected = IllegalArgumentException.class) + public void testDigitoCharNaoLetra() { + + new Agencia(1, "-"); + } + + @Test(expected = IllegalArgumentException.class) + public void testDigitoCharDigitoInteiroNaoNatural() { + + new Agencia(1, "-1"); + } + + @Test + public void testValoresCorretos() { + + new Agencia(12345, "x"); + } +} diff --git a/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestBanco.java b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestBanco.java new file mode 100644 index 0000000..1e8cc8b --- /dev/null +++ b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestBanco.java @@ -0,0 +1,58 @@ +/* + * Copyright 2008 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: 22/02/2010 - 13:52:30 + * + * ================================================================================ + * + * 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. + * + * Criado em: 22/02/2010 - 13:52:30 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Classe de teste para a classe Banco. + * + * @author Rômulo Augusto + * + * @version 0.2 + * + * @since 0.2 + */ +public class TestBanco { + + @Test + public void testIsCodigoDeCompensacaoOKNaoNulo() { + + assertTrue(Banco.isCodigoDeCompensacaoOK("001")); + + assertFalse(Banco.isCodigoDeCompensacaoOK(null)); + assertFalse(Banco.isCodigoDeCompensacaoOK("ABC")); + assertFalse(Banco.isCodigoDeCompensacaoOK("0011")); + } +} diff --git a/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestTipoDeTitulo.java b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestTipoDeTitulo.java new file mode 100644 index 0000000..d31281a --- /dev/null +++ b/jrimum-domkee/src/test/java/org/jrimum/domkee/financeiro/banco/febraban/TestTipoDeTitulo.java @@ -0,0 +1,66 @@ +/* + * 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: 11/04/2014 - 12:23:59 + * + * ================================================================================ + * + * 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: 11/04/2014 - 12:23:59 + * + */ + +package org.jrimum.domkee.financeiro.banco.febraban; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * @author Gilmar P.S.L. + * + */ +public class TestTipoDeTitulo { + + @Test + public void deve_retornar_corretamente_qualquer_enum_buscada_pelo_seu_codigo(){ + for(TipoDeTitulo t : TipoDeTitulo.values()){ + assertEquals(t, TipoDeTitulo.valueOf(t.getCodigo())); + } + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_quando_codigo_nao_existe_na_enumeracao(){ + TipoDeTitulo.valueOf(-1); + } + + @Test + public void deve_retornar_corretamente_qualquer_enum_buscada_pelo_sua_sigla(){ + for(TipoDeTitulo t : TipoDeTitulo.values()){ + assertEquals(t, TipoDeTitulo.valueOfSigla(t.getSigla())); + } + } + + @Test(expected=IllegalArgumentException.class) + public void deve_lancar_excessao_quando_sigla_nao_existe_na_enumeracao(){ + TipoDeTitulo.valueOf("JJJ"); + } +}