1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.validation.impl;
17
18 import static org.kuali.ole.sys.OLEConstants.DOCUMENT_ERRORS;
19 import static org.kuali.ole.sys.OLEKeyConstants.ERROR_DOCUMENT_ACCOUNTING_PERIOD_CLOSED;
20
21 import org.kuali.ole.coa.businessobject.AccountingPeriod;
22 import org.kuali.ole.coa.service.AccountingPeriodService;
23 import org.kuali.ole.fp.document.AuxiliaryVoucherDocument;
24 import org.kuali.ole.sys.document.validation.GenericValidation;
25 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
26 import org.kuali.rice.krad.util.GlobalVariables;
27
28
29
30
31 public class AuxiliaryVoucherAccountingPeriodOpenValidation extends GenericValidation {
32 private AuxiliaryVoucherDocument auxliaryVoucherDocumentForValidation;
33 private AccountingPeriodService accountingPeriodService;
34
35
36
37
38
39 public boolean validate(AttributedDocumentEvent event) {
40 AccountingPeriod acctPeriod = getAccountingPeriodService().getByPeriod(auxliaryVoucherDocumentForValidation.getPostingPeriodCode(), auxliaryVoucherDocumentForValidation.getPostingYear());
41
42
43 if (acctPeriod == null || acctPeriod.isActive()) {
44 GlobalVariables.getMessageMap().putError(DOCUMENT_ERRORS, ERROR_DOCUMENT_ACCOUNTING_PERIOD_CLOSED);
45 return false;
46 }
47
48 return true;
49 }
50
51
52
53
54
55 public AccountingPeriodService getAccountingPeriodService() {
56 return accountingPeriodService;
57 }
58
59
60
61
62
63 public void setAccountingPeriodService(AccountingPeriodService accountingPeriodService) {
64 this.accountingPeriodService = accountingPeriodService;
65 }
66
67
68
69
70
71 public AuxiliaryVoucherDocument getAuxliaryVoucherDocumentForValidation() {
72 return auxliaryVoucherDocumentForValidation;
73 }
74
75
76
77
78
79 public void setAuxliaryVoucherDocumentForValidation(AuxiliaryVoucherDocument auxliaryVoucherDocumentForValidation) {
80 this.auxliaryVoucherDocumentForValidation = auxliaryVoucherDocumentForValidation;
81 }
82 }