Source Code Cross Referenced for PurchaseOrderVoidDocumentRule.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 static org.kuali.kfs.KFSConstants.GL_CREDIT_CODE;
019:
020:        import org.apache.commons.lang.StringUtils;
021:        import org.kuali.core.bo.user.UniversalUser;
022:        import org.kuali.core.document.Document;
023:        import org.kuali.core.exceptions.UserNotFoundException;
024:        import org.kuali.core.exceptions.ValidationException;
025:        import org.kuali.core.rule.event.ApproveDocumentEvent;
026:        import org.kuali.core.service.UniversalUserService;
027:        import org.kuali.core.util.GlobalVariables;
028:        import org.kuali.core.util.ObjectUtils;
029:        import org.kuali.kfs.KFSConstants;
030:        import org.kuali.kfs.bo.AccountingLine;
031:        import org.kuali.kfs.bo.GeneralLedgerPendingEntry;
032:        import org.kuali.kfs.context.SpringContext;
033:        import org.kuali.kfs.document.AccountingDocument;
034:        import org.kuali.kfs.service.ParameterService;
035:        import org.kuali.kfs.service.impl.ParameterConstants;
036:        import org.kuali.module.purap.PurapKeyConstants;
037:        import org.kuali.module.purap.PurapParameterConstants;
038:        import org.kuali.module.purap.PurapPropertyConstants;
039:        import org.kuali.module.purap.PurapConstants.PurapDocTypeCodes;
040:        import org.kuali.module.purap.PurapConstants.PurchaseOrderStatuses;
041:        import org.kuali.module.purap.document.PurchaseOrderDocument;
042:        import org.kuali.module.purap.service.PurapGeneralLedgerService;
043:        import org.kuali.module.purap.service.PurchaseOrderService;
044:
045:        /**
046:         * Rules for Purchase Order Void document creation.
047:         */
048:        public class PurchaseOrderVoidDocumentRule extends
049:                PurchasingDocumentRuleBase {
050:
051:            /**
052:             * @see org.kuali.module.financial.rules.TransactionalDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.core.document.Document)
053:             */
054:            @Override
055:            protected boolean processCustomRouteDocumentBusinessRules(
056:                    Document document) {
057:                boolean isValid = true;
058:                PurchaseOrderDocument porDocument = (PurchaseOrderDocument) document;
059:                return isValid &= processValidation(porDocument);
060:            }
061:
062:            /**
063:             * @see org.kuali.core.rules.DocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.core.document.Document)
064:             */
065:            @Override
066:            protected boolean processCustomSaveDocumentBusinessRules(
067:                    Document document) {
068:                boolean isValid = true;
069:                PurchaseOrderDocument porDocument = (PurchaseOrderDocument) document;
070:                return isValid &= processValidation(porDocument);
071:            }
072:
073:            /**
074:             * @see org.kuali.core.rules.DocumentRuleBase#processCustomApproveDocumentBusinessRules(org.kuali.core.rule.event.ApproveDocumentEvent)
075:             */
076:            @Override
077:            protected boolean processCustomApproveDocumentBusinessRules(
078:                    ApproveDocumentEvent approveEvent) {
079:                boolean isValid = true;
080:                PurchaseOrderDocument porDocument = (PurchaseOrderDocument) approveEvent
081:                        .getDocument();
082:                return isValid;
083:            }
084:
085:            /**
086:             * Central method to control the processing of rule checks. Checks that the purchase order document is not null, that it is in
087:             * the correct status, and that the user is in the purchasing workgroup.
088:             * 
089:             * @param document A PurchaseOrderDocument.
090:             * @return True if the document passes all the validations.
091:             */
092:            public boolean processValidation(PurchaseOrderDocument document) {
093:                boolean valid = true;
094:
095:                // Check that the PO is not null
096:                if (ObjectUtils.isNull(document)) {
097:                    throw new ValidationException(
098:                            "Purchase Order Void document was null on validation.");
099:                } else {
100:                    PurchaseOrderDocument currentPO = SpringContext.getBean(
101:                            PurchaseOrderService.class)
102:                            .getCurrentPurchaseOrder(
103:                                    document.getPurapDocumentIdentifier());
104:                    // The PO must be in OPEN status.
105:                    if (!StringUtils.equalsIgnoreCase(
106:                            currentPO.getStatusCode(),
107:                            PurchaseOrderStatuses.OPEN)
108:                            && !StringUtils.equalsIgnoreCase(currentPO
109:                                    .getStatusCode(),
110:                                    PurchaseOrderStatuses.PENDING_VOID)
111:                            && !StringUtils.equalsIgnoreCase(currentPO
112:                                    .getStatusCode(),
113:                                    PurchaseOrderStatuses.PENDING_PRINT)) {
114:                        valid = false;
115:                        GlobalVariables
116:                                .getErrorMap()
117:                                .putError(
118:                                        PurapPropertyConstants.STATUS_CODE,
119:                                        PurapKeyConstants.ERROR_PURCHASE_ORDER_STATUS_NOT_REQUIRED_STATUS,
120:                                        PurchaseOrderStatuses.OPEN);
121:                    }
122:
123:                    // Check that the user is in purchasing workgroup.
124:                    String initiatorNetworkId = document.getDocumentHeader()
125:                            .getWorkflowDocument().getInitiatorNetworkId();
126:                    UniversalUserService uus = SpringContext
127:                            .getBean(UniversalUserService.class);
128:                    UniversalUser user = null;
129:                    try {
130:                        user = uus
131:                                .getUniversalUserByAuthenticationUserId(initiatorNetworkId);
132:                        String purchasingGroup = SpringContext
133:                                .getBean(ParameterService.class)
134:                                .getParameterValue(
135:                                        ParameterConstants.PURCHASING_DOCUMENT.class,
136:                                        PurapParameterConstants.Workgroups.WORKGROUP_PURCHASING);
137:                        if (!uus.isMember(user, purchasingGroup)) {
138:                            valid = false;
139:                        }
140:                    } catch (UserNotFoundException ue) {
141:                        valid = false;
142:                    }
143:                }
144:                return valid;
145:            }
146:
147:            /**
148:             * @see org.kuali.module.purap.rules.PurapAccountingDocumentRuleBase#customizeExplicitGeneralLedgerPendingEntry(org.kuali.kfs.document.AccountingDocument,
149:             *      org.kuali.kfs.bo.AccountingLine, org.kuali.kfs.bo.GeneralLedgerPendingEntry)
150:             */
151:            @Override
152:            protected void customizeExplicitGeneralLedgerPendingEntry(
153:                    AccountingDocument accountingDocument,
154:                    AccountingLine accountingLine,
155:                    GeneralLedgerPendingEntry explicitEntry) {
156:                super .customizeExplicitGeneralLedgerPendingEntry(
157:                        accountingDocument, accountingLine, explicitEntry);
158:                PurchaseOrderDocument po = (PurchaseOrderDocument) accountingDocument;
159:
160:                SpringContext.getBean(PurapGeneralLedgerService.class)
161:                        .customizeGeneralLedgerPendingEntry(po, accountingLine,
162:                                explicitEntry, po.getPurapDocumentIdentifier(),
163:                                GL_CREDIT_CODE, PurapDocTypeCodes.PO_DOCUMENT,
164:                                true);
165:
166:                // don't think i should have to override this, but default isn't getting the right PO doc
167:                explicitEntry
168:                        .setFinancialDocumentTypeCode(PurapDocTypeCodes.PO_VOID_DOCUMENT);
169:                explicitEntry
170:                        .setFinancialDocumentApprovedCode(KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
171:            }
172:
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.