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.fp.document.validation.impl.AuxiliaryVoucherDocumentRuleConstants.RESTRICTED_PERIOD_CODES;
19 import static org.kuali.ole.sys.OLEConstants.ACCOUNTING_PERIOD_ACTIVE_INDICATOR_FIELD;
20 import static org.kuali.ole.sys.OLEKeyConstants.AuxiliaryVoucher.ERROR_ACCOUNTING_PERIOD_OUT_OF_RANGE;
21
22 import org.kuali.ole.coa.businessobject.AccountingPeriod;
23 import org.kuali.ole.coa.service.AccountingPeriodService;
24 import org.kuali.ole.fp.document.AuxiliaryVoucherDocument;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.ole.sys.document.validation.GenericValidation;
27 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
28 import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
29 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
30 import org.kuali.rice.krad.util.GlobalVariables;
31
32
33
34
35
36 public class AuxiliaryVoucherAccountingPeriodAllowedByParameterValidation extends GenericValidation {
37 private AuxiliaryVoucherDocument auxiliaryVoucherDocumentForValidation;
38 private ParameterService parameterService;
39 private AccountingPeriodService accountingPeriodService;
40
41
42
43
44
45 public boolean validate(AttributedDocumentEvent event) {
46 boolean valid = true;
47 AccountingPeriod acctPeriod = getAccountingPeriodService().getByPeriod(auxiliaryVoucherDocumentForValidation.getPostingPeriodCode(), auxiliaryVoucherDocumentForValidation.getPostingYear());
48
49 valid = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(AuxiliaryVoucherDocument.class, RESTRICTED_PERIOD_CODES, auxiliaryVoucherDocumentForValidation.getPostingPeriodCode()).evaluationSucceeds();
50 if (!valid) {
51 GlobalVariables.getMessageMap().putError(ACCOUNTING_PERIOD_ACTIVE_INDICATOR_FIELD, ERROR_ACCOUNTING_PERIOD_OUT_OF_RANGE);
52 }
53
54 return valid;
55 }
56
57
58
59
60
61 public AuxiliaryVoucherDocument getAuxiliaryVoucherDocumentForValidation() {
62 return auxiliaryVoucherDocumentForValidation;
63 }
64
65
66
67
68
69 public void setAuxiliaryVoucherDocumentForValidation(AuxiliaryVoucherDocument auxiliaryVoucherDocumentForValidation) {
70 this.auxiliaryVoucherDocumentForValidation = auxiliaryVoucherDocumentForValidation;
71 }
72
73
74
75
76
77 public ParameterService getParameterService() {
78 return parameterService;
79 }
80
81
82
83
84
85 public void setParameterService(ParameterService parameterService) {
86 this.parameterService = parameterService;
87 }
88
89
90
91
92
93 public AccountingPeriodService getAccountingPeriodService() {
94 return accountingPeriodService;
95 }
96
97
98
99
100
101 public void setAccountingPeriodService(AccountingPeriodService accountingPeriodService) {
102 this.accountingPeriodService = accountingPeriodService;
103 }
104 }