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 import org.kuali.kfs.module.purap.PurapKeyConstants;
019 import org.kuali.kfs.module.purap.businessobject.PurApAccountingLine;
020 import org.kuali.kfs.sys.document.validation.GenericValidation;
021 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
022 import org.kuali.rice.kns.util.GlobalVariables;
023
024 public class PurchasingAccountsPayableAccountPercentBetween0And100Validation extends GenericValidation {
025
026 private PurApAccountingLine accountingLine;
027 private String errorPropertyName;
028 private String itemIdentifier;
029
030 public boolean validate(AttributedDocumentEvent event) {
031 boolean valid = true;
032 double pct = accountingLine.getAccountLinePercent().doubleValue();
033
034 if (pct <= 0 || pct > 100) {
035 GlobalVariables.getMessageMap().putError(errorPropertyName, PurapKeyConstants.ERROR_ITEM_PERCENT, "%", itemIdentifier);
036
037 valid = false;
038 }
039
040 return valid;
041 }
042
043 public PurApAccountingLine getAccountingLine() {
044 return accountingLine;
045 }
046
047 public void setAccountingLine(PurApAccountingLine accountingLine) {
048 this.accountingLine = accountingLine;
049 }
050
051 public String getErrorPropertyName() {
052 return errorPropertyName;
053 }
054
055 public void setErrorPropertyName(String errorPropertyName) {
056 this.errorPropertyName = errorPropertyName;
057 }
058
059 public String getItemIdentifier() {
060 return itemIdentifier;
061 }
062
063 public void setItemIdentifier(String itemIdentifier) {
064 this.itemIdentifier = itemIdentifier;
065 }
066
067 }