Source Code Cross Referenced for PayeeDocumentPreRules.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » rules » 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.rules 
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.rules;
017:
018:        import org.apache.commons.lang.StringUtils;
019:        import org.kuali.core.document.Document;
020:        import org.kuali.core.document.MaintenanceDocument;
021:        import org.kuali.core.rules.PreRulesContinuationBase;
022:        import org.kuali.core.service.BusinessObjectService;
023:        import org.kuali.core.service.KualiConfigurationService;
024:        import org.kuali.kfs.KFSConstants;
025:        import org.kuali.kfs.KFSKeyConstants;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.kfs.service.ParameterEvaluator;
028:        import org.kuali.kfs.service.ParameterService;
029:        import org.kuali.module.financial.bo.Payee;
030:        import org.kuali.module.financial.document.DisbursementVoucherDocument;
031:
032:        /**
033:         * Checks warnings and prompt conditions for PayeeDocument.
034:         */
035:        public class PayeeDocumentPreRules extends PreRulesContinuationBase
036:                implements  DisbursementVoucherRuleConstants {
037:
038:            /**
039:             * Default method called to perform pre-rules checks.  All subsequent rule checks performed by the pre-rules will be 
040:             * initiated from this method.  This method tracks the results of all the pre-rule checks and returns a boolean 
041:             * identifying if the pre-rules successfully passed all the checks.
042:             * 
043:             * @param document The document being validated.
044:             * @return True if all the pre-rule checks succeeded, false otherwise.
045:             * 
046:             * @see org.kuali.core.rules.PreRulesContinuationBase#doRules(org.kuali.core.document.MaintenanceDocument)
047:             */
048:            public boolean doRules(Document document) {
049:                MaintenanceDocument maintenanceDocument = (MaintenanceDocument) document;
050:                boolean preRulesOK = true;
051:
052:                preRulesOK &= performW9Warning(maintenanceDocument);
053:
054:                preRulesOK &= checkPayeeName(maintenanceDocument);
055:
056:                preRulesOK &= askNewTaxAddressLineCopy(maintenanceDocument);
057:
058:                preRulesOK &= askChangeTaxAddressLineCopy(maintenanceDocument);
059:
060:                return preRulesOK;
061:            }
062:
063:            /**
064:             * If the w9 indicator has been selected for the first time, give notice about W9 regulations. If the w9 indicator 
065:             * has not been selected, give missing W9 warning. Forms change depending on the alien indicator.
066:             * 
067:             * @param document The document being validated.
068:             * @return True if the provided maintenance document does not require any warnings related to W9 regulations, false otherwise.
069:             */
070:            private boolean performW9Warning(MaintenanceDocument document) {
071:                Payee oldPayee = (Payee) document.getOldMaintainableObject()
072:                        .getBusinessObject();
073:                Payee newPayee = (Payee) document.getNewMaintainableObject()
074:                        .getBusinessObject();
075:
076:                /**
077:                 * give warning about required tax forms
078:                 */
079:                String warningText = "";
080:                boolean warningNeeded = false;
081:                if (!oldPayee.isPayeeW9CompleteCode()
082:                        && newPayee.isPayeeW9CompleteCode()) {
083:                    ParameterEvaluator evaluator = SpringContext.getBean(
084:                            ParameterService.class).getParameterEvaluator(
085:                            DisbursementVoucherDocument.class,
086:                            W9_OWNERSHIP_TYPES_PARM_NM,
087:                            newPayee.getPayeeOwnershipTypCd());
088:                    if (evaluator.evaluationSucceeds()) {
089:                        warningNeeded = true;
090:                        if (newPayee.isAlienPaymentCode()) {
091:                            warningText = SpringContext
092:                                    .getBean(KualiConfigurationService.class)
093:                                    .getPropertyString(
094:                                            KFSKeyConstants.WARNING_DV_W9_ALIEN);
095:                        } else {
096:                            warningText = SpringContext
097:                                    .getBean(KualiConfigurationService.class)
098:                                    .getPropertyString(
099:                                            KFSKeyConstants.WARNING_DV_W9_NONALIEN);
100:                        }
101:                    }
102:                } else if (!oldPayee.isPayeeW9CompleteCode()
103:                        && !newPayee.isPayeeW9CompleteCode()) {
104:                    warningNeeded = true;
105:                    if (newPayee.isAlienPaymentCode()) {
106:                        warningText = SpringContext
107:                                .getBean(KualiConfigurationService.class)
108:                                .getPropertyString(
109:                                        KFSKeyConstants.WARNING_MISSING_DV_W9_ALIEN);
110:                    } else {
111:                        warningText = SpringContext
112:                                .getBean(KualiConfigurationService.class)
113:                                .getPropertyString(
114:                                        KFSKeyConstants.WARNING_MISSING_DV_W9_NONALIEN);
115:                    }
116:                }
117:
118:                if (warningNeeded) {
119:                    boolean confirmedW9Warning = super 
120:                            .askOrAnalyzeYesNoQuestion(
121:                                    KFSConstants.PAYEE_W9_QUESTION, warningText);
122:                    if (!confirmedW9Warning) {
123:                        super .abortRulesCheck();
124:                    }
125:                }
126:
127:                return true;
128:            }
129:
130:            /**
131:             * If the payee is new, checks for the existence of the name in the payee database, if not found, ask the user to 
132:             * confirm they want to add the new payee.
133:             * 
134:             * @param document The document the payee will be added to.
135:             * @return True if the name was found in the database or if the user wishes to add the new payee, false otherwise.
136:             */
137:            private boolean checkPayeeName(MaintenanceDocument document) {
138:                Payee oldPayee = (Payee) document.getOldMaintainableObject()
139:                        .getBusinessObject();
140:                Payee newPayee = (Payee) document.getNewMaintainableObject()
141:                        .getBusinessObject();
142:
143:                boolean confirmPayeeName = false;
144:                // only check name if this is a new payee
145:                if (!isExistingPayee(newPayee.getPayeeIdNumber())) {
146:                    String payeeName = newPayee.getPayeePersonName();
147:                    if (StringUtils.isNotBlank(payeeName)) {
148:                        // check payee table for existence of new name
149:                        Payee payee = new Payee();
150:                        payee.setPayeePersonName(payeeName);
151:
152:                        payee = (Payee) SpringContext.getBean(
153:                                BusinessObjectService.class).retrieve(payee);
154:                        if (payee != null) {
155:                            confirmPayeeName = true;
156:                        }
157:                    }
158:                }
159:
160:                // if name was found for new payee, confirm they want to add the new payee id number
161:                if (confirmPayeeName) {
162:                    String questionText = SpringContext.getBean(
163:                            KualiConfigurationService.class).getPropertyString(
164:                            KFSKeyConstants.QUESTION_EXISTING_PAYEE_NAME);
165:                    boolean addPayee = super .askOrAnalyzeYesNoQuestion(
166:                            KFSConstants.PAYEE_NAME_EXIST_QUESTION,
167:                            questionText);
168:                    if (!addPayee) {
169:                        super .abortRulesCheck();
170:                    }
171:                }
172:
173:                return true;
174:            }
175:
176:            /**
177:             * If this is a new payee, and the first tax address line has not been completed, ask if the user wants to copy 
178:             * the payee's address lines to the tax address lines.
179:             * 
180:             * @param document The document being validated.
181:             * @return This method always returns true. 
182:             */
183:            private boolean askNewTaxAddressLineCopy(
184:                    MaintenanceDocument document) {
185:                Payee oldPayee = (Payee) document.getOldMaintainableObject()
186:                        .getBusinessObject();
187:                Payee newPayee = (Payee) document.getNewMaintainableObject()
188:                        .getBusinessObject();
189:
190:                if (!isExistingPayee(newPayee.getPayeeIdNumber())
191:                        && StringUtils.isBlank(newPayee.getTaxpayerLine1Addr())) {
192:                    String questionText = SpringContext
193:                            .getBean(KualiConfigurationService.class)
194:                            .getPropertyString(
195:                                    KFSKeyConstants.QUESTION_COPY_NEW_PAYEE_ADDRESS_LINES);
196:                    boolean copyAddressLines = super .askOrAnalyzeYesNoQuestion(
197:                            KFSConstants.COPY_NEW_PAYEE_ADDRESS_LINES,
198:                            questionText);
199:                    if (copyAddressLines) {
200:                        copyAddressLinesToTaxAddress(newPayee);
201:                    }
202:                }
203:
204:                return true;
205:            }
206:
207:            /**
208:             * If this payee address lines have changed, ask if they want to copy the payee's address lines to the tax address lines.
209:             * 
210:             * @param document The document being validated.
211:             * @return This method always returns true.
212:             */
213:            private boolean askChangeTaxAddressLineCopy(
214:                    MaintenanceDocument document) {
215:                Payee oldPayee = (Payee) document.getOldMaintainableObject()
216:                        .getBusinessObject();
217:                Payee newPayee = (Payee) document.getNewMaintainableObject()
218:                        .getBusinessObject();
219:
220:                if (isExistingPayee(newPayee.getPayeeIdNumber())) {
221:                    if ((newPayee.getPayeeLine1Addr() != null && !newPayee
222:                            .getPayeeLine1Addr().equals(
223:                                    oldPayee.getPayeeLine1Addr()))
224:                            || (newPayee.getPayeeLine2Addr() != null && !newPayee
225:                                    .getPayeeLine2Addr().equals(
226:                                            oldPayee.getPayeeLine2Addr()))
227:                            || (newPayee.getPayeeCityName() != null && !newPayee
228:                                    .getPayeeCityName().equals(
229:                                            oldPayee.getPayeeCityName()))
230:                            || (newPayee.getPayeeStateCode() != null && !newPayee
231:                                    .getPayeeStateCode().equals(
232:                                            oldPayee.getPayeeStateCode()))
233:                            || (newPayee.getPayeeZipCode() != null && !newPayee
234:                                    .getPayeeZipCode().equals(
235:                                            oldPayee.getPayeeZipCode()))
236:                            || (newPayee.getPayeeCountryCode() != null && !newPayee
237:                                    .getPayeeCountryCode().equals(
238:                                            oldPayee.getPayeeCountryCode()))) {
239:                        String questionText = SpringContext
240:                                .getBean(KualiConfigurationService.class)
241:                                .getPropertyString(
242:                                        KFSKeyConstants.QUESTION_COPY_CHANGED_PAYEE_ADDRESS_LINES);
243:
244:                        boolean copyAddressLines = super 
245:                                .askOrAnalyzeYesNoQuestion(
246:                                        KFSConstants.COPY_CHANGE_PAYEE_ADDRESS_LINES,
247:                                        questionText);
248:                        if (copyAddressLines) {
249:                            copyAddressLinesToTaxAddress(newPayee);
250:                        }
251:                    }
252:                }
253:
254:                return true;
255:            }
256:
257:            /**
258:             * Copies the payee's address lines to the payee's tax address lines.
259:             * 
260:             * @param payee The payee whose tax address is being updated from its address.
261:             */
262:            private void copyAddressLinesToTaxAddress(Payee payee) {
263:                payee.setTaxpayerLine1Addr(payee.getPayeeLine1Addr());
264:                payee.setTaxpayerLine2Addr(payee.getPayeeLine2Addr());
265:                payee.setTaxpayerCityName(payee.getPayeeCityName());
266:                payee.setTaxpayerStateCode(payee.getPayeeStateCode());
267:                payee.setTaxpayerZipCode(payee.getPayeeZipCode());
268:                payee.setTaxpayerCountryCode(payee.getPayeeCountryCode());
269:            }
270:
271:            /**
272:             * Queries the payee table for the given id number and returns true if a payee was found.
273:             * 
274:             * @param payeeIDNumber The payee id number to search for in the database payee table.
275:             * @return True if the payee id number was found in the database, false otherwise.
276:             */
277:            private boolean isExistingPayee(String payeeIDNumber) {
278:                boolean exists = false;
279:
280:                Payee payee = new Payee();
281:                payee.setPayeeIdNumber(payeeIDNumber);
282:
283:                payee = (Payee) SpringContext.getBean(
284:                        BusinessObjectService.class).retrieve(payee);
285:                if (payee != null) {
286:                    exists = true;
287:                }
288:
289:                return exists;
290:            }
291:
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.