001 /*
002 * Copyright 2011 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 */
016 package org.kuali.kfs.module.purap.document.validation.impl;
017
018
019 import org.apache.commons.lang.StringUtils;
020 import org.kuali.kfs.module.purap.PurapConstants;
021 import org.kuali.kfs.module.purap.PurapParameterConstants;
022 import org.kuali.kfs.module.purap.businessobject.PurApItem;
023 import org.kuali.kfs.module.purap.businessobject.PurchasingItemBase;
024 import org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument;
025 import org.kuali.kfs.module.purap.document.PurchasingDocumentBase;
026 import org.kuali.kfs.module.purap.document.RequisitionDocument;
027 import org.kuali.kfs.module.purap.document.web.struts.PurchasingFormBase;
028 import org.kuali.kfs.sys.KFSConstants;
029 import org.kuali.rice.kns.document.Document;
030 import org.kuali.rice.kns.service.ParameterService;
031
032 public abstract class PurchasingDocumentPreRulesBase extends PurapDocumentPreRulesBase{
033
034 @Override
035 public boolean doPrompts(Document document) {
036 PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument)document;
037
038 boolean preRulesValid=super.doPrompts(document);
039
040 if (StringUtils.isBlank(event.getQuestionContext()) || StringUtils.equals(question, PurapConstants.FIX_CAPITAL_ASSET_WARNINGS)) {
041 preRulesValid &= confirmFixCapitalAssetWarningConditions(purapDocument);
042 }
043
044 return preRulesValid;
045 }
046
047 protected boolean checkForTaxRecalculation(PurchasingAccountsPayableDocument purapDocument){
048
049 String initialZipCode = ((PurchasingFormBase)form).getInitialZipCode();
050 if (StringUtils.isNotEmpty(initialZipCode) && !StringUtils.equals(initialZipCode,((PurchasingDocumentBase)purapDocument).getDeliveryPostalCode())){
051 for (PurApItem purApItem : purapDocument.getItems()) {
052 PurchasingItemBase item = (PurchasingItemBase)purApItem;
053 if (item.getItemTaxAmount() != null){
054
055 StringBuffer questionTextBuffer = new StringBuffer("");
056 questionTextBuffer.append(PurapConstants.TAX_RECALCULATION_QUESTION);
057
058 Boolean proceed = super.askOrAnalyzeYesNoQuestion(PurapConstants.TAX_RECALCULATION_INFO, questionTextBuffer.toString());
059
060 //Set a marker to record that this method has been used.
061 if (proceed && StringUtils.isBlank(event.getQuestionContext())) {
062 event.setQuestionContext(PurapConstants.TAX_RECALCULATION_INFO);
063 }
064
065 if (!proceed) {
066 event.setActionForwardName(KFSConstants.MAPPING_BASIC);
067 return false;
068 }
069 }
070 }
071 }
072
073 return true;
074 }
075
076
077 }