1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.module.purap.service.impl;
17  
18  import org.kuali.ole.coa.businessobject.Account;
19  import org.kuali.ole.coa.businessobject.ObjectCode;
20  import org.kuali.ole.coa.businessobject.SubObjectCode;
21  import org.kuali.ole.coa.service.ObjectCodeService;
22  import org.kuali.ole.coa.service.SubObjectCodeService;
23  import org.kuali.ole.module.purap.PurapKeyConstants;
24  import org.kuali.ole.sys.OLEConstants;
25  import org.kuali.ole.sys.OLEKeyConstants;
26  import org.kuali.ole.sys.businessobject.AccountingLine;
27  import org.kuali.ole.sys.context.SpringContext;
28  import org.kuali.rice.krad.datadictionary.DataDictionary;
29  import org.kuali.rice.krad.util.GlobalVariables;
30  import org.kuali.rice.krad.util.ObjectUtils;
31  
32  public class PurchasingAccountingLineRuleHelperServiceImpl extends PurapAccountingLineRuleHelperServiceImpl {
33  
34      
35  
36  
37  
38      @Override
39      public boolean hasRequiredOverrides(AccountingLine line, String overrideCode) {
40          boolean retVal = true;
41          Account account = line.getAccount();
42          if (!ObjectUtils.isNull(account) && account.isExpired()) {
43              GlobalVariables.getMessageMap().putError(OLEConstants.ACCOUNT_NUMBER_PROPERTY_NAME, PurapKeyConstants.ERROR_ITEM_ACCOUNT_EXPIRED, account.getAccountNumber());
44              retVal = false;
45          }
46          return retVal;
47      }
48  
49      public boolean isValidObjectCode(ObjectCode objectCode, DataDictionary dataDictionary, String errorPropertyName) {
50          String label = getObjectCodeLabel();
51  
52          
53          if (ObjectUtils.isNull(objectCode)) {
54              GlobalVariables.getMessageMap().putError(errorPropertyName, OLEKeyConstants.ERROR_EXISTENCE, label);
55              return false;
56          }
57  
58          Integer universityFiscalYear = getDocument().getPostingYearNextOrCurrent();
59          ObjectCode objectCodeForValidation = (SpringContext.getBean(ObjectCodeService.class).getByPrimaryId(universityFiscalYear, objectCode.getChartOfAccountsCode(), objectCode.getFinancialObjectCode()));
60  
61          
62          if (objectCodeForValidation == null || !objectCodeForValidation.isFinancialObjectActiveCode()) {
63              GlobalVariables.getMessageMap().putError(errorPropertyName, OLEKeyConstants.ERROR_INACTIVE, label);
64              return false;
65          }
66  
67          return true;
68      }
69  
70      public boolean isValidSubObjectCode(SubObjectCode subObjectCode, DataDictionary dataDictionary, String errorPropertyName) {
71          String label = getSubObjectCodeLabel();
72  
73          
74          if (ObjectUtils.isNull(subObjectCode)) {
75              GlobalVariables.getMessageMap().putError(errorPropertyName, OLEKeyConstants.ERROR_EXISTENCE, label);
76              return false;
77          }
78  
79          Integer universityFiscalYear = getDocument().getPostingYearNextOrCurrent();
80          SubObjectCode subObjectCodeForValidation = (SpringContext.getBean(SubObjectCodeService.class).getByPrimaryId(universityFiscalYear, subObjectCode.getChartOfAccountsCode(), subObjectCode.getAccountNumber(), subObjectCode.getFinancialObjectCode(), subObjectCode.getFinancialSubObjectCode()));
81  
82  
83          
84          if (!subObjectCodeForValidation.isActive()) {
85              GlobalVariables.getMessageMap().putError(errorPropertyName, OLEKeyConstants.ERROR_INACTIVE, label);
86              return false;
87          }
88          return true;
89      }
90  
91  }