1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.businessobject.lookup;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.fp.businessobject.CashDrawer;
23 import org.kuali.ole.fp.document.service.CashReceiptService;
24 import org.kuali.ole.fp.service.CashDrawerService;
25 import org.kuali.rice.kns.lookup.HtmlData;
26 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
27 import org.kuali.rice.krad.bo.BusinessObject;
28 import org.kuali.rice.krad.document.DocumentAuthorizer;
29 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
30 import org.kuali.rice.krad.util.GlobalVariables;
31 import org.kuali.rice.krad.util.KRADConstants;
32
33
34
35
36
37 public class CashDrawerLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
38 protected CashReceiptService cashReceiptService;
39 protected CashDrawerService cashDrawerService;
40
41
42
43
44
45 @Override
46 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
47 List<HtmlData> htmlDataList = new ArrayList<HtmlData>();
48 if (StringUtils.isNotBlank(getMaintenanceDocumentTypeName()) && allowsMaintenanceEditAction(businessObject) && isEditOfCashDrawerAuthorized((CashDrawer)businessObject) && ((CashDrawer)businessObject).isClosed()) {
49 htmlDataList.add(getUrlData(businessObject, KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, pkNames));
50 }
51 return htmlDataList;
52 }
53
54
55
56
57
58
59 protected boolean isEditOfCashDrawerAuthorized(CashDrawer cashDrawer) {
60 String cashDrawerDocType = KRADServiceLocatorWeb.getDocumentDictionaryService().getMaintenanceDocumentTypeName(CashDrawer.class);
61 DocumentAuthorizer documentAuthorizer = KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentAuthorizer(cashDrawerDocType);
62 return documentAuthorizer.canInitiate(cashDrawerDocType, GlobalVariables.getUserSession().getPerson());
63 }
64
65
66
67
68
69
70 @Override
71 public boolean allowsMaintenanceNewOrCopyAction() {
72 final String currentUserCampus = cashReceiptService.getCashReceiptVerificationUnitForUser(GlobalVariables.getUserSession().getPerson());
73 final CashDrawer cashDrawer = cashDrawerService.getByCampusCode(currentUserCampus);
74
75 if (cashDrawer != null) {
76 return false;
77 }
78 return super.allowsMaintenanceNewOrCopyAction();
79 }
80
81 public void setCashDrawerService(CashDrawerService cashDrawerService) {
82 this.cashDrawerService = cashDrawerService;
83 }
84
85 public void setCashReceiptService(CashReceiptService cashReceiptService) {
86 this.cashReceiptService = cashReceiptService;
87 }
88
89 }