1 /*
2 * Copyright 2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.fp.document.validation.impl;
17
18 import org.kuali.ole.fp.businessobject.Check;
19 import org.kuali.ole.sys.OLEKeyConstants;
20 import org.kuali.ole.sys.OLEPropertyConstants;
21 import org.kuali.ole.sys.document.validation.GenericValidation;
22 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23 import org.kuali.rice.krad.util.GlobalVariables;
24
25 /**
26 * Validation that checks that a check's amount is not zero.
27 */
28 public class CashReceiptCheckAmountNotZeroValidation extends GenericValidation {
29 private Check checkForValidation;
30
31 /**
32 * Verifies that a check amount is not zero.
33 * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
34 */
35 public boolean validate(AttributedDocumentEvent event) {
36 if (getCheckForValidation().getAmount().isZero()) {
37 GlobalVariables.getMessageMap().putError(OLEPropertyConstants.CHECK_AMOUNT, OLEKeyConstants.CashReceipt.ERROR_ZERO_CHECK_AMOUNT, OLEPropertyConstants.CHECKS);
38 return false;
39 }
40 return true;
41 }
42
43 /**
44 * Gets the checkForValidation attribute.
45 * @return Returns the checkForValidation.
46 */
47 public Check getCheckForValidation() {
48 return checkForValidation;
49 }
50
51 /**
52 * Sets the checkForValidation attribute value.
53 * @param checkForValidation The checkForValidation to set.
54 */
55 public void setCheckForValidation(Check checkForValidation) {
56 this.checkForValidation = checkForValidation;
57 }
58 }