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.CashReceiptDocument;
019 import org.kuali.kfs.fp.document.service.CashReceiptService;
020 import org.kuali.kfs.sys.document.validation.GenericValidation;
021 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
022
023 /**
024 * Validation that checks all of the various cash totals on a cash receipt document.
025 */
026 public class CashReceiptCashTotalsValidation extends GenericValidation {
027 private CashReceiptDocument cashReceiptDocumentForValidation;
028 private CashReceiptService cashReceiptService;
029
030 /**
031 * Uses the CashReceiptService.areCashTotalsInvalid method to check the cash totals.
032 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
033 */
034 public boolean validate(AttributedDocumentEvent event) {
035 return !getCashReceiptService().areCashTotalsInvalid(getCashReceiptDocumentForValidation());
036 }
037
038 /**
039 * Gets the cashReceiptDocumentForValidation attribute.
040 * @return Returns the cashReceiptDocumentForValidation.
041 */
042 public CashReceiptDocument getCashReceiptDocumentForValidation() {
043 return cashReceiptDocumentForValidation;
044 }
045
046 /**
047 * Sets the cashReceiptDocumentForValidation attribute value.
048 * @param cashReceiptDocumentForValidation The cashReceiptDocumentForValidation to set.
049 */
050 public void setCashReceiptDocumentForValidation(CashReceiptDocument cashReceiptDocumentForValidation) {
051 this.cashReceiptDocumentForValidation = cashReceiptDocumentForValidation;
052 }
053
054 /**
055 * Gets the cashReceiptService attribute.
056 * @return Returns the cashReceiptService.
057 */
058 public CashReceiptService getCashReceiptService() {
059 return cashReceiptService;
060 }
061
062 /**
063 * Sets the cashReceiptService attribute value.
064 * @param cashReceiptService The cashReceiptService to set.
065 */
066 public void setCashReceiptService(CashReceiptService cashReceiptService) {
067 this.cashReceiptService = cashReceiptService;
068 }
069 }