001/* 002 * Copyright 2006-2008 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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 */ 016package org.kuali.ole.module.purap.document.validation.impl; 017 018import org.kuali.ole.module.purap.PurapConstants; 019import org.kuali.ole.module.purap.document.ElectronicInvoiceRejectDocument; 020import org.kuali.ole.module.purap.service.ElectronicInvoiceHelperService; 021import org.kuali.ole.sys.OLEConstants; 022import org.kuali.ole.sys.context.SpringContext; 023import org.kuali.rice.core.api.util.type.KualiDecimal; 024import org.kuali.rice.kns.rules.DocumentRuleBase; 025import org.kuali.rice.krad.document.Document; 026import org.kuali.rice.krad.util.GlobalVariables; 027 028import java.math.BigDecimal; 029 030/** 031 * Business rule(s) applicable to Payment Request documents. 032 */ 033public class ElectronicInvoiceRejectDocumentRule extends DocumentRuleBase { 034 035 protected static KualiDecimal zero = KualiDecimal.ZERO; 036 protected static BigDecimal ONE_HUNDRED = BigDecimal.valueOf(100); 037 038 /** 039 * @see org.kuali.rice.krad.rules.DocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.krad.document.Document) 040 */ 041 @Override 042 protected boolean processCustomRouteDocumentBusinessRules(Document document) { 043 return processBusinessRules(document); 044 } 045 046 protected boolean processBusinessRules(Document document) { 047 boolean isValid = true; 048 049 ElectronicInvoiceRejectDocument eirDocument = (ElectronicInvoiceRejectDocument) document; 050 051 // check to see if the document is being researched 052 if (eirDocument.isInvoiceResearchIndicator()) { 053 GlobalVariables.getMessageMap().putError(OLEConstants.DOCUMENT_ERRORS, PurapConstants.REJECT_DOCUMENT_RESEARCH_INCOMPETE); 054 isValid = false; 055 } 056 057 if (!eirDocument.isDocumentCreationInProgress()) { 058 isValid = isValid && SpringContext.getBean(ElectronicInvoiceHelperService.class).doMatchingProcess(eirDocument); 059 if (isValid) { 060 SpringContext.getBean(ElectronicInvoiceHelperService.class).createPaymentRequest(eirDocument); 061 } 062 } 063 064 return isValid; 065 } 066 067}