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