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


001:        /*
002:         * Copyright 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.purap.rules;
017:
018:        import org.apache.commons.lang.StringUtils;
019:        import org.kuali.core.document.Document;
020:        import org.kuali.core.service.KualiConfigurationService;
021:        import org.kuali.kfs.KFSConstants;
022:        import org.kuali.kfs.context.SpringContext;
023:        import org.kuali.module.purap.PurapConstants;
024:        import org.kuali.module.purap.PurapKeyConstants;
025:        import org.kuali.module.purap.PurapConstants.PREQDocumentsStrings;
026:        import org.kuali.module.purap.document.PaymentRequestDocument;
027:        import org.kuali.module.purap.service.PurapService;
028:
029:        /**
030:         * Business pre rule(s) applicable to Payment Request documents.
031:         */
032:        public class PaymentRequestDocumentPreRules extends
033:                AccountsPayableDocumentPreRulesBase {
034:
035:            /**
036:             * Default Constructor
037:             */
038:            public PaymentRequestDocumentPreRules() {
039:                super ();
040:            }
041:
042:            /**
043:             * Main hook point to perform rules check.
044:             * 
045:             * @see org.kuali.core.rules.PreRulesContinuationBase#doRules(org.kuali.core.document.Document)
046:             */
047:            @Override
048:            public boolean doRules(Document document) {
049:                boolean preRulesOK = true;
050:
051:                PaymentRequestDocument preq = (PaymentRequestDocument) document;
052:                if ((!SpringContext.getBean(PurapService.class)
053:                        .isFullDocumentEntryCompleted(preq))
054:                        || (StringUtils
055:                                .equals(
056:                                        preq.getStatusCode(),
057:                                        PurapConstants.PaymentRequestStatuses.AWAITING_ACCOUNTS_PAYABLE_REVIEW))) {
058:                    if (!confirmPayDayNotOverThresholdDaysAway(preq)) {
059:                        return false;
060:                    }
061:                }
062:                preRulesOK &= super .doRules(document);
063:                return preRulesOK;
064:            }
065:
066:            /**
067:             * Prompts user to confirm with a Yes or No to a question being asked.
068:             * 
069:             * @param questionType - type of question
070:             * @param messageConstant - key to retrieve message
071:             * @return - true if overriding, false otherwise
072:             */
073:            private boolean askForConfirmation(String questionType,
074:                    String messageConstant) {
075:
076:                String questionText = SpringContext.getBean(
077:                        KualiConfigurationService.class).getPropertyString(
078:                        messageConstant);
079:                if (questionText.contains("{")) {
080:                    questionText = prepareQuestionText(questionType,
081:                            questionText);
082:                }
083:
084:                boolean confirmOverride = super .askOrAnalyzeYesNoQuestion(
085:                        questionType, questionText);
086:
087:                if (!confirmOverride) {
088:                    event.setActionForwardName(KFSConstants.MAPPING_BASIC);
089:                    return false;
090:                }
091:                return true;
092:            }
093:
094:            /**
095:             * Creates the actual text of the question, replacing place holders like pay date threshold with an actual constant value.
096:             * 
097:             * @param questionType - type of question
098:             * @param questionText - actual text of question pulled from resource file
099:             * @return - question text with place holders replaced
100:             */
101:            private String prepareQuestionText(String questionType,
102:                    String questionText) {
103:                if (StringUtils.equals(questionType,
104:                        PREQDocumentsStrings.THRESHOLD_DAYS_OVERRIDE_QUESTION)) {
105:                    questionText = StringUtils
106:                            .replace(
107:                                    questionText,
108:                                    "{0}",
109:                                    new Integer(
110:                                            PurapConstants.PREQ_PAY_DATE_DAYS_BEFORE_WARNING)
111:                                            .toString());
112:                }
113:                return questionText;
114:            }
115:
116:            /**
117:             * Validates if the pay date threshold has not been passed, if so confirmation is required by the user to
118:             * exceed the threshold.
119:             * 
120:             * @param preq - payment request document
121:             * @return - true if threshold has not been surpassed or if user confirmed ok to override, false otherwise
122:             */
123:            public boolean confirmPayDayNotOverThresholdDaysAway(
124:                    PaymentRequestDocument preq) {
125:                // If the pay date is more than the threshold number of days in the future, ask for confirmation.
126:                PaymentRequestDocumentRule rule = new PaymentRequestDocumentRule();
127:                if (!rule.validatePayDateNotOverThresholdDaysAway(preq)) {
128:                    return askForConfirmation(
129:                            PREQDocumentsStrings.THRESHOLD_DAYS_OVERRIDE_QUESTION,
130:                            PurapKeyConstants.MESSAGE_PAYMENT_REQUEST_PAYDATE_OVER_THRESHOLD_DAYS);
131:                }
132:                return true;
133:            }
134:
135:            /**
136:             * @see org.kuali.module.purap.rules.AccountsPayableDocumentPreRulesBase#getDocumentName()
137:             */
138:            @Override
139:            public String getDocumentName() {
140:                return "Payment Request";
141:            }
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.