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.fp.document.validation.impl; 017 018 import static org.kuali.kfs.sys.KFSKeyConstants.AuxiliaryVoucher.ERROR_INVALID_ACCRUAL_REVERSAL_DATE; 019 import static org.kuali.kfs.sys.KFSPropertyConstants.REVERSAL_DATE; 020 021 import org.kuali.kfs.fp.document.AuxiliaryVoucherDocument; 022 import org.kuali.kfs.sys.document.validation.GenericValidation; 023 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent; 024 import org.kuali.rice.kns.util.GlobalVariables; 025 026 /** 027 * A validation that checks the reversal date on the AuxiliaryVoucher. 028 */ 029 public class AuxiliaryVoucherReversalDateValidation extends GenericValidation { 030 private AuxiliaryVoucherDocument auxiliaryVoucherDocumentForValidation; 031 032 /** 033 * This method verifies that the user entered a reversal date, but only if it's an accrual. 034 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent) 035 */ 036 public boolean validate(AttributedDocumentEvent event) { 037 if (getAuxiliaryVoucherDocumentForValidation().isAccrualType() && getAuxiliaryVoucherDocumentForValidation().getReversalDate() == null) { 038 GlobalVariables.getMessageMap().putError(REVERSAL_DATE, ERROR_INVALID_ACCRUAL_REVERSAL_DATE); 039 return false; 040 } 041 042 return true; 043 } 044 045 /** 046 * Gets the auxiliaryVoucherDocumentForValidation attribute. 047 * @return Returns the auxiliaryVoucherDocumentForValidation. 048 */ 049 public AuxiliaryVoucherDocument getAuxiliaryVoucherDocumentForValidation() { 050 return auxiliaryVoucherDocumentForValidation; 051 } 052 053 /** 054 * Sets the auxiliaryVoucherDocumentForValidation attribute value. 055 * @param auxiliaryVoucherDocumentForValidation The auxiliaryVoucherDocumentForValidation to set. 056 */ 057 public void setAuxiliaryVoucherDocumentForValidation(AuxiliaryVoucherDocument auxiliaryVoucherForValidation) { 058 this.auxiliaryVoucherDocumentForValidation = auxiliaryVoucherForValidation; 059 } 060 }