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.HtmlData;
31 import org.kuali.rice.kns.lookup.KualiLookupableImpl;
32 import org.kuali.rice.krad.bo.PersistableBusinessObject;
33 import org.kuali.rice.krad.lookup.CollectionIncomplete;
34
35
36
37
38 public class AccountBalanceByLevelLookupableImpl extends KualiLookupableImpl {
39 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByLevelLookupableImpl.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 public HtmlData getInquiryUrl(PersistableBusinessObject bo, String propertyName) {
55 return (new AccountBalanceByLevelInquirableImpl()).getInquiryUrl(bo, propertyName);
56 }
57
58
59
60
61
62
63
64 public List getSearchResults(Map fieldValues) {
65 LOG.debug("getSearchResults() started");
66
67 setBackLocation((String) fieldValues.get(OLEConstants.BACK_LOCATION));
68 setDocFormKey((String) fieldValues.get(OLEConstants.DOC_FORM_KEY));
69
70 BusinessObjectFieldConverter.escapeSingleQuote(fieldValues);
71
72 String costShareOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.COST_SHARE_OPTION);
73 String pendingEntryOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.PENDING_ENTRY_OPTION);
74 String consolidationOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.CONSOLIDATION_OPTION);
75 boolean isCostShareExcluded = Constant.COST_SHARE_EXCLUDE.equals(costShareOption);
76 int pendingEntryCode = AccountBalanceService.PENDING_NONE;
77 if (GeneralLedgerConstants.PendingEntryOptions.APPROVED.equals(pendingEntryOption)) {
78 pendingEntryCode = AccountBalanceService.PENDING_APPROVED;
79 }
80 else if (GeneralLedgerConstants.PendingEntryOptions.ALL.equals(pendingEntryOption)) {
81 pendingEntryCode = AccountBalanceService.PENDING_ALL;
82 }
83 boolean isConsolidated = Constant.CONSOLIDATION.equals(consolidationOption);
84
85 String chartOfAccountsCode = (String) fieldValues.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
86 String accountNumber = (String) fieldValues.get(OLEPropertyConstants.ACCOUNT_NUMBER);
87 String subAccountNumber = (String) fieldValues.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
88 String financialConsolidationObjectCode = (String) fieldValues.get(GeneralLedgerConstants.BalanceInquiryDrillDowns.CONSOLIDATION_OBJECT_CODE);
89
90
91 if (OLEConstants.getDashSubAccountNumber().equals(subAccountNumber)) {
92 subAccountNumber = "";
93 }
94
95 String ufy = (String) fieldValues.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
96
97
98 Integer universityFiscalYear = new Integer(Integer.parseInt(ufy));
99
100 List results = accountBalanceService.findAccountBalanceByLevel(universityFiscalYear, chartOfAccountsCode, accountNumber, subAccountNumber, financialConsolidationObjectCode, isCostShareExcluded, isConsolidated, pendingEntryCode);
101
102
103 for (Iterator iter = results.iterator(); iter.hasNext();) {
104 AccountBalance ab = (AccountBalance) iter.next();
105
106 TransientBalanceInquiryAttributes dbo = ab.getDummyBusinessObject();
107 dbo.setConsolidationOption(consolidationOption);
108 dbo.setCostShareOption(costShareOption);
109 dbo.setPendingEntryOption(pendingEntryOption);
110 dbo.setLinkButtonOption(Constant.LOOKUP_BUTTON_VALUE);
111 }
112 return new CollectionIncomplete(results, new Long(results.size()));
113 }
114 }