Source Code Cross Referenced for PayeeDocumentRule.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.MaintenanceDocument;
020:        import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase;
021:        import org.kuali.core.service.KualiConfigurationService;
022:        import org.kuali.core.util.GlobalVariables;
023:        import org.kuali.kfs.KFSConstants;
024:        import org.kuali.kfs.KFSKeyConstants;
025:        import org.kuali.kfs.KFSPropertyConstants;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.module.financial.bo.Payee;
028:        import org.kuali.module.financial.service.DisbursementVoucherTaxService;
029:
030:        /**
031:         * Business rules for the Payee maintenance document.
032:         */
033:        public class PayeeDocumentRule extends MaintenanceDocumentRuleBase
034:                implements  DisbursementVoucherRuleConstants {
035:
036:            /**
037:             * This method performs custom route business rule checks on the document being routed.  The rules include 
038:             * checking the tax id number and the presense of all required fields for the associated Payee instance.
039:             * 
040:             * @param document The document being routed.
041:             * @return True if all the business rules pass, false otherwise.
042:             * 
043:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules
044:             */
045:            @Override
046:            public boolean processCustomRouteDocumentBusinessRules(
047:                    MaintenanceDocument maintenanceDocument) {
048:                Payee payee = (Payee) maintenanceDocument
049:                        .getNewMaintainableObject().getBusinessObject();
050:
051:                checkTaxIDNumber(payee);
052:                checkRequiredFields(payee);
053:
054:                // Payment reason not passed in payee maintenance document, no checks for required tax id number
055:                //
056:                // 1-1 if ($$curr_state = $$screate | $$curr_state = $$snew)
057:                // 2-2 if ($new_payee$)
058:                // 3-2 $$error_message = "A new payee ID number has already been created."
059:                // 4-2 call fp_final_errmsg
060:                // 5-2 return $$failure
061:                // 6-2 else
062:                // 7-2 run "fp_h0072"
063:                // 8-3 if ($status = $$success)
064:                // 9-3 dv_payee_id_nbr.fp_dv_pend_payee_t = $1
065:                // 10-4 if(dv_payee_cntry_nm.fp_dv_pend_payee_t = "")
066:                // 11-4 dv_payee_cntry_nm.fp_dv_pend_payee_t = "USA"
067:                // 12-4 endif
068:                // 13-3 dv_payee_entry_dt.fp_dv_pend_payee_t = $$today
069:                // 14-3 dv_taxctrl_mdfy_dt.fp_dv_pend_payee_t = $$today
070:                // 15-3 $new_payee$ = $$true
071:                // 16-3 endif
072:                // 17-2 endif
073:                //       
074:                //       
075:                //       
076:                // ;Only people in DV_TAXGRP can update controls and tax code
077:                // sql "select fs_work_grp_id from fs_work_grp_usr_t where person_unvl_id %\
078:                // = '%%$$universal_id' and fs_work_grp_id = 'DV_TAXGRP'","DEF"
079:                // if ($status = 0)
080:                // field_syntax dv_payee_txctrl_cd.fp_dv_pend_payee_t, "NED,NPR"
081:                // field_video dv_payee_txctrl_cd.fp_dv_pend_payee_t, "COL=27"
082:                // field_syntax dv_payee_tax_cd.fp_dv_pend_payee_t, "NED,NPR"
083:                // field_video dv_payee_tax_cd.fp_dv_pend_payee_t, "COL=27"
084:
085:                return GlobalVariables.getErrorMap().isEmpty();
086:            }
087:
088:            /**
089:             * Checks that the given tax id number is not being used for another payee, vendor, or employee.  This method 
090:             * posts errors to the error map, but does not otherwise indicate any problems occurred.  
091:             * 
092:             * @param payee The payee whose tax id number will be validated.
093:             */
094:            private void checkTaxIDNumber(Payee payee) {
095:                DisbursementVoucherTaxService taxIDService = SpringContext
096:                        .getBean(DisbursementVoucherTaxService.class);
097:                KualiConfigurationService kualiConfigurationService = SpringContext
098:                        .getBean(KualiConfigurationService.class);
099:
100:                String taxIDNumber = payee.getTaxIdNumber();
101:                String taxIDType = payee.getTaxpayerTypeCode();
102:                Integer foundType = null;
103:
104:                if (StringUtils.isNotBlank(taxIDNumber)
105:                        && StringUtils.isNotBlank(taxIDType)) {
106:                    String institutionFeinNumber = kualiConfigurationService
107:                            .getPropertyString(KFSKeyConstants.INSTITUTION_TAX_FEIN_NUMBER);
108:                    if (taxIDNumber.equals(institutionFeinNumber)
109:                            && TAX_TYPE_FEIN.equals(taxIDType)) {
110:                        putFieldError(KFSPropertyConstants.TAX_ID_NUMBER,
111:                                KFSKeyConstants.ERROR_FOUND_TAX_ID_INSTITUTION);
112:                    } else {
113:                        // vendor
114:                        String vendorId = taxIDService.getVendorId(taxIDNumber,
115:                                taxIDType);
116:                        if (vendorId != null) {
117:                            putFieldError(KFSPropertyConstants.TAX_ID_NUMBER,
118:                                    KFSKeyConstants.ERROR_FOUND_TAX_ID_VENDOR,
119:                                    vendorId);
120:                        } else {
121:                            // payee
122:                            String payeeId = taxIDService.getPayeeId(
123:                                    taxIDNumber, taxIDType);
124:                            if (payeeId != null
125:                                    && !payee.getPayeeIdNumber()
126:                                            .equals(payeeId)) {
127:                                putFieldError(
128:                                        KFSPropertyConstants.TAX_ID_NUMBER,
129:                                        KFSKeyConstants.ERROR_FOUND_TAX_ID_PAYEE,
130:                                        payeeId);
131:                            } else {
132:                                // pending payee
133:                                String pendingPayeeId = taxIDService
134:                                        .getPendingPayeeId(taxIDNumber,
135:                                                taxIDType);
136:                                if (pendingPayeeId != null
137:                                        && !payee.getPayeeIdNumber().equals(
138:                                                pendingPayeeId)) {
139:                                    putFieldError(
140:                                            KFSPropertyConstants.TAX_ID_NUMBER,
141:                                            KFSKeyConstants.ERROR_FOUND_TAX_ID_PEND_PAYEE,
142:                                            pendingPayeeId);
143:                                } else {
144:                                    // employee
145:                                    String universalId = taxIDService
146:                                            .getUniversalId(taxIDNumber,
147:                                                    taxIDType);
148:                                    if (universalId != null) {
149:                                        if (!payee.isPayeeEmployeeCode()) {
150:                                            putFieldError(
151:                                                    KFSPropertyConstants.TAX_ID_NUMBER,
152:                                                    KFSKeyConstants.ERROR_FOUND_TAX_ID_EMPL);
153:                                        }
154:                                    }
155:                                    /* employee flag can only be selected if it really is an employee */
156:                                    else if (payee.isPayeeEmployeeCode()) {
157:                                        putFieldError(
158:                                                KFSPropertyConstants.PAYEE_EMPLOYEE_CODE,
159:                                                KFSKeyConstants.ERROR_EMPL_FLAG);
160:                                    }
161:                                }
162:                            }
163:                        }
164:                    }
165:                }
166:            }
167:
168:            /**
169:             * Checks conditional required fields.  The required fields being checked for are:
170:             * <ul>
171:             * <li>tax type code (only required if a tax id number is present)</li>
172:             * <li>employee flag (only required if SSN is present)</li>
173:             * <li>city, state and zip fields populated (only required if country is US)</li>
174:             * <li>alien flag (only required if payee is an individual, not a company or other entity)</li>
175:             * </ul> 
176:             * 
177:             * @param payee
178:             */
179:            private void checkRequiredFields(Payee payee) {
180:
181:                /* check tax type code given if tax id number was given */
182:                if (StringUtils.isNotBlank(payee.getTaxIdNumber())) {
183:                    if (StringUtils.isBlank(payee.getTaxpayerTypeCode())) {
184:                        putFieldError(KFSPropertyConstants.TAXPAYER_TYPE_CODE,
185:                                KFSKeyConstants.ERROR_TAX_TYPE_REQUIRED);
186:                    }
187:                }
188:
189:                /* employee flag can be checked only if ssn */
190:                if (payee.isPayeeEmployeeCode()
191:                        && !TAX_TYPE_SSN.equals(payee.getTaxpayerTypeCode())) {
192:                    putFieldError(KFSPropertyConstants.PAYEE_EMPLOYEE_CODE,
193:                            KFSKeyConstants.ERROR_EMPL_FLAG_NOT_SSN);
194:                }
195:
196:                /* city, state & zip must be given for the US */
197:                if (KFSConstants.COUNTRY_CODE_UNITED_STATES.equals(payee
198:                        .getPayeeCountryCode())) {
199:                    if (StringUtils.isBlank(payee.getPayeeCityName())) {
200:                        putFieldErrorWithShortLabel(
201:                                KFSPropertyConstants.PAYEE_CITY_NAME,
202:                                KFSKeyConstants.ERROR_REQUIRED_FOR_US);
203:                    }
204:                    if (StringUtils.isBlank(payee.getPayeeStateCode())) {
205:                        putFieldErrorWithShortLabel(
206:                                KFSPropertyConstants.PAYEE_STATE_CODE,
207:                                KFSKeyConstants.ERROR_REQUIRED_FOR_US);
208:                    }
209:                    if (StringUtils.isBlank(payee.getPayeeZipCode())) {
210:                        putFieldErrorWithShortLabel(
211:                                KFSPropertyConstants.PAYEE_ZIP_CODE,
212:                                KFSKeyConstants.ERROR_REQUIRED_FOR_US);
213:                    }
214:                }
215:
216:                /* alien indicator can only be checked for individuals */
217:                if (payee.isAlienPaymentCode()
218:                        && !DisbursementVoucherDocumentRule.OWNERSHIP_TYPE_INDIVIDUAL
219:                                .equals(payee.getPayeeOwnershipTypCd())) {
220:                    putFieldError(KFSPropertyConstants.ALIEN_PAYMENT_CODE,
221:                            KFSKeyConstants.ERROR_DV_ALIEN_NOT_INDIVIDUAL);
222:                }
223:            }
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.