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 org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.coa.businessobject.Account;
20 import org.kuali.ole.fp.businessobject.BudgetAdjustmentAccountingLine;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.OLEKeyConstants;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.ole.sys.document.validation.GenericValidation;
26 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
27 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
28 import org.kuali.rice.krad.util.GlobalVariables;
29 import org.kuali.rice.krad.util.ObjectUtils;
30
31
32
33
34 public class BudgetAdjustmentAccountingLineAccountIncomeStreamValidation extends GenericValidation {
35 private BudgetAdjustmentAccountingLine accountingLineForValidation;
36
37
38
39
40
41 public boolean validate(AttributedDocumentEvent event) {
42 boolean accountNumberAllowed = true;
43 if (getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount().isNonZero()) {
44 getAccountingLineForValidation().refreshReferenceObject("account");
45
46 if (!ObjectUtils.isNull(getAccountingLineForValidation().getAccount())) {
47
48 String fundGroupCode = getAccountingLineForValidation().getAccount().getSubFundGroup().getFundGroupCode();
49 String incomeStreamRequiringFundGroupCode = SpringContext.getBean(ParameterService.class).getParameterValueAsString(Account.class, OLEConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS);
50 if (StringUtils.containsIgnoreCase(fundGroupCode, incomeStreamRequiringFundGroupCode)) {
51 if (ObjectUtils.isNull(getAccountingLineForValidation().getAccount().getIncomeStreamAccount())) {
52 GlobalVariables.getMessageMap().putError(OLEPropertyConstants.ACCOUNT_NUMBER, OLEKeyConstants.ERROR_DOCUMENT_BA_NO_INCOME_STREAM_ACCOUNT, getAccountingLineForValidation().getAccountNumber());
53 accountNumberAllowed = false;
54 }
55 }
56 }
57 }
58
59 return accountNumberAllowed;
60 }
61
62
63
64
65
66 public BudgetAdjustmentAccountingLine getAccountingLineForValidation() {
67 return accountingLineForValidation;
68 }
69
70
71
72
73
74 public void setAccountingLineForValidation(BudgetAdjustmentAccountingLine accountingLineForValidation) {
75 this.accountingLineForValidation = accountingLineForValidation;
76 }
77 }