Source Code Cross Referenced for JournalVoucherForm.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » web » struts » form » 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.financial.web.struts.form 
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.financial.web.struts.form;
017:
018:        import java.util.ArrayList;
019:        import java.util.List;
020:
021:        import javax.servlet.http.HttpServletRequest;
022:
023:        import org.apache.commons.lang.StringUtils;
024:        import org.kuali.kfs.KFSConstants;
025:        import org.kuali.kfs.bo.SourceAccountingLine;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.module.chart.bo.codes.BalanceTyp;
028:        import org.kuali.module.chart.service.BalanceTypService;
029:        import org.kuali.module.financial.document.JournalVoucherDocument;
030:
031:        /**
032:         * This class is the Struts specific form object that works in conjunction with the pojo utilities to build the UI for the Journal
033:         * Voucher Document. This class is unique in that it leverages a helper data structure called the VoucherAccountingLineHelper
034:         * because the Journal Voucher, under certain conditions, presents the user with a debit and credit column for amount entry. In
035:         * addition, this form class must keep track of the changes between the old and new balance type selection so that the corresponding
036:         * action class and make decisions based upon the differences. New accounting lines use specific credit and debit amount fields b/c
037:         * the new line is explicitly known; however, already existing accounting lines need to exist within a list with ordering that
038:         * matches the accounting lines source list.
039:         */
040:        public class JournalVoucherForm extends VoucherForm {
041:            private List balanceTypes;
042:            private String originalBalanceType;
043:            private BalanceTyp selectedBalanceType;
044:
045:            /**
046:             * Constructs a JournalVoucherForm instance.
047:             */
048:            public JournalVoucherForm() {
049:                super ();
050:                setDocument(new JournalVoucherDocument());
051:                selectedBalanceType = new BalanceTyp(
052:                        KFSConstants.BALANCE_TYPE_ACTUAL);
053:                originalBalanceType = "";
054:            }
055:
056:            /**
057:             * Overrides the parent to call super.populate and then to call the two methods that are specific to loading the two select
058:             * lists on the page. In addition, this also makes sure that the credit and debit amounts are filled in for situations where
059:             * validation errors occur and the page reposts.
060:             * 
061:             * @see org.kuali.core.web.struts.pojo.PojoForm#populate(javax.servlet.http.HttpServletRequest)
062:             */
063:            public void populate(HttpServletRequest request) {
064:                super .populate(request);
065:                populateBalanceTypeListForRendering();
066:            }
067:
068:            /**
069:             * Override the parent, to push the chosen accounting period and balance type down into the source accounting line object. In
070:             * addition, check the balance type to see if it's the "External Encumbrance" balance and alter the encumbrance update code on
071:             * the accounting line appropriately.
072:             * 
073:             * @see org.kuali.core.web.struts.form.KualiTransactionalDocumentFormBase#populateSourceAccountingLine(org.kuali.core.bo.SourceAccountingLine)
074:             */
075:            public void populateSourceAccountingLine(
076:                    SourceAccountingLine sourceLine) {
077:                super .populateSourceAccountingLine(sourceLine);
078:                populateSourceAccountingLineEncumbranceCode(sourceLine);
079:            }
080:
081:            /**
082:             * Sets the encumbrance code of the line based on the balance type.
083:             * 
084:             * @param sourceLine - line to set code on
085:             */
086:            protected void populateSourceAccountingLineEncumbranceCode(
087:                    SourceAccountingLine sourceLine) {
088:                BalanceTyp selectedBalanceType = getSelectedBalanceType();
089:                if (selectedBalanceType != null
090:                        && StringUtils
091:                                .isNotBlank(selectedBalanceType.getCode())) {
092:                    sourceLine.setBalanceTyp(selectedBalanceType);
093:                    sourceLine
094:                            .setBalanceTypeCode(selectedBalanceType.getCode());
095:
096:                    // set the encumbrance update code appropriately
097:                    if (KFSConstants.BALANCE_TYPE_EXTERNAL_ENCUMBRANCE
098:                            .equals(selectedBalanceType.getCode())) {
099:                        sourceLine
100:                                .setEncumbranceUpdateCode(KFSConstants.JOURNAL_VOUCHER_ENCUMBRANCE_UPDATE_CODE_BALANCE_TYPE_EXTERNAL_ENCUMBRANCE);
101:                    } else {
102:                        sourceLine.setEncumbranceUpdateCode(null);
103:                    }
104:                } else {
105:                    // it's the first time in, the form will be empty the first time in
106:                    // set up default selection value
107:                    selectedBalanceType = SpringContext.getBean(
108:                            BalanceTypService.class).getBalanceTypByCode(
109:                            KFSConstants.BALANCE_TYPE_ACTUAL);
110:                    setSelectedBalanceType(selectedBalanceType);
111:                    setOriginalBalanceType(selectedBalanceType.getCode());
112:
113:                    sourceLine.setEncumbranceUpdateCode(null);
114:                }
115:            }
116:
117:            /**
118:             * This method retrieves the list of valid balance types to display.
119:             * 
120:             * @return List
121:             */
122:            public List getBalanceTypes() {
123:                return balanceTypes;
124:            }
125:
126:            /**
127:             * This method sets the selected balance type.
128:             * 
129:             * @return BalanceTyp
130:             */
131:            public BalanceTyp getSelectedBalanceType() {
132:                return selectedBalanceType;
133:            }
134:
135:            /**
136:             * This method retrieves the selected balance type.
137:             * 
138:             * @param selectedBalanceType
139:             */
140:            public void setSelectedBalanceType(BalanceTyp selectedBalanceType) {
141:                this .selectedBalanceType = selectedBalanceType;
142:            }
143:
144:            /**
145:             * This method sets the list of valid balance types to display.
146:             * 
147:             * @param balanceTypes
148:             */
149:            public void setBalanceTypes(List balanceTypes) {
150:                this .balanceTypes = balanceTypes;
151:            }
152:
153:            /**
154:             * This method returns the journal voucher document associated with this form.
155:             * 
156:             * @return Returns the journalVoucherDocument.
157:             */
158:            public JournalVoucherDocument getJournalVoucherDocument() {
159:                return (JournalVoucherDocument) getTransactionalDocument();
160:            }
161:
162:            /**
163:             * This method sets the journal voucher document associated with this form.
164:             * 
165:             * @param journalVoucherDocument The journalVoucherDocument to set.
166:             */
167:            public void setJournalVoucherDocument(
168:                    JournalVoucherDocument journalVoucherDocument) {
169:                setDocument(journalVoucherDocument);
170:            }
171:
172:            /**
173:             * This method retrieves the originalBalanceType attribute.
174:             * 
175:             * @return String
176:             */
177:            public String getOriginalBalanceType() {
178:                return originalBalanceType;
179:            }
180:
181:            /**
182:             * This method sets the originalBalanceType attribute.
183:             * 
184:             * @param changedBalanceType
185:             */
186:            public void setOriginalBalanceType(String changedBalanceType) {
187:                this .originalBalanceType = changedBalanceType;
188:            }
189:
190:            /**
191:             * This method retrieves all of the balance types in the system and prepares them to be rendered in a dropdown UI component.
192:             */
193:            private void populateBalanceTypeListForRendering() {
194:                // grab the list of valid balance types
195:                ArrayList balanceTypes = new ArrayList(SpringContext.getBean(
196:                        BalanceTypService.class).getAllBalanceTyps());
197:
198:                // set into the form for rendering
199:                this .setBalanceTypes(balanceTypes);
200:
201:                String selectedBalanceTypeCode = getSelectedBalanceType()
202:                        .getCode();
203:                if (StringUtils.isBlank(selectedBalanceTypeCode)) {
204:                    selectedBalanceTypeCode = KFSConstants.BALANCE_TYPE_ACTUAL;
205:                }
206:
207:                setSelectedBalanceType(getPopulatedBalanceTypeInstance(selectedBalanceTypeCode));
208:                getJournalVoucherDocument().setBalanceTypeCode(
209:                        selectedBalanceTypeCode);
210:            }
211:
212:            /**
213:             * This method will fully populate a balance type given the passed in code, by calling the business object service that
214:             * retrieves the rest of the instances' information.
215:             * 
216:             * @param balanceTypeCode
217:             * @return BalanceTyp
218:             */
219:            protected BalanceTyp getPopulatedBalanceTypeInstance(
220:                    String balanceTypeCode) {
221:                // now we have to get the code and the name of the original and new balance types
222:                BalanceTypService bts = SpringContext
223:                        .getBean(BalanceTypService.class);
224:                return bts.getBalanceTypByCode(balanceTypeCode);
225:            }
226:
227:            /**
228:             * If the balance type is an offset generation balance type, then the user is able to enter the amount as either a debit or a
229:             * credit, otherwise, they only need to deal with the amount field in this case we always need to update the underlying bo so
230:             * that the debit/credit code along with the amount, is properly set.
231:             */
232:            protected void populateCreditAndDebitAmounts() {
233:                if (isSelectedBalanceTypeFinancialOffsetGenerationIndicator()) {
234:                    super .populateCreditAndDebitAmounts();
235:                }
236:            }
237:
238:            /**
239:             * This is a convenience helper method that is used several times throughout this action class to determine if the selected
240:             * balance type contained within the form instance is a financial offset generation balance type or not.
241:             * 
242:             * @return boolean True if it is an offset generation balance type, false otherwise.
243:             */
244:            private boolean isSelectedBalanceTypeFinancialOffsetGenerationIndicator() {
245:                return getPopulatedBalanceTypeInstance(
246:                        getSelectedBalanceType().getCode())
247:                        .isFinancialOffsetGenerationIndicator();
248:            }
249:        }
w__w___w__.j__a___v___a__2__s__.__co__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.