001/* 002 * Copyright 2009 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 */ 016package org.kuali.ole.fp.document.validation.impl; 017 018import org.kuali.ole.fp.document.CreditCardReceiptDocument; 019import org.kuali.ole.sys.OLEKeyConstants; 020import org.kuali.ole.sys.OLEPropertyConstants; 021import org.kuali.ole.sys.document.validation.GenericValidation; 022import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent; 023import org.kuali.rice.krad.util.GlobalVariables; 024 025/** 026 * Validation which tests that the amount in credit card lines equals the amount in accounting lines 027 * on the document. 028 */ 029public class CreditCardReceiptDocumentTotalValidation extends GenericValidation { 030 private CreditCardReceiptDocument creditCardReceiptDocumentForValidation; 031 032 /** 033 * For Credit Card Receipt documents, the document is balanced if the sum total of credit card receipts equals the sum total of 034 * the accounting lines. 035 * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent) 036 */ 037 public boolean validate(AttributedDocumentEvent event) { 038 // make sure the document is in balance 039 boolean isValid = creditCardReceiptDocumentForValidation.getSourceTotal().equals(creditCardReceiptDocumentForValidation.getTotalDollarAmount()); 040 041 if (!isValid) { 042 GlobalVariables.getMessageMap().putError(OLEPropertyConstants.NEW_CREDIT_CARD_RECEIPT, OLEKeyConstants.CreditCardReceipt.ERROR_DOCUMENT_CREDIT_CARD_RECEIPT_OUT_OF_BALANCE); 043 } 044 045 return isValid; 046 } 047 048 /** 049 * Gets the creditCardReceiptDocumentForValidation attribute. 050 * @return Returns the creditCardReceiptDocumentForValidation. 051 */ 052 public CreditCardReceiptDocument getCreditCardReceiptDocumentForValidation() { 053 return creditCardReceiptDocumentForValidation; 054 } 055 056 /** 057 * Sets the creditCardReceiptDocumentForValidation attribute value. 058 * @param creditCardReceiptDocumentForValidation The creditCardReceiptDocumentForValidation to set. 059 */ 060 public void setCreditCardReceiptDocumentForValidation(CreditCardReceiptDocument creditCardReceiptDocumentForValidation) { 061 this.creditCardReceiptDocumentForValidation = creditCardReceiptDocumentForValidation; 062 } 063 064}