1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.document.validation.impl;
17
18 import java.util.Iterator;
19 import java.util.List;
20
21 import org.kuali.ole.coa.businessobject.AccountingPeriod;
22 import org.kuali.ole.sys.OLEKeyConstants;
23 import org.kuali.ole.sys.businessobject.SystemOptions;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.rice.kns.document.MaintenanceDocument;
26 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
27 import org.kuali.rice.krad.service.KeyValuesService;
28
29
30
31
32 public class AccountingPeriodRule extends MaintenanceDocumentRuleBase {
33
34 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountingPeriodRule.class);
35
36 protected static final String GENERAL_FUND_CD = "GF";
37 protected static final String RESTRICTED_FUND_CD = "RF";
38 protected static final String ENDOWMENT_FUND_CD = "EN";
39 protected static final String PLANT_FUND_CD = "PF";
40
41 protected static final String RESTRICTED_CD_RESTRICTED = "R";
42 protected static final String RESTRICTED_CD_UNRESTRICTED = "U";
43 protected static final String RESTRICTED_CD_TEMPORARILY_RESTRICTED = "T";
44 protected static final String SUB_FUND_GROUP_MEDICAL_PRACTICE_FUNDS = "MPRACT";
45 protected static final String BUDGET_RECORDING_LEVEL_MIXED = "M";
46
47 protected AccountingPeriod oldAccountingPeriod;
48 protected AccountingPeriod newAccountingPeriod;
49
50 public AccountingPeriodRule() {
51 }
52
53
54
55
56
57
58
59
60 public void setupConvenienceObjects() {
61
62
63 oldAccountingPeriod = (AccountingPeriod) super.getOldBo();
64
65
66 newAccountingPeriod = (AccountingPeriod) super.getNewBo();
67 }
68
69
70
71
72
73
74
75 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
76
77 LOG.info("processCustomSaveDocumentBusinessRules called");
78
79 processCustomRouteDocumentBusinessRules(document);
80
81
82 return true;
83 }
84
85
86
87
88
89
90
91 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
92
93 LOG.info("processCustomRouteDocumentBusinessRules called");
94 setupConvenienceObjects();
95
96 Boolean foundYear = false;
97
98 KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
99 List optionList = (List) boService.findAll(SystemOptions.class);
100 if ( newAccountingPeriod.getUniversityFiscalYear() != null) {
101 for (Iterator iter = optionList.iterator(); iter.hasNext();) {
102 SystemOptions options = (SystemOptions) iter.next();
103 if (options.getUniversityFiscalYear().compareTo(newAccountingPeriod.getUniversityFiscalYear()) == 0) {
104 foundYear = true;
105 break;
106 }
107 }
108 }
109 if (!foundYear) {
110
111 putFieldError("universityFiscalYear", OLEKeyConstants.ERROR_DOCUMENT_FISCAL_PERIOD_YEAR_DOESNT_EXIST);
112 }
113
114 return foundYear;
115 }
116
117 }