1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.fp.document.authorization;
17  
18  import java.util.List;
19  
20  import org.kuali.ole.fp.service.FiscalYearFunctionControlService;
21  import org.kuali.ole.sys.context.SpringContext;
22  import org.kuali.ole.sys.document.Correctable;
23  import org.kuali.ole.sys.document.FinancialSystemTransactionalDocument;
24  import org.kuali.ole.sys.document.authorization.AccountingDocumentPresentationControllerBase;
25  import org.kuali.ole.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry;
26  import org.kuali.rice.kew.api.WorkflowDocument;
27  import org.kuali.rice.kns.service.DataDictionaryService;
28  
29  
30  
31  
32  public class BudgetAdjustmentDocumentPresentationController extends AccountingDocumentPresentationControllerBase {
33      
34  
35  
36      @Override
37      public boolean canInitiate(String documentTypeName) {
38          List<Integer> allowedYears = SpringContext.getBean(FiscalYearFunctionControlService.class).getBudgetAdjustmentAllowedYears();
39  
40          
41          if (allowedYears == null || allowedYears.isEmpty()) {
42              return false;
43          }
44  
45          return super.canInitiate(documentTypeName);
46      }
47  
48      
49      
50  
51  
52      @Override
53      public boolean canErrorCorrect(FinancialSystemTransactionalDocument document) {
54          final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
55  
56          if (!(document instanceof Correctable)) return false;
57          if (!((FinancialSystemTransactionalDocumentEntry)SpringContext.getBean(DataDictionaryService.class).getDataDictionary().getDocumentEntry(document.getClass().getName())).getAllowsErrorCorrection()) return false;
58          if (document.getFinancialSystemDocumentHeader().getCorrectedByDocumentId() != null) return false;
59          return (workflowDocument.isApproved() || workflowDocument.isProcessed() || workflowDocument.isFinal());
60      }
61  
62  }