View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.document.CashReceiptDocument;
19  import org.kuali.ole.fp.document.CashReceiptFamilyBase;
20  import org.kuali.ole.sys.OLEConstants;
21  import org.kuali.ole.sys.OLEKeyConstants;
22  import org.kuali.ole.sys.document.validation.RouteNodeValidation;
23  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  
26  public class CashReceiptCashManagerValidation extends RouteNodeValidation {
27  
28      private CashReceiptFamilyBase cashReceiptDocumentForValidation;
29  
30      @Override
31      public boolean validate(AttributedDocumentEvent event) {
32        //check whether cash manager confirmed amount equals to the old amount
33          CashReceiptDocument crDoc = (CashReceiptDocument) getCashReceiptDocumentForValidation();
34           if ((crDoc.getTotalDollarAmount().compareTo(crDoc.getTotalConfirmedCashAmount().add(crDoc.getTotalConfirmedCheckAmount()).add(crDoc.getTotalConfirmedCoinAmount()))) != 0) {
35              GlobalVariables.getMessageMap().putError(OLEConstants.GLOBAL_ERRORS, OLEKeyConstants.CashReceipt.ERROR_CONFIRMED_TOTAL, crDoc.getTotalDollarAmount().toString());
36              return false;
37          }
38  
39          return true;
40  
41      }
42  
43      public CashReceiptFamilyBase getCashReceiptDocumentForValidation() {
44          return cashReceiptDocumentForValidation;
45      }
46  
47      public void setCashReceiptDocumentForValidation(CashReceiptFamilyBase cashReceiptDocumentForValidation) {
48          this.cashReceiptDocumentForValidation = cashReceiptDocumentForValidation;
49      }
50  
51  
52  }