1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.businessobject.lookup;
17
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.kuali.ole.gl.Constant;
23 import org.kuali.ole.gl.GeneralLedgerConstants;
24 import org.kuali.ole.gl.businessobject.AccountBalance;
25 import org.kuali.ole.gl.businessobject.TransientBalanceInquiryAttributes;
26 import org.kuali.ole.gl.businessobject.inquiry.AccountBalanceByLevelInquirableImpl;
27 import org.kuali.ole.gl.service.AccountBalanceService;
28 import org.kuali.ole.sys.OLEConstants;
29 import org.kuali.ole.sys.OLEPropertyConstants;
30 import org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl;
31 import org.kuali.rice.kns.lookup.HtmlData;
32 import org.kuali.rice.krad.bo.BusinessObject;
33 import org.kuali.rice.krad.lookup.CollectionIncomplete;
34
35
36
37
38 public class AccountBalanceByLevelLookupableHelperServiceImpl extends AbstractLookupableHelperServiceImpl {
39 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByLevelLookupableHelperServiceImpl.class);
40
41 private AccountBalanceService accountBalanceService;
42
43 public void setAccountBalanceService(AccountBalanceService abs) {
44 accountBalanceService = abs;
45 }
46
47
48
49
50
51
52
53
54 @Override
55 public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
56 return (new AccountBalanceByLevelInquirableImpl()).getInquiryUrl(bo, propertyName);
57 }
58
59
60
61
62
63
64
65 public List getSearchResults(Map fieldValues) {
66 LOG.debug("getSearchResults() started");
67
68 setBackLocation((String) fieldValues.get(OLEConstants.BACK_LOCATION));
69 setDocFormKey((String) fieldValues.get(OLEConstants.DOC_FORM_KEY));
70
71 BusinessObjectFieldConverter.escapeSingleQuote(fieldValues);
72
73 String costShareOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.COST_SHARE_OPTION);
74 String pendingEntryOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.PENDING_ENTRY_OPTION);
75 String consolidationOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.CONSOLIDATION_OPTION);
76 boolean isCostShareExcluded = Constant.COST_SHARE_EXCLUDE.equals(costShareOption);
77 int pendingEntryCode = AccountBalanceService.PENDING_NONE;
78 if (GeneralLedgerConstants.PendingEntryOptions.APPROVED.equals(pendingEntryOption)) {
79 pendingEntryCode = AccountBalanceService.PENDING_APPROVED;
80 }
81 else if (GeneralLedgerConstants.PendingEntryOptions.ALL.equals(pendingEntryOption)) {
82 pendingEntryCode = AccountBalanceService.PENDING_ALL;
83 }
84 boolean isConsolidated = Constant.CONSOLIDATION.equals(consolidationOption);
85
86 String chartOfAccountsCode = (String) fieldValues.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
87 String accountNumber = (String) fieldValues.get(OLEPropertyConstants.ACCOUNT_NUMBER);
88 String subAccountNumber = (String) fieldValues.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
89 String financialConsolidationObjectCode = (String) fieldValues.get(GeneralLedgerConstants.BalanceInquiryDrillDowns.CONSOLIDATION_OBJECT_CODE);
90
91
92 if (OLEConstants.getDashSubAccountNumber().equals(subAccountNumber)) {
93 subAccountNumber = "";
94 }
95
96 String ufy = (String) fieldValues.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
97
98
99 Integer universityFiscalYear = new Integer(Integer.parseInt(ufy));
100
101 List results = accountBalanceService.findAccountBalanceByLevel(universityFiscalYear, chartOfAccountsCode, accountNumber, subAccountNumber, financialConsolidationObjectCode, isCostShareExcluded, isConsolidated, pendingEntryCode);
102
103
104 for (Iterator iter = results.iterator(); iter.hasNext();) {
105 AccountBalance ab = (AccountBalance) iter.next();
106
107 TransientBalanceInquiryAttributes dbo = ab.getDummyBusinessObject();
108 dbo.setConsolidationOption(consolidationOption);
109 dbo.setCostShareOption(costShareOption);
110 dbo.setPendingEntryOption(pendingEntryOption);
111 dbo.setLinkButtonOption(Constant.LOOKUP_BUTTON_VALUE);
112 }
113 return new CollectionIncomplete(results, new Long(results.size()));
114 }
115 }