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.AccountBalanceByConsolidationInquirableImpl;
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 AccountBalanceByConsolidationLookupableHelperServiceImpl extends AbstractLookupableHelperServiceImpl {
39
40 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByConsolidationLookupableHelperServiceImpl.class);
41
42 private AccountBalanceService accountBalanceService;
43
44 public void setAccountBalanceService(AccountBalanceService abs) {
45 accountBalanceService = abs;
46 }
47
48
49
50
51
52
53
54
55 @Override
56 public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
57 HtmlData hRef = (new AccountBalanceByConsolidationInquirableImpl()).getInquiryUrl(bo, propertyName);
58 return hRef;
59 }
60
61
62
63
64
65
66
67 @Override
68 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
69 LOG.debug("getSearchResults() started");
70
71 setBackLocation((String) fieldValues.get(OLEConstants.BACK_LOCATION));
72 setDocFormKey((String) fieldValues.get(OLEConstants.DOC_FORM_KEY));
73
74 BusinessObjectFieldConverter.escapeSingleQuote(fieldValues);
75
76 String costShareOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.COST_SHARE_OPTION);
77 String pendingEntryOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.PENDING_ENTRY_OPTION);
78
79 String consolidationOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.CONSOLIDATION_OPTION);
80 String chartOfAccountsCode = (String) fieldValues.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
81 String accountNumber = (String) fieldValues.get(OLEPropertyConstants.ACCOUNT_NUMBER);
82 String subAccountNumber = (String) fieldValues.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
83 String ufy = (String) fieldValues.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
84
85 boolean isCostShareExcluded = Constant.COST_SHARE_EXCLUDE.equals(costShareOption);
86
87 int pendingEntryCode = AccountBalanceService.PENDING_NONE;
88 if (GeneralLedgerConstants.PendingEntryOptions.APPROVED.equals(pendingEntryOption)) {
89 pendingEntryCode = AccountBalanceService.PENDING_APPROVED;
90 }
91 else if (GeneralLedgerConstants.PendingEntryOptions.ALL.equals(pendingEntryOption)) {
92 pendingEntryCode = AccountBalanceService.PENDING_ALL;
93 }
94 boolean isConsolidated = Constant.CONSOLIDATION.equals(consolidationOption);
95
96
97 if (consolidationOption.equals(Constant.EXCLUDE_SUBACCOUNTS)){
98 subAccountNumber = OLEConstants.getDashSubAccountNumber();
99 isConsolidated = false;
100 }
101
102
103 Integer universityFiscalYear = new Integer(Integer.parseInt(ufy));
104
105 List results = accountBalanceService.findAccountBalanceByConsolidation(universityFiscalYear, chartOfAccountsCode, accountNumber, subAccountNumber, isCostShareExcluded, isConsolidated, pendingEntryCode);
106
107
108 int count = 0;
109 for (Iterator iter = results.iterator(); iter.hasNext();) {
110 AccountBalance ab = (AccountBalance) iter.next();
111 count++;
112 TransientBalanceInquiryAttributes dbo = ab.getDummyBusinessObject();
113 dbo.setConsolidationOption(consolidationOption);
114 dbo.setCostShareOption(costShareOption);
115 dbo.setPendingEntryOption(pendingEntryOption);
116 dbo.setLinkButtonOption(Constant.LOOKUP_BUTTON_VALUE);
117
118
119 if (count > 7) {
120 dbo.setGenericAmount(ab.getVariance());
121 }
122 }
123 return new CollectionIncomplete(results, new Long(results.size()));
124 }
125 }