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.document.validation.impl.AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX;
019
020 import org.kuali.kfs.fp.document.AdvanceDepositDocument;
021 import org.kuali.kfs.fp.document.CreditCardReceiptDocument;
022 import org.kuali.kfs.sys.KFSKeyConstants;
023 import org.kuali.kfs.sys.KFSPropertyConstants;
024 import org.kuali.kfs.sys.document.validation.GenericValidation;
025 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
026 import org.kuali.rice.kns.util.GlobalVariables;
027
028 /**
029 * This class...
030 */
031 public class AdvanceDepositMinimumAdvanceDepositValidation extends GenericValidation {
032 private AdvanceDepositDocument accountingDocumentForValidation;
033 private int requiredMinimumCount;
034 /**
035 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
036 */
037 public boolean validate(AttributedDocumentEvent event) {
038 AdvanceDepositDocument ad = getAccountingDocumentForValidation();
039 if (ad.getAdvanceDeposits().size() < requiredMinimumCount) {
040 GlobalVariables.getMessageMap().putError(DOCUMENT_ERROR_PREFIX, KFSKeyConstants.AdvanceDeposit.ERROR_DOCUMENT_ADVANCE_DEPOSIT_REQ_NUMBER_DEPOSITS_NOT_MET);
041 return false;
042 }
043 return true;
044 }
045 /**
046 * Gets the documentForValidation attribute.
047 * @return Returns the documentForValidation.
048 */
049 public AdvanceDepositDocument getAccountingDocumentForValidation() {
050 return accountingDocumentForValidation;
051 }
052 /**
053 * Sets the documentForValidation attribute value.
054 * @param documentForValidation The documentForValidation to set.
055 */
056 public void setAccountingDocumentForValidation(AdvanceDepositDocument accountingDocumentForValidation) {
057 this.accountingDocumentForValidation = accountingDocumentForValidation;
058 }
059 /**
060 * Gets the requiredMinimumCount attribute.
061 * @return Returns the requiredMinimumCount.
062 */
063 public int getRequiredMinimumCount() {
064 return requiredMinimumCount;
065 }
066 /**
067 * Sets the requiredMinimumCount attribute value.
068 * @param requiredMinimumCount The requiredMinimumCount to set.
069 */
070 public void setRequiredMinimumCount(int requiredMinimumCount) {
071 this.requiredMinimumCount = requiredMinimumCount;
072 }
073
074 }