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


001:        /*
002:         * Copyright 2006-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.util;
017:
018:        import java.util.HashMap;
019:        import java.util.Map;
020:
021:        import org.apache.commons.lang.StringUtils;
022:
023:        /**
024:         * A collection of many LedgerEntry records, which appropriately groups the records
025:         */
026:        public class LedgerEntryHolder {
027:            private Map ledgerEntries;
028:            private Map subtotals;
029:            private LedgerEntry grandTotal;
030:
031:            private static final String GRAND_TOTAL = "Grand Total";
032:            private static final String SUB_TOTAL = "Subtotal";
033:
034:            /**
035:             * Constructs a LedgerEntryHolder.java.
036:             */
037:            public LedgerEntryHolder() {
038:                ledgerEntries = new HashMap();
039:                subtotals = new HashMap();
040:                grandTotal = new LedgerEntry(null, null, null, GRAND_TOTAL);
041:            }
042:
043:            /**
044:             * add a given ledger entry into the holder. If there exists a ledger entry with the same key, then update the amount and count
045:             * fields of the ledger entry; otherwise, insert it into the holder.
046:             * 
047:             * @param newLedgerEntry the given ledger entry
048:             * @param calculateTotals indicate if the subtotals and grand total need to be calculated
049:             */
050:            public void insertLedgerEntry(LedgerEntry newLedgerEntry,
051:                    boolean calculateTotal) {
052:                Integer fiscalYear = newLedgerEntry.getFiscalYear();
053:                String periodCode = newLedgerEntry.getPeriod();
054:
055:                String balanceType = newLedgerEntry.getBalanceType();
056:                String originCode = newLedgerEntry.getOriginCode();
057:
058:                String keyOfLedgerEntry = balanceType + "-" + originCode + "-"
059:                        + fiscalYear + "-" + periodCode;
060:
061:                if (!ledgerEntries.containsKey(keyOfLedgerEntry)) {
062:                    ledgerEntries.put(keyOfLedgerEntry, newLedgerEntry);
063:                } else {
064:                    LedgerEntry ledgerEntry = (LedgerEntry) ledgerEntries
065:                            .get(keyOfLedgerEntry);
066:                    ledgerEntry.add(newLedgerEntry);
067:                }
068:
069:                // calculate the subtotals and grand total
070:                if (calculateTotal) {
071:                    updateSubtotal(newLedgerEntry);
072:                    updateGrandTotal(newLedgerEntry);
073:                }
074:            }
075:
076:            /**
077:             * update the subtotal using the given ledger entry
078:             * 
079:             * @param newLedgerEntry a new ledger entry to add to the holder
080:             */
081:            private void updateSubtotal(LedgerEntry newLedgerEntry) {
082:                String groupingKey = newLedgerEntry.getBalanceType();
083:
084:                if (StringUtils.isBlank(groupingKey)) {
085:                    return;
086:                }
087:
088:                LedgerEntry ledgerEntry = null;
089:                if (!subtotals.containsKey(groupingKey)) {
090:                    ledgerEntry = new LedgerEntry(null, "", newLedgerEntry
091:                            .getBalanceType(), SUB_TOTAL);
092:                    subtotals.put(groupingKey, ledgerEntry);
093:                } else {
094:                    ledgerEntry = (LedgerEntry) subtotals.get(groupingKey);
095:                }
096:                ledgerEntry.add(newLedgerEntry);
097:            }
098:
099:            /**
100:             * update the grand total with the given ledger entry
101:             * 
102:             * @param newLedgerEntry entry to help update the grand total
103:             */
104:            private void updateGrandTotal(LedgerEntry newLedgerEntry) {
105:                this .grandTotal.add(newLedgerEntry);
106:            }
107:
108:            /**
109:             * Gets the grandTotal attribute.
110:             * 
111:             * @return Returns the grandTotal.
112:             */
113:            public LedgerEntry getGrandTotal() {
114:                return grandTotal;
115:            }
116:
117:            /**
118:             * Gets the ledgerEntries attribute.
119:             * 
120:             * @return Returns the ledgerEntries.
121:             */
122:            public Map getLedgerEntries() {
123:                return ledgerEntries;
124:            }
125:
126:            /**
127:             * Gets the subtotals attribute.
128:             * 
129:             * @return Returns the subtotals.
130:             */
131:            public Map getSubtotals() {
132:                return subtotals;
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.