001/* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 1.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/ecl1.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 */ 016package org.kuali.ole.fp.document.validation.impl; 017 018import org.kuali.ole.fp.document.CashReceiptDocument; 019import org.kuali.ole.fp.document.CashReceiptFamilyBase; 020import org.kuali.ole.sys.OLEConstants; 021import org.kuali.ole.sys.OLEKeyConstants; 022import org.kuali.ole.sys.document.validation.RouteNodeValidation; 023import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent; 024import org.kuali.rice.krad.util.GlobalVariables; 025 026public class CashReceiptCashManagerValidation extends RouteNodeValidation { 027 028 private CashReceiptFamilyBase cashReceiptDocumentForValidation; 029 030 @Override 031 public boolean validate(AttributedDocumentEvent event) { 032 //check whether cash manager confirmed amount equals to the old amount 033 CashReceiptDocument crDoc = (CashReceiptDocument) getCashReceiptDocumentForValidation(); 034 if ((crDoc.getTotalDollarAmount().compareTo(crDoc.getTotalConfirmedCashAmount().add(crDoc.getTotalConfirmedCheckAmount()).add(crDoc.getTotalConfirmedCoinAmount()))) != 0) { 035 GlobalVariables.getMessageMap().putError(OLEConstants.GLOBAL_ERRORS, OLEKeyConstants.CashReceipt.ERROR_CONFIRMED_TOTAL, crDoc.getTotalDollarAmount().toString()); 036 return false; 037 } 038 039 return true; 040 041 } 042 043 public CashReceiptFamilyBase getCashReceiptDocumentForValidation() { 044 return cashReceiptDocumentForValidation; 045 } 046 047 public void setCashReceiptDocumentForValidation(CashReceiptFamilyBase cashReceiptDocumentForValidation) { 048 this.cashReceiptDocumentForValidation = cashReceiptDocumentForValidation; 049 } 050 051 052}