Source Code Cross Referenced for PostBalance.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.kuali.core.util.KualiDecimal;
023:        import org.kuali.kfs.context.SpringContext;
024:        import org.kuali.module.financial.service.UniversityDateService;
025:        import org.kuali.module.gl.batch.poster.BalanceCalculator;
026:        import org.kuali.module.gl.batch.poster.PostTransaction;
027:        import org.kuali.module.gl.bo.Balance;
028:        import org.kuali.module.gl.bo.Transaction;
029:        import org.kuali.module.gl.bo.UniversityDate;
030:        import org.kuali.module.gl.dao.BalanceDao;
031:        import org.springframework.transaction.annotation.Transactional;
032:
033:        /**
034:         * This implementation of PostTransaction updates the appropriate Balance
035:         */
036:        @Transactional
037:        public class PostBalance implements  PostTransaction, BalanceCalculator {
038:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
039:                    .getLogger(PostBalance.class);
040:
041:            private BalanceDao balanceDao;
042:
043:            /**
044:             * Constructs a PostBalance instance
045:             */
046:            public PostBalance() {
047:                super ();
048:            }
049:
050:            /**
051:             * This posts the effect of the transaction upon the appropriate balance record.
052:             * 
053:             * @param t the transaction which is being posted
054:             * @param mode the mode the poster is currently running in
055:             * @param postDate the date this transaction should post to
056:             * @return the accomplished post type
057:             * @see org.kuali.module.gl.batch.poster.PostTransaction#post(org.kuali.module.gl.bo.Transaction, int, java.util.Date)
058:             */
059:            public String post(Transaction t, int mode, Date postDate) {
060:                LOG.debug("post() started");
061:
062:                String postType = "U";
063:
064:                KualiDecimal amount = t.getTransactionLedgerEntryAmount();
065:
066:                // Subtract the amount if offset generation indicator & the debit/credit code isn't the same
067:                // as the one in the object type code table
068:                if (t.getBalanceType().isFinancialOffsetGenerationIndicator()) {
069:                    if (!t.getTransactionDebitCreditCode().equals(
070:                            t.getObjectType().getFinObjectTypeDebitcreditCd())) {
071:                        amount = amount.multiply(new KualiDecimal(-1));
072:                    }
073:                }
074:
075:                Balance b = balanceDao.getBalanceByTransaction(t);
076:                if (b == null) {
077:                    postType = "I";
078:                    b = new Balance(t);
079:                }
080:                b.setTimestamp(new java.sql.Date(postDate.getTime()));
081:
082:                String period = t.getUniversityFiscalPeriodCode();
083:                b.addAmount(period, amount);
084:
085:                balanceDao.save(b);
086:
087:                return postType;
088:            }
089:
090:            /**
091:             * Given a list of balances, determines which one the given trsnaction should post to
092:             * 
093:             * @param balanceList a Collection of balances
094:             * @param t the transaction that is being posted
095:             * @return the balance, either found from the list, or, if not present in the list, newly created
096:             * @see org.kuali.module.gl.batch.poster.BalanceCalculator#findBalance(java.util.Collection, org.kuali.module.gl.bo.Transaction)
097:             */
098:            public Balance findBalance(Collection balanceList, Transaction t) {
099:                // Try to find one that already exists
100:                for (Iterator iter = balanceList.iterator(); iter.hasNext();) {
101:                    Balance b = (Balance) iter.next();
102:
103:                    if (b.getUniversityFiscalYear().equals(
104:                            t.getUniversityFiscalYear())
105:                            && b.getChartOfAccountsCode().equals(
106:                                    t.getChartOfAccountsCode())
107:                            && b.getAccountNumber()
108:                                    .equals(t.getAccountNumber())
109:                            && b.getSubAccountNumber().equals(
110:                                    t.getSubAccountNumber())
111:                            && b.getObjectCode().equals(
112:                                    t.getFinancialObjectCode())
113:                            && b.getSubObjectCode().equals(
114:                                    t.getFinancialSubObjectCode())
115:                            && b.getBalanceTypeCode().equals(
116:                                    t.getFinancialBalanceTypeCode())
117:                            && b.getObjectTypeCode().equals(
118:                                    t.getFinancialObjectTypeCode())) {
119:                        return b;
120:                    }
121:                }
122:
123:                // If we couldn't find one that exists, create a new one
124:                Balance b = new Balance(t);
125:                balanceList.add(b);
126:
127:                return b;
128:            }
129:
130:            /**
131:             * @param t
132:             * @param enc
133:             */
134:            public void updateBalance(Transaction t, Balance b) {
135:
136:                // The pending entries haven't been scrubbed so there could be
137:                // bad data. This won't update a balance if the data it needs
138:                // is invalid
139:                KualiDecimal amount = t.getTransactionLedgerEntryAmount();
140:                if (amount == null) {
141:                    amount = KualiDecimal.ZERO;
142:                }
143:
144:                if (t.getObjectType() == null) {
145:                    LOG.error("updateBalance() Invalid object type ("
146:                            + t.getFinancialObjectTypeCode()
147:                            + ") in pending table");
148:                    return;
149:                }
150:
151:                if (t.getBalanceType() == null) {
152:                    LOG.error("updateBalance() Invalid balance type ("
153:                            + t.getFinancialBalanceTypeCode()
154:                            + ") in pending table");
155:                    return;
156:                }
157:
158:                // Subtract the amount if offset generation indicator & the debit/credit code isn't the same
159:                // as the one in the object type code table
160:                if (t.getBalanceType().isFinancialOffsetGenerationIndicator()) {
161:                    if (!t.getTransactionDebitCreditCode().equals(
162:                            t.getObjectType().getFinObjectTypeDebitcreditCd())) {
163:                        amount = amount.multiply(new KualiDecimal(-1));
164:                    }
165:                }
166:
167:                // update the balance amount of the cooresponding period
168:                String period = t.getUniversityFiscalPeriodCode();
169:                if (period == null) {
170:                    UniversityDate currentUniversityDate = SpringContext
171:                            .getBean(UniversityDateService.class)
172:                            .getCurrentUniversityDate();
173:                    period = currentUniversityDate
174:                            .getUniversityFiscalAccountingPeriod();
175:                }
176:
177:                b.addAmount(period, amount);
178:            }
179:
180:            /**
181:             * @see org.kuali.module.gl.batch.poster.PostTransaction#getDestinationName()
182:             */
183:            public String getDestinationName() {
184:                return "GL_BALANCE_T";
185:            }
186:
187:            public void setBalanceDao(BalanceDao bd) {
188:                balanceDao = bd;
189:            }
190:        }
www.__j__a___v___a2___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.