Source Code Cross Referenced for CreditCardDAO.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfp » dao » 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.dao 
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; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:        package br.com.gfp.dao;
023:
024:        import java.sql.SQLException;
025:        import java.util.Calendar;
026:
027:        import javax.swing.event.EventListenerList;
028:
029:        import br.com.gfp.data.AccountType;
030:        import br.com.gfp.data.CheckingAccount;
031:        import br.com.gfp.data.CreditCard;
032:        import br.com.gfp.data.Transaction;
033:        import br.com.gfp.data.TransactionType;
034:        import br.com.gfp.internationalization.TipoDeLancamentosMessages;
035:        import br.com.gfpshare.db.AbstractDAO;
036:        import br.com.gfpshare.db.SQLCondition;
037:        import br.com.gfpshare.db.SQLCondition.Condicao;
038:
039:        /**
040:         * Controler para as aplicações financeiras
041:         * A idéia é que esta classe realize a formulação de relatórios.  
042:         * @author Igor Regis da Silva Simoes
043:         * @param <A> Tipo do PersistentObject que esse controller irá gerenciar
044:         */
045:        public class CreditCardDAO extends AbstractDAO<CreditCard> {
046:            /**
047:             * Lista de listeners de eventos do controller
048:             */
049:            private static final EventListenerList listeners = new EventListenerList();
050:
051:            /**
052:             *  Ultimo cartão de crédito utilizado  
053:             */
054:            private CreditCard creditCard = null;
055:
056:            private TransactionDAO<Transaction> transactionDAO = new TransactionDAO<Transaction>();
057:
058:            private TransactionTypeDAO transactionTypeDAO = new TransactionTypeDAO();
059:
060:            /**
061:             * @see br.com.gfpshare.db.AbstractDAO#getListeners()
062:             */
063:            @Override
064:            protected EventListenerList getListeners() {
065:                return listeners;
066:            }
067:
068:            /**
069:             * @param mes Data da qual se deseja saber o valor da fatura
070:             * @return
071:             * @throws SQLException 
072:             */
073:            public Double getValorFaturaNoMes(int mes, int ano, Integer conta)
074:                    throws SQLException {
075:                Transaction compras = new Transaction();
076:                compras.setTipo(transactionTypeDAO.getBy(
077:                        new TransactionType(TipoDeLancamentosMessages
078:                                .getMessages().getString("Despesas"))).getId());
079:                compras.setConta(conta);
080:
081:                if (creditCard == null || !creditCard.getId().equals(conta)) {
082:                    creditCard = getBy(new CreditCard(conta));
083:                }
084:
085:                //Montamos a condição que restringe nossa busca aos últimos 12 meses
086:                Calendar inicio = Calendar.getInstance();
087:                Calendar fim = Calendar.getInstance();
088:
089:                //40 dias antes do pagamento
090:                inicio.set(Calendar.YEAR, ano);
091:                inicio.set(Calendar.MONTH, mes);
092:                inicio.set(Calendar.DAY_OF_MONTH, creditCard.getDataPagamento()
093:                        .intValue());
094:                inicio.add(Calendar.DAY_OF_MONTH, -1
095:                        * (creditCard.getDiasParaPagamento().intValue() + 1));
096:                //10 dias antes do pagamento (começo de nova fatura)
097:                fim.setTime(inicio.getTime());
098:                fim.add(Calendar.DAY_OF_MONTH, 30);
099:
100:                compras.addCondicaoExtra(new SQLCondition<java.sql.Date>("Dia",
101:                        new java.sql.Date(inicio.getTime().getTime()),
102:                        new java.sql.Date(fim.getTime().getTime()),
103:                        Condicao.BETWEEN));
104:
105:                String tipoContaCartaoCredito = new AccountTypeDAO().getBy(
106:                        new AccountType("cartaoCredito")).getId().toString();
107:
108:                compras.setTipoConta(tipoContaCartaoCredito);
109:                compras.setIncluirSubtipos(true);
110:                return Double.valueOf(""
111:                        + (-1 * transactionDAO.getTotalNoPeriodo(compras)));
112:            }
113:
114:            @Override
115:            public synchronized boolean atualizar(CreditCard atualizacao)
116:                    throws SQLException {
117:                deletarDebitosAutomaticos(new TransactionDAO<Transaction>(),
118:                        atualizacao);
119:                return super .atualizar(atualizacao);
120:            }
121:
122:            /**
123:             * Here we remove the old credit card bill value predictions
124:             * @param lancamentoController
125:             * @param creditCard
126:             * @return
127:             * @throws SQLException
128:             */
129:            private Transaction deletarDebitosAutomaticos(
130:                    TransactionDAO<Transaction> lancamentoController,
131:                    CreditCard creditCard) throws SQLException {
132:                CreditCard old = getBy(new CreditCard(creditCard.getId()));
133:                Transaction lancamentoPagamentoCartao;
134:                lancamentoPagamentoCartao = new Transaction();
135:                lancamentoPagamentoCartao.setConta(old.getContaDebito());
136:                lancamentoPagamentoCartao.setTipoConta(new CheckingAccount()
137:                        .getTipoConta());
138:                lancamentoPagamentoCartao
139:                        .setEntidadeEnvolvida(old.getBanco() == null ? old
140:                                .getOperadora() : old.getBanco());
141:                lancamentoPagamentoCartao.setTipo(new TransactionTypeDAO()
142:                        .getBy(
143:                                new TransactionType(TipoDeLancamentosMessages
144:                                        .getMessages().getString(
145:                                                "PagamentoCartao"))).getId());
146:                lancamentoPagamentoCartao.setEhPrevisao(true);
147:
148:                //deletamos os antigos
149:                lancamentoController.setCheckIntegridade(false);
150:                lancamentoController.deletar(lancamentoPagamentoCartao);
151:                lancamentoController.setCheckIntegridade(true);
152:                return lancamentoPagamentoCartao;
153:            }
154:
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.