Source Code Cross Referenced for CreditCardReceiptDocumentRuleUtil.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 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.financial.rules;
017:
018:        import static org.kuali.kfs.rules.AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX;
019:        import static org.kuali.module.financial.rules.CreditCardReceiptDocumentRuleConstants.CREDIT_CARD_RECEIPT_PREFIX;
020:
021:        import org.kuali.core.service.DataDictionaryService;
022:        import org.kuali.core.service.DictionaryValidationService;
023:        import org.kuali.core.util.ErrorMap;
024:        import org.kuali.core.util.GlobalVariables;
025:        import org.kuali.core.util.KualiDecimal;
026:        import org.kuali.kfs.KFSKeyConstants;
027:        import org.kuali.kfs.KFSPropertyConstants;
028:        import org.kuali.kfs.KFSKeyConstants.CashReceipt;
029:        import org.kuali.kfs.context.SpringContext;
030:        import org.kuali.module.financial.bo.CreditCardDetail;
031:        import org.kuali.module.financial.document.CreditCardReceiptDocument;
032:
033:        /**
034:         * Common Credit Card Receipt Document rule utilities.
035:         */
036:        public class CreditCardReceiptDocumentRuleUtil {
037:            /**
038:             * This method method will invoke the data dictionary validation for a CreditCardDetail bo instance, in addition to checking
039:             * existence of the CreditCardType and CreditCardVendor attributes that hang off of it. This method assumes that the document
040:             * hierarchy for the error map path is managed outside of this call.
041:             * 
042:             * @param creditCardReceipt credit card detail
043:             * @return true if credit card detail amount is non zero and credit card vendor and type references exist
044:             */
045:            public static boolean validateCreditCardReceipt(
046:                    CreditCardDetail creditCardReceipt) {
047:                ErrorMap errorMap = GlobalVariables.getErrorMap();
048:                int originalErrorCount = errorMap.getErrorCount();
049:
050:                // call the DD validation which checks basic data integrity
051:                SpringContext.getBean(DictionaryValidationService.class)
052:                        .validateBusinessObject(creditCardReceipt);
053:                boolean isValid = (errorMap.getErrorCount() == originalErrorCount);
054:
055:                // check that dollar amount is not zero before continuing
056:                if (isValid) {
057:                    isValid = !creditCardReceipt
058:                            .getCreditCardAdvanceDepositAmount().isZero();
059:                    if (!isValid) {
060:                        String label = SpringContext
061:                                .getBean(DataDictionaryService.class)
062:                                .getAttributeLabel(
063:                                        CreditCardDetail.class,
064:                                        KFSPropertyConstants.CREDIT_CARD_ADVANCE_DEPOSIT_AMOUNT);
065:                        errorMap
066:                                .putError(
067:                                        KFSPropertyConstants.CREDIT_CARD_ADVANCE_DEPOSIT_AMOUNT,
068:                                        KFSKeyConstants.ERROR_ZERO_AMOUNT,
069:                                        label);
070:                    }
071:                }
072:
073:                if (isValid) {
074:                    isValid = SpringContext.getBean(
075:                            DictionaryValidationService.class)
076:                            .validateReferenceExists(creditCardReceipt,
077:                                    KFSPropertyConstants.CREDIT_CARD_TYPE);
078:                    if (!isValid) {
079:                        String label = SpringContext
080:                                .getBean(DataDictionaryService.class)
081:                                .getAttributeLabel(
082:                                        CreditCardDetail.class,
083:                                        KFSPropertyConstants.FINANCIAL_DOCUMENT_CREDIT_CARD_TYPE_CODE);
084:                        errorMap
085:                                .putError(
086:                                        KFSPropertyConstants.FINANCIAL_DOCUMENT_CREDIT_CARD_TYPE_CODE,
087:                                        KFSKeyConstants.ERROR_EXISTENCE, label);
088:                    }
089:                }
090:                if (isValid) {
091:                    isValid = SpringContext.getBean(
092:                            DictionaryValidationService.class)
093:                            .validateReferenceExists(creditCardReceipt,
094:                                    KFSPropertyConstants.CREDIT_CARD_VENDOR);
095:                    if (!isValid) {
096:                        String label = SpringContext
097:                                .getBean(DataDictionaryService.class)
098:                                .getAttributeLabel(
099:                                        CreditCardDetail.class,
100:                                        KFSPropertyConstants.FINANCIAL_DOCUMENT_CREDIT_CARD_VENDOR_NUMBER);
101:                        errorMap
102:                                .putError(
103:                                        KFSPropertyConstants.FINANCIAL_DOCUMENT_CREDIT_CARD_VENDOR_NUMBER,
104:                                        KFSKeyConstants.ERROR_EXISTENCE, label);
105:                    }
106:                }
107:
108:                return isValid;
109:            }
110:
111:            /**
112:             * Checks whether the CashReceiptDocument's cash totals are invalid, generating global errors if so.
113:             * 
114:             * @param cashReceiptDocument submitted cash receipt document
115:             * @return true if any of the cash totals on cash credit card receipt document are invalid
116:             */
117:            public static boolean areCashTotalsInvalid(
118:                    CreditCardReceiptDocument ccrDocument) {
119:                String documentEntryName = ccrDocument.getDocumentHeader()
120:                        .getWorkflowDocument().getDocumentType();
121:
122:                boolean isInvalid = isTotalInvalid(ccrDocument, ccrDocument
123:                        .getTotalDollarAmount(), documentEntryName,
124:                        KFSPropertyConstants.CREDIT_CARD_RECEIPTS_TOTAL);
125:
126:                return isInvalid;
127:            }
128:
129:            /**
130:             * Returns true if total is invalid and puts an error message in the error map for that property if the amount is negative
131:             * 
132:             * @param cashReceiptDocument
133:             * @param totalAmount
134:             * @param documentEntryName
135:             * @param propertyName
136:             * @return true if the totalAmount is an invalid value
137:             */
138:            private static boolean isTotalInvalid(
139:                    CreditCardReceiptDocument ccrDocument,
140:                    KualiDecimal totalAmount, String documentEntryName,
141:                    String propertyName) {
142:                boolean isInvalid = false;
143:                String errorProperty = CREDIT_CARD_RECEIPT_PREFIX
144:                        + propertyName;
145:
146:                // treating null totalAmount as if it were a zero
147:                DataDictionaryService dds = SpringContext
148:                        .getBean(DataDictionaryService.class);
149:                String errorLabel = dds.getAttributeLabel(documentEntryName,
150:                        propertyName);
151:                if ((totalAmount == null) || totalAmount.isZero()) {
152:                    GlobalVariables.getErrorMap().putError(errorProperty,
153:                            CashReceipt.ERROR_ZERO_TOTAL, errorLabel);
154:
155:                    isInvalid = true;
156:                } else {
157:                    int precount = GlobalVariables.getErrorMap().size();
158:
159:                    DictionaryValidationService dvs = SpringContext
160:                            .getBean(DictionaryValidationService.class);
161:                    dvs.validateDocumentAttribute(ccrDocument, propertyName,
162:                            DOCUMENT_ERROR_PREFIX);
163:
164:                    // replace generic error message, if any, with something more readable
165:                    GlobalVariables.getErrorMap().replaceError(errorProperty,
166:                            KFSKeyConstants.ERROR_MAX_LENGTH,
167:                            CashReceipt.ERROR_EXCESSIVE_TOTAL, errorLabel);
168:
169:                    int postcount = GlobalVariables.getErrorMap().size();
170:                    isInvalid = (postcount > precount);
171:                }
172:
173:                return isInvalid;
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.