Source Code Cross Referenced for CreditCard.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfp » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Personal Finance Manager » br.com.gfp.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 17/03/2005 
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2004 Igor Regis da Silva Simões
007:         *  
008:         * This program is free software;
009:         * 
010:         * you can redistribute it and/or modify it under the terms of the GNU General
011:         * Public License as published by the Free Software Foundation; either version 2
012:         * of the License, or (at your option) any later version. This program is
013:         * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
014:         * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
015:         * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
016:         * should have received a copy of the GNU General Public License along with this
017:         * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place -
018:         * Suite 330, Boston, MA 02111-1307, USA.
019:         */
020:        package br.com.gfp.data;
021:
022:        import java.sql.SQLException;
023:        import java.util.Calendar;
024:        import java.util.Date;
025:
026:        import br.com.gfp.dao.AccountTypeDAO;
027:        import br.com.gfp.dao.GFPController;
028:        import br.com.gfp.internationalization.ErrosDeDadosMessages;
029:        import br.com.gfp.util.SimpleLog;
030:        import br.com.gfpshare.db.Column;
031:        import br.com.gfpshare.db.Table;
032:
033:        /**
034:         * @author Igor Regis da Silva Simoes
035:         * @since 17/03/2005 15:42:37
036:         */
037:        @Table(name="CartaoCredito")
038:        public class CreditCard extends BasicGFPDataObject {
039:            /**
040:             * A operadora do Cartão de Crédito
041:             */
042:            @Column(nome="Operadora",isPk=false,writeMethodName="setOperadora",readMethodName="getOperadora")
043:            private Integer operadora = null;
044:
045:            /**
046:             * Indica se este cartão está ou não vunculado a um banco
047:             */
048:            @Column(nome="TemBanco",isPk=false,writeMethodName="setTemBanco",readMethodName="getTemBanco")
049:            private Boolean temBanco = null;
050:
051:            /**
052:             * Banco ao qual o cartão está vinculado (caso esteja)
053:             */
054:            @Column(nome="Banco",isPk=false,writeMethodName="setBanco",readMethodName="getBanco")
055:            private Integer banco = null;
056:
057:            /**
058:             * Numero do Cartão
059:             */
060:            @Column(nome="NumeroCartao",isPk=false,writeMethodName="setNumeroCartao",readMethodName="getNumeroCartao")
061:            private String numeroCartao = null;
062:
063:            /**
064:             * Data de abertura do cartão (adesão)
065:             */
066:            @Column(nome="DataAbertura",isPk=false,writeMethodName="setDataAbertura",readMethodName="getDataAbertura")
067:            private Date dataAbertura = null;
068:
069:            /**
070:             * Data em que o cartão foi ecerrado (caso se aplique)
071:             */
072:            @Column(nome="DataFechamento",isPk=false,writeMethodName="setDataFechamento",readMethodName="getDataFechamento")
073:            private Date dataFechamento = null;
074:
075:            /**
076:             * Valor do limite de crédito do cartão
077:             */
078:            @Column(nome="Limite",isPk=false,writeMethodName="setLimite",readMethodName="getLimite")
079:            private Double limite = null;
080:
081:            /**
082:             * Valor de limite de crédito rotativo extra
083:             */
084:            @Column(nome="LimiteExtra",isPk=false,writeMethodName="setLimiteExtra",readMethodName="getLimiteExtra")
085:            private Double limiteExtra = null;
086:
087:            /**
088:             * Data de validade do cartão
089:             */
090:            @Column(nome="DataValidade",isPk=false,writeMethodName="setDataValidade",readMethodName="getDataValidade")
091:            private Date dataValidade = null;
092:
093:            /**
094:             * Quantos dia no máximo o usuário possui para pagar a fatura do cartão
095:             */
096:            @Column(nome="DiasParaPagamento",isPk=false,writeMethodName="setDiasParaPagamento",readMethodName="getDiasParaPagamento")
097:            private Integer diasParaPagamento = null;
098:
099:            /**
100:             * Data do vencimento da fatura do cartão
101:             */
102:            @Column(nome="DataPagamento",isPk=false,writeMethodName="setDataPagamento",readMethodName="getDataPagamento")
103:            private Integer dataPagamento = null;
104:
105:            /**
106:             * Juros de crédito rotativo
107:             */
108:            @Column(nome="JurosRotativo",isPk=false,writeMethodName="setJurosRotativo",readMethodName="getJurosRotativo")
109:            private Double jurosRotativo = null;
110:
111:            /**
112:             * Juros de crédito de parcelamentos
113:             */
114:            @Column(nome="JurosFinanciamento",isPk=false,writeMethodName="setJurosFinanciamento",readMethodName="getJurosFinanciamento")
115:            private Double jurosFinanciamento = null;
116:
117:            /**
118:             * Indica se o cartão esta vinculado a algum plano de fidelidade
119:             */
120:            @Column(nome="TemPlanoDeFidelidade",isPk=false,writeMethodName="setTemPlanoDeFidelidade",readMethodName="getTemPlanoDeFidelidade")
121:            private Boolean temPlanoDeFidelidade = null;
122:
123:            /**
124:             * Valor de cada ponto no plano de fidelidade
125:             */
126:            @Column(nome="QuantoValeCadaPonto",isPk=false,writeMethodName="setQuantoValeCadaPonto",readMethodName="getQuantoValeCadaPonto")
127:            private Double quantoValeCadaPonto = null;
128:
129:            /**
130:             * Descrição do Cartão
131:             */
132:            @Column(nome="Descricao",isPk=false,writeMethodName="setDescricao",readMethodName="getDescricao")
133:            private String descricao = null;
134:
135:            /**
136:             * Tipo da conta, em nosso caso cartaoCredito
137:             */
138:            @Column(nome="TipoConta",isPk=false,writeMethodName="setTipoConta",readMethodName="getTipoConta")
139:            private String tipoConta = null;
140:
141:            /**
142:             * Account para realização de debito automatico das faturas deste cartao
143:             */
144:            @Column(nome="ContaDebito",isPk=false,writeMethodName="setContaDebito",readMethodName="getContaDebito")
145:            private Integer contaDebito = null;
146:
147:            /**
148:             * Indica se este é um registro de sistema
149:             */
150:            @Column(nome="EhDeSistema",isPk=false,writeMethodName="setEhDeSistema",readMethodName="getEhDeSistema")
151:            private Boolean ehDeSistema = Boolean.FALSE;
152:
153:            /**
154:             * Inicializamos o tipo da conta para aplicação
155:             */
156:            {
157:                try {
158:                    tipoConta = ""
159:                            + new AccountTypeDAO().getBy(
160:                                    new AccountType("cartaoCredito")).getId();
161:                } catch (SQLException e) {
162:                    ((SimpleLog) GFPController.getGFPController().getContexto()
163:                            .get(GFPController.LOG))
164:                            .log("Erro ao reter tipo da conta cartao credito!");
165:                    ((SimpleLog) GFPController.getGFPController().getContexto()
166:                            .get(GFPController.LOG)).log(e
167:                            .getLocalizedMessage());
168:                    ((SimpleLog) GFPController.getGFPController().getContexto()
169:                            .get(GFPController.LOG)).log(e);
170:                }
171:            }
172:
173:            /**
174:             * Contrói um novo cartão de crédito sem nenhum campo preenchido
175:             */
176:            public CreditCard() {
177:                // Não fazemos nada
178:            }
179:
180:            /**
181:             * Contrói um novo cartão de crédito com o ID especificado
182:             * @param id O Id do cartão de crédito
183:             */
184:            public CreditCard(Integer id) {
185:                setId(id);
186:            }
187:
188:            /**
189:             * Banco ao qual o cartão está vinculado (caso esteja)
190:             * 
191:             * @return
192:             */
193:            public Integer getBanco() {
194:                return banco;
195:            }
196:
197:            /**
198:             * Banco ao qual o cartão está vinculado (caso esteja)
199:             * 
200:             * @param persistentBanco
201:             */
202:            public void setBanco(Integer persistentBanco) {
203:                this .banco = persistentBanco;
204:            }
205:
206:            /**
207:             * Data de abertura do cartão (adesão)
208:             * @return
209:             */
210:            public Date getDataAbertura() {
211:                return dataAbertura;
212:            }
213:
214:            /**
215:             * Data de abertura do cartão (adesão)
216:             * @param persistentDataAbertura
217:             */
218:            public void setDataAbertura(Date persistentDataAbertura) {
219:                this .dataAbertura = persistentDataAbertura;
220:            }
221:
222:            /**
223:             * Quantos dia no máximo o usuário possui para pagar a fatura do cartão
224:             * @return
225:             */
226:            public Integer getDiasParaPagamento() {
227:                return diasParaPagamento;
228:            }
229:
230:            /**
231:             * Quantos dia no máximo o usuário possui para pagar a fatura do cartão
232:             * @param persistentDiasParaPagamento
233:             */
234:            public void setDiasParaPagamento(Integer persistentDiasParaPagamento) {
235:                this .diasParaPagamento = persistentDiasParaPagamento;
236:            }
237:
238:            /**
239:             * Data em que o cartão foi ecerrado (caso se aplique)
240:             * @return
241:             */
242:            public Date getDataFechamento() {
243:                return dataFechamento;
244:            }
245:
246:            /**
247:             * Data em que o cartão foi ecerrado (caso se aplique)
248:             * @param dataFechamento
249:             */
250:            public void setDataFechamento(Date dataFechamento) {
251:                this .dataFechamento = dataFechamento;
252:            }
253:
254:            /**
255:             * Data do vencimento da fatura do cartão
256:             * @return
257:             */
258:            public Integer getDataPagamento() {
259:                return dataPagamento;
260:            }
261:
262:            /**
263:             * Data do vencimento da fatura do cartão
264:             * @param dataPagamento
265:             */
266:            public void setDataPagamento(Integer dataPagamento) {
267:                this .dataPagamento = dataPagamento;
268:            }
269:
270:            /**
271:             * Data de validade do cartão
272:             * @return
273:             */
274:            public Date getDataValidade() {
275:                return dataValidade;
276:            }
277:
278:            /**
279:             * Data de validade do cartão
280:             * @param dataValidade
281:             */
282:            public void setDataValidade(Date dataValidade) {
283:                this .dataValidade = dataValidade;
284:            }
285:
286:            /**
287:             * Descrição do Cartão
288:             * @return
289:             */
290:            public String getDescricao() {
291:                return descricao;
292:            }
293:
294:            /**
295:             * Descrição do Cartão
296:             * @param descricao
297:             */
298:            public void setDescricao(String descricao) {
299:                this .descricao = descricao;
300:            }
301:
302:            /**
303:             * Juros de crédito de parcelamentos
304:             * @return
305:             */
306:            public Double getJurosFinanciamento() {
307:                return jurosFinanciamento;
308:            }
309:
310:            /**
311:             * Juros de crédito de parcelamentos
312:             * @param jurosFinanciamento
313:             */
314:            public void setJurosFinanciamento(Double jurosFinanciamento) {
315:                this .jurosFinanciamento = jurosFinanciamento;
316:            }
317:
318:            /**
319:             * Juros de crédito rotativo
320:             * @return
321:             */
322:            public Double getJurosRotativo() {
323:                return jurosRotativo;
324:            }
325:
326:            /**
327:             * Juros de crédito rotativo
328:             * @param jurosRotativo
329:             */
330:            public void setJurosRotativo(Double jurosRotativo) {
331:                this .jurosRotativo = jurosRotativo;
332:            }
333:
334:            /**
335:             * Valor do limite de crédito do cartão
336:             * @return
337:             */
338:            public Double getLimite() {
339:                return limite;
340:            }
341:
342:            /**
343:             * Valor do limite de crédito do cartão
344:             * @param limite
345:             */
346:            public void setLimite(Double limite) {
347:                this .limite = limite;
348:            }
349:
350:            /**
351:             * Valor de limite de crédito rotativo extra
352:             * @return
353:             */
354:            public Double getLimiteExtra() {
355:                return limiteExtra;
356:            }
357:
358:            /**
359:             * Valor de limite de crédito rotativo extra
360:             * @param limiteExtra
361:             */
362:            public void setLimiteExtra(Double limiteExtra) {
363:                this .limiteExtra = limiteExtra;
364:            }
365:
366:            /**
367:             * Numero do Cartão
368:             * @return
369:             */
370:            public String getNumeroCartao() {
371:                return numeroCartao;
372:            }
373:
374:            /**
375:             * Numero do Cartão
376:             * @param numeroCartao
377:             */
378:            public void setNumeroCartao(String numeroCartao) {
379:                this .numeroCartao = numeroCartao;
380:            }
381:
382:            /**
383:             * A operadora do Cartão de Crédito
384:             * @return
385:             */
386:            public Integer getOperadora() {
387:                return operadora;
388:            }
389:
390:            /**
391:             * A operadora do Cartão de Crédito
392:             * @param operadora
393:             */
394:            public void setOperadora(Integer operadora) {
395:                this .operadora = operadora;
396:            }
397:
398:            /**
399:             * Valor de cada ponto no plano de fidelidade
400:             * @return
401:             */
402:            public Double getQuantoValeCadaPonto() {
403:                return quantoValeCadaPonto;
404:            }
405:
406:            /**
407:             * Valor de cada ponto no plano de fidelidade
408:             * @param quantoValeCadaPonto
409:             */
410:            public void setQuantoValeCadaPonto(Double quantoValeCadaPonto) {
411:                this .quantoValeCadaPonto = quantoValeCadaPonto;
412:            }
413:
414:            /**
415:             * Indica se este cartão está ou não vunculado a um banco
416:             * @return
417:             */
418:            public Boolean getTemBanco() {
419:                return temBanco;
420:            }
421:
422:            /**
423:             * Indica se este cartão está ou não vunculado a um banco
424:             * @param temBanco
425:             */
426:            public void setTemBanco(Boolean temBanco) {
427:                this .temBanco = temBanco;
428:            }
429:
430:            /**
431:             * Indica se o cartão esta vinculado a algum plano de fidelidade
432:             * @return Boolean
433:             */
434:            public Boolean getTemPlanoDeFidelidade() {
435:                return temPlanoDeFidelidade;
436:            }
437:
438:            /**
439:             * Indica se o cartão esta vinculado a algum plano de fidelidade
440:             * @param temPlanoDeFidelidade
441:             */
442:            public void setTemPlanoDeFidelidade(Boolean temPlanoDeFidelidade) {
443:                this .temPlanoDeFidelidade = temPlanoDeFidelidade;
444:            }
445:
446:            /**
447:             * Indica o tipo de conta, neste caso cartão de crédito
448:             * @return String
449:             */
450:            public String getTipoConta() {
451:                return tipoConta;
452:            }
453:
454:            /**
455:             * Indica o tipo de conta, neste caso cartão de crédito
456:             * @param tipoConta
457:             */
458:            public void setTipoConta(String tipoConta) {
459:                this .tipoConta = tipoConta;
460:            }
461:
462:            /**
463:             * @see br.com.gfpshare.db.PersistentObject#validate()
464:             */
465:            public void validate() throws SQLException {
466:                if (this .dataAbertura == null)
467:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
468:                            .getString("DataAberturaInvalido"));
469:                if (this .dataPagamento == null)
470:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
471:                            .getString("DataPagamentoInvalido"));
472:                if (this .dataValidade != null
473:                        && this .dataValidade.before(new Date()))
474:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
475:                            .getString("DataValidadeInvalido"));
476:                if (this .descricao == null)
477:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
478:                            .getString("DescricaoCartaoInvalido"));
479:                if (this .jurosFinanciamento == null
480:                        || this .jurosFinanciamento.doubleValue() < 0)
481:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
482:                            .getString("JurosFinanciamentoInvalido"));
483:                if (this .jurosRotativo == null
484:                        || this .jurosRotativo.doubleValue() < 0)
485:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
486:                            .getString("JurosRotativoInvalido"));
487:
488:                if (this .limite == null || this .limite.doubleValue() < 0)
489:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
490:                            .getString("LimiteInvalido"));
491:                if (this .limiteExtra != null
492:                        && this .limiteExtra.doubleValue() <= 0)
493:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
494:                            .getString("LimiteExtraInvalido"));
495:                if (this .numeroCartao == null)
496:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
497:                            .getString("NumeroCartaoInvalido"));
498:                if (this .operadora == null)
499:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
500:                            .getString("OperadoraInvalida"));
501:                if (this .temBanco != null && this .temBanco.booleanValue()
502:                        && this .banco == null)
503:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
504:                            .getString("BancoInvalido"));
505:                if ((this .temPlanoDeFidelidade != null && this .temPlanoDeFidelidade
506:                        .booleanValue())
507:                        && (this .quantoValeCadaPonto == null || this .quantoValeCadaPonto
508:                                .doubleValue() < 0))
509:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
510:                            .getString("QuantoValeCadaPontoInvalido"));
511:            }
512:
513:            /**
514:             * @see br.com.gfpshare.db.PersistentObject#getAsString(int)
515:             */
516:            public String getAsString(int format) {
517:                return getDescricao();
518:            }
519:
520:            /**
521:             * Account para realização de debito automatico das faturas deste cartao
522:             * @return
523:             */
524:            public Integer getContaDebito() {
525:                return contaDebito;
526:            }
527:
528:            /**
529:             * Account para realização de debito automatico das faturas deste cartao
530:             * @param contaDebito
531:             */
532:            public void setContaDebito(Integer contaDebito) {
533:                this .contaDebito = contaDebito;
534:            }
535:
536:            /**
537:             * Indica se este é um registro de sistema
538:             * @return true caso seja um registro de sistema
539:             */
540:            public Boolean getEhDeSistema() {
541:                return ehDeSistema;
542:            }
543:
544:            /**
545:             * Indica se este é um registro de sistema
546:             * @param ehDeSistema
547:             */
548:            public void setEhDeSistema(Boolean ehDeSistema) {
549:                this .ehDeSistema = ehDeSistema;
550:            }
551:
552:            /**
553:             * Valida o numero de cartçao de crédito
554:             * @param valor 
555:             */
556:            public void validateNumeroCartao(Object valor) {
557:                if (valor != null)
558:                    numeroCartao = valor.toString();
559:                if (this .numeroCartao == null
560:                        || this .numeroCartao.equals("0000 0000 0000 0000"))
561:                    throw new RuntimeException(ErrosDeDadosMessages
562:                            .getMessages().getString("NumeroCartaoInvalido"));
563:            }
564:
565:            /**
566:             * Valida o valor de limite do cartão
567:             * @param valor
568:             */
569:            public void validateLimiteCartao(Object valor) {
570:                if (valor != null)
571:                    limite = (Double) valor;
572:                if (this .limite == null
573:                        || this .limite.equals(Double.valueOf("0.0"))
574:                        || this .limite.equals(Double.valueOf("-0.0")))
575:                    throw new RuntimeException(ErrosDeDadosMessages
576:                            .getMessages().getString("LimiteInvalido"));
577:            }
578:
579:            /**
580:             * Valida o campo dias para pagar do cartão de crédito
581:             * @param valor
582:             */
583:            public void validateDiasParaPagar(Object valor) {
584:                if (valor != null) {
585:                    if (valor instanceof  Integer)
586:                        diasParaPagamento = (Integer) valor;
587:                    else
588:                        throw new RuntimeException(ErrosDeDadosMessages
589:                                .getMessages().getString(
590:                                        "DiasParaPagarInvalido"));
591:                }
592:                if (this .diasParaPagamento == null
593:                        || this .diasParaPagamento.equals(Integer.valueOf("0")))
594:                    throw new RuntimeException(ErrosDeDadosMessages
595:                            .getMessages().getString("DiasParaPagarInvalido"));
596:            }
597:
598:            /**
599:             * Valida o campo dias para pagar do cartão de crédito
600:             * @param valor
601:             */
602:            public void validateDataPagamento(Object valor) {
603:                if (valor != null) {
604:                    if (valor instanceof  Integer)
605:                        dataPagamento = (Integer) valor;
606:                    else
607:                        throw new RuntimeException(ErrosDeDadosMessages
608:                                .getMessages().getString(
609:                                        "DataPagamentoInvalido"));
610:                }
611:                if (this .dataPagamento == null
612:                        || this .dataPagamento.equals(Integer.valueOf("0")))
613:                    throw new RuntimeException(ErrosDeDadosMessages
614:                            .getMessages().getString("DataPagamentoInvalido"));
615:            }
616:
617:            /**
618:             * Valida o campo dias para pagar do cartão de crédito
619:             * @param valor
620:             */
621:            public void validateJurosRotativo(Object valor) {
622:                if (valor != null)
623:                    jurosRotativo = (Double) valor;
624:                if (this .jurosRotativo == null
625:                        || this .jurosRotativo.doubleValue() <= 0.0)
626:                    throw new RuntimeException(ErrosDeDadosMessages
627:                            .getMessages().getString("JurosRotativoInvalido"));
628:            }
629:
630:            /**
631:             * Valida o campo dias para pagar do cartão de crédito
632:             * @param valor
633:             */
634:            public void validateJurosFinanciamento(Object valor) {
635:                if (valor != null)
636:                    jurosFinanciamento = (Double) valor;
637:                if (this .jurosFinanciamento == null
638:                        || this .jurosFinanciamento.doubleValue() <= 0.0)
639:                    throw new RuntimeException(ErrosDeDadosMessages
640:                            .getMessages().getString(
641:                                    "JurosFinanciamentoInvalido"));
642:            }
643:
644:            /**
645:             * Retorna o melhor dia para se comprar dado um mes e ano
646:             * @param mes Mes no qual se deseja saber o melhor dia para compra
647:             * @param ano Ano no qual se deseja saber o melhor dia para compra
648:             * @return Melhor dia para compra
649:             */
650:            public Date getMelhorDiaParaComprar(int mes, int ano) {
651:                Calendar inicio = Calendar.getInstance();
652:
653:                //40 dias antes do pagamento
654:                inicio.set(Calendar.YEAR, ano);
655:                inicio.set(Calendar.MONTH, mes);
656:                inicio
657:                        .set(Calendar.DAY_OF_MONTH, getDataPagamento()
658:                                .intValue());
659:                inicio.add(Calendar.DAY_OF_MONTH, -1
660:                        * (getDiasParaPagamento().intValue()));
661:                return inicio.getTime();
662:            }
663:
664:            /**
665:             * Retorna o melhor dia para se comprar dado um mes e ano representados pelo Date passado como parametro (o dia é ignorado)
666:             * @param data mes e ano representados pelo Date passado como parametro (o dia é ignorado)
667:             * @return Melhor dia para compra
668:             */
669:            public Date getMelhorDiaParaComprar(Date data) {
670:                Calendar dia = Calendar.getInstance();
671:                dia.setTime(data);
672:                return getMelhorDiaParaComprar(dia.get(Calendar.MONTH), dia
673:                        .get(Calendar.YEAR));
674:            }
675:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.