Source Code Cross Referenced for PostGlAccountBalance.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » batch » poster » impl » 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 » Kuali Financial System » org.kuali.module.gl.batch.poster.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.module.gl.batch.poster.impl;
017:
018:        import java.util.Collection;
019:        import java.util.Date;
020:        import java.util.Iterator;
021:
022:        import org.apache.ojb.broker.metadata.MetadataManager;
023:        import org.kuali.kfs.KFSConstants;
024:        import org.kuali.module.gl.GLConstants;
025:        import org.kuali.module.gl.batch.poster.AccountBalanceCalculator;
026:        import org.kuali.module.gl.batch.poster.PostTransaction;
027:        import org.kuali.module.gl.bo.AccountBalance;
028:        import org.kuali.module.gl.bo.Transaction;
029:        import org.kuali.module.gl.dao.AccountBalanceDao;
030:        import org.springframework.transaction.annotation.Transactional;
031:
032:        @Transactional
033:        public class PostGlAccountBalance implements  PostTransaction,
034:                AccountBalanceCalculator {
035:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
036:                    .getLogger(PostGlAccountBalance.class);
037:
038:            private AccountBalanceDao accountBalanceDao;
039:
040:            public void setAccountBalanceDao(AccountBalanceDao abd) {
041:                accountBalanceDao = abd;
042:            }
043:
044:            /**
045:             * Constructs a PostGlAccountBalance instance
046:             */
047:            public PostGlAccountBalance() {
048:                super ();
049:            }
050:
051:            /**
052:             * Posts the transaction to the appropriate account balance record.
053:             * 
054:             * @param t the transaction which is being posted
055:             * @param mode the mode the poster is currently running in
056:             * @param postDate the date this transaction should post to
057:             * @return the accomplished post type
058:             * @see org.kuali.module.gl.batch.poster.PostTransaction#post(org.kuali.module.gl.bo.Transaction, int, java.util.Date)
059:             */
060:            public String post(Transaction t, int mode, Date postDate) {
061:                LOG.debug("post() started");
062:
063:                // Only post transactions where:
064:                // balance type code is AC or CB
065:                // or where object type isn't FB and balance type code is EX, IE, PE and CE
066:                if ((t.getFinancialBalanceTypeCode().equals(
067:                        t.getOption().getActualFinancialBalanceTypeCd()) || t
068:                        .getFinancialBalanceTypeCode().equals(
069:                                t.getOption().getBudgetCheckingBalanceTypeCd()))
070:                        || (t.getFinancialBalanceTypeCode().equals(
071:                                t.getOption().getExtrnlEncumFinBalanceTypCd())
072:                                || t
073:                                        .getFinancialBalanceTypeCode()
074:                                        .equals(
075:                                                t
076:                                                        .getOption()
077:                                                        .getIntrnlEncumFinBalanceTypCd())
078:                                || t
079:                                        .getFinancialBalanceTypeCode()
080:                                        .equals(
081:                                                t
082:                                                        .getOption()
083:                                                        .getPreencumbranceFinBalTypeCd()) || t
084:                                .getFinancialBalanceTypeCode()
085:                                .equals(
086:                                        t
087:                                                .getOption()
088:                                                .getCostShareEncumbranceBalanceTypeCd()))
089:                        && (!t.getFinancialObjectTypeCode().equals(
090:                                t.getOption().getFinObjectTypeFundBalanceCd()))) {
091:                    // We are posting this transaction
092:                    String returnCode = GLConstants.UPDATE_CODE;
093:
094:                    // Load it
095:                    AccountBalance ab = accountBalanceDao.getByTransaction(t);
096:
097:                    if (ab == null) {
098:                        returnCode = GLConstants.INSERT_CODE;
099:                        ab = new AccountBalance(t);
100:                    }
101:
102:                    ab.setTimestamp(new java.sql.Date(postDate.getTime()));
103:
104:                    if (!updateAccountBalanceReturn(t, ab)) {
105:                        return GLConstants.EMPTY_CODE;
106:                    }
107:
108:                    accountBalanceDao.save(ab);
109:
110:                    return returnCode;
111:                } else {
112:                    return GLConstants.EMPTY_CODE;
113:                }
114:            }
115:
116:            public AccountBalance findAccountBalance(Collection balanceList,
117:                    Transaction t) {
118:
119:                // Try to find one that already exists
120:                for (Iterator iter = balanceList.iterator(); iter.hasNext();) {
121:                    AccountBalance b = (AccountBalance) iter.next();
122:
123:                    if (b.getUniversityFiscalYear().equals(
124:                            t.getUniversityFiscalYear())
125:                            && b.getChartOfAccountsCode().equals(
126:                                    t.getChartOfAccountsCode())
127:                            && b.getAccountNumber()
128:                                    .equals(t.getAccountNumber())
129:                            && b.getSubAccountNumber().equals(
130:                                    t.getSubAccountNumber())
131:                            && b.getObjectCode().equals(
132:                                    t.getFinancialObjectCode())
133:                            && b.getSubObjectCode().equals(
134:                                    t.getFinancialSubObjectCode())) {
135:                        return b;
136:                    }
137:                }
138:
139:                // If we couldn't find one that exists, create a new one
140:                AccountBalance b = new AccountBalance(t);
141:                balanceList.add(b);
142:
143:                return b;
144:            }
145:
146:            private boolean updateAccountBalanceReturn(Transaction t,
147:                    AccountBalance ab) {
148:                if (t.getFinancialBalanceTypeCode().equals(
149:                        t.getOption().getBudgetCheckingBalanceTypeCd())) {
150:                    ab.setCurrentBudgetLineBalanceAmount(ab
151:                            .getCurrentBudgetLineBalanceAmount().add(
152:                                    t.getTransactionLedgerEntryAmount()));
153:                } else if (t.getFinancialBalanceTypeCode().equals(
154:                        t.getOption().getActualFinancialBalanceTypeCd())) {
155:                    if (t.getObjectType().getFinObjectTypeDebitcreditCd()
156:                            .equals(t.getTransactionDebitCreditCode())
157:                            || ((!t.getBalanceType()
158:                                    .isFinancialOffsetGenerationIndicator()) && KFSConstants.GL_BUDGET_CODE
159:                                    .equals(t.getTransactionDebitCreditCode()))) {
160:                        ab.setAccountLineActualsBalanceAmount(ab
161:                                .getAccountLineActualsBalanceAmount().add(
162:                                        t.getTransactionLedgerEntryAmount()));
163:                    } else {
164:                        ab.setAccountLineActualsBalanceAmount(ab
165:                                .getAccountLineActualsBalanceAmount().subtract(
166:                                        t.getTransactionLedgerEntryAmount()));
167:                    }
168:                } else if (t.getFinancialBalanceTypeCode().equals(
169:                        t.getOption().getExtrnlEncumFinBalanceTypCd())
170:                        || t.getFinancialBalanceTypeCode().equals(
171:                                t.getOption().getIntrnlEncumFinBalanceTypCd())
172:                        || t.getFinancialBalanceTypeCode().equals(
173:                                t.getOption().getPreencumbranceFinBalTypeCd())
174:                        || t
175:                                .getFinancialBalanceTypeCode()
176:                                .equals(
177:                                        t
178:                                                .getOption()
179:                                                .getCostShareEncumbranceBalanceTypeCd())) {
180:                    if (t.getObjectType().getFinObjectTypeDebitcreditCd()
181:                            .equals(t.getTransactionDebitCreditCode())
182:                            || ((!t.getBalanceType()
183:                                    .isFinancialOffsetGenerationIndicator()) && KFSConstants.GL_BUDGET_CODE
184:                                    .equals(t.getTransactionDebitCreditCode()))) {
185:                        ab.setAccountLineEncumbranceBalanceAmount(ab
186:                                .getAccountLineEncumbranceBalanceAmount().add(
187:                                        t.getTransactionLedgerEntryAmount()));
188:                    } else {
189:                        ab.setAccountLineEncumbranceBalanceAmount(ab
190:                                .getAccountLineEncumbranceBalanceAmount()
191:                                .subtract(t.getTransactionLedgerEntryAmount()));
192:                    }
193:                } else {
194:                    return false;
195:                }
196:                return true;
197:            }
198:
199:            /**
200:             * @param t
201:             * @param enc
202:             */
203:            public void updateAccountBalance(Transaction t, AccountBalance ab) {
204:                updateAccountBalanceReturn(t, ab);
205:            }
206:
207:            public String getDestinationName() {
208:                return MetadataManager.getInstance().getGlobalRepository()
209:                        .getDescriptorFor(AccountBalance.class)
210:                        .getFullTableName();
211:            }
212:        }
ww__w__.___j__ava_2___s._c__o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.