View Javadoc
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 static org.kuali.ole.sys.OLEPropertyConstants.REVERSAL_DATE;
19  import static org.kuali.ole.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX;
20  
21  import org.kuali.ole.fp.document.JournalVoucherDocument;
22  import org.kuali.ole.sys.OLEKeyConstants;
23  import org.kuali.ole.sys.context.SpringContext;
24  import org.kuali.ole.sys.document.validation.GenericValidation;
25  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
26  import org.kuali.rice.core.api.datetime.DateTimeService;
27  import org.kuali.rice.krad.util.GlobalVariables;
28  
29  /**
30   * A validation of the reversal date on a Journal Voucher document
31   */
32  public class JournalVoucherReversalDateValidation extends GenericValidation {
33      private JournalVoucherDocument journalVoucherForValidation;
34  
35      /**
36       * Checks that if the reveral date for the document is not null, that the reversal date has not already occurred
37       * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
38       */
39      public boolean validate(AttributedDocumentEvent event) {
40          java.sql.Date today = SpringContext.getBean(DateTimeService.class).getCurrentSqlDateMidnight();
41          if (null != getJournalVoucherForValidation().getReversalDate() && getJournalVoucherForValidation().getReversalDate().before(today)) {
42              GlobalVariables.getMessageMap().putError(DOCUMENT_ERROR_PREFIX + REVERSAL_DATE, OLEKeyConstants.ERROR_DOCUMENT_INCORRECT_REVERSAL_DATE);
43              return false;
44          }
45          return true;
46      }
47  
48      /**
49       * Gets the journalVoucherForValidation attribute. 
50       * @return Returns the journalVoucherForValidation.
51       */
52      public JournalVoucherDocument getJournalVoucherForValidation() {
53          return journalVoucherForValidation;
54      }
55  
56      /**
57       * Sets the journalVoucherForValidation attribute value.
58       * @param journalVoucherForValidation The journalVoucherForValidation to set.
59       */
60      public void setJournalVoucherForValidation(JournalVoucherDocument journalVoucherForDocument) {
61          this.journalVoucherForValidation = journalVoucherForDocument;
62      }
63  }