1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.web.struts;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import javax.servlet.http.HttpServletRequest;
22
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.struts.util.LabelValueBean;
25 import org.kuali.ole.fp.businessobject.CapitalAssetInformation;
26 import org.kuali.ole.fp.businessobject.CashDrawer;
27 import org.kuali.ole.fp.businessobject.Check;
28 import org.kuali.ole.fp.document.CapitalAssetEditable;
29 import org.kuali.ole.fp.document.CashManagementDocument;
30 import org.kuali.ole.fp.document.CashReceiptDocument;
31 import org.kuali.ole.fp.document.service.CashManagementService;
32 import org.kuali.ole.fp.document.service.CashReceiptCoverSheetService;
33 import org.kuali.ole.fp.service.CashDrawerService;
34 import org.kuali.ole.sys.OLEConstants;
35 import org.kuali.ole.sys.OLEConstants.DocumentStatusCodes.CashReceipt;
36 import org.kuali.ole.sys.OLEKeyConstants;
37 import org.kuali.ole.sys.context.SpringContext;
38 import org.kuali.ole.sys.service.FinancialSystemWorkflowHelperService;
39 import org.kuali.rice.core.api.config.property.ConfigurationService;
40 import org.kuali.rice.core.api.util.type.KualiDecimal;
41 import org.kuali.rice.core.web.format.SimpleBooleanFormatter;
42 import org.kuali.rice.krad.util.GlobalVariables;
43
44
45
46
47 public class CashReceiptForm extends CapitalAccountingLinesFormBase implements CapitalAssetEditable{
48 protected static final long serialVersionUID = 1L;
49 protected static final String CAN_PRINT_COVERSHEET_SIG_STR = "isCoverSheetPrintingAllowed";
50
51 protected Check newCheck;
52 protected Check newConfirmedCheck;
53
54 protected KualiDecimal checkTotal;
55
56 protected String checkEntryMode;
57 protected List checkEntryModes;
58
59 protected List baselineChecks;
60
61 protected List<CapitalAssetInformation> capitalAssetInformation;
62
63
64
65
66 public CashReceiptForm() {
67 super();
68 setFormatterType(CAN_PRINT_COVERSHEET_SIG_STR, SimpleBooleanFormatter.class);
69 setNewCheck(getCashReceiptDocument().createNewCheck());
70 setNewConfirmedCheck(getCashReceiptDocument().createNewConfirmedCheck());
71
72 checkEntryModes = new ArrayList();
73 checkEntryModes.add(new LabelValueBean("Individual Checks/Batches", CashReceiptDocument.CHECK_ENTRY_DETAIL));
74 checkEntryModes.add(new LabelValueBean("Total Only", CashReceiptDocument.CHECK_ENTRY_TOTAL));
75
76 baselineChecks = new ArrayList();
77 capitalAssetInformation = new ArrayList<CapitalAssetInformation>();
78 this.capitalAccountingLine.setCanCreateAsset(false);
79 }
80
81 @Override
82 protected String getDefaultDocumentTypeName() {
83 return "OLE_CR";
84 }
85
86 @Override
87 public void populate(HttpServletRequest request) {
88 super.populate(request);
89
90 setCheckEntryMode(getCashReceiptDocument().getCheckEntryMode());
91 }
92
93
94
95
96 public CashReceiptDocument getCashReceiptDocument() {
97 return (CashReceiptDocument) getDocument();
98 }
99
100
101
102
103 public Check getNewCheck() {
104 return newCheck;
105 }
106
107
108
109
110 public void setNewCheck(Check newCheck) {
111 this.newCheck = newCheck;
112 }
113
114
115
116
117 public Check getNewConfirmedCheck() {
118 return newConfirmedCheck;
119 }
120
121
122
123
124 public void setNewConfirmedCheck(Check newConfirmedCheck) {
125 this.newConfirmedCheck = newConfirmedCheck;
126 }
127
128
129
130
131 public void setCheckTotal(KualiDecimal checkTotal) {
132 this.checkTotal = checkTotal;
133 }
134
135
136
137
138 public KualiDecimal getCheckTotal() {
139 return checkTotal;
140 }
141
142
143
144
145 public List getCheckEntryModes() {
146 return checkEntryModes;
147 }
148
149
150
151
152 public String getCheckEntryMode() {
153 return checkEntryMode;
154 }
155
156
157
158
159 public void setCheckEntryMode(String checkEntryMode) {
160 this.checkEntryMode = checkEntryMode;
161 }
162
163
164
165
166 public boolean isCheckEntryDetailMode() {
167 return CashReceiptDocument.CHECK_ENTRY_DETAIL.equals(getCheckEntryMode());
168 }
169
170
171
172
173 public List getBaselineChecks() {
174 return baselineChecks;
175 }
176
177
178
179
180
181
182 public void setBaselineChecks(List baselineChecks) {
183 this.baselineChecks = baselineChecks;
184 }
185
186
187
188
189
190 public boolean hasBaselineCheck(int index) {
191 boolean has = false;
192
193 if ((index >= 0) && (index < baselineChecks.size())) {
194 has = true;
195 }
196
197 return has;
198 }
199
200
201
202
203
204
205
206
207 public Check getBaselineCheck(int index) {
208 while (baselineChecks.size() <= index) {
209 baselineChecks.add(getCashReceiptDocument().createNewCheck());
210 }
211 return (Check) baselineChecks.get(index);
212 }
213
214
215
216
217
218
219 public String getFinancialDocumentStatusMessage() {
220 String financialDocumentStatusMessage = "";
221 CashReceiptDocument crd = getCashReceiptDocument();
222 String financialDocumentStatusCode = crd.getFinancialSystemDocumentHeader().getFinancialDocumentStatusCode();
223 if (financialDocumentStatusCode.equals(CashReceipt.VERIFIED)) {
224 financialDocumentStatusMessage = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.CashReceipt.MSG_VERIFIED_BUT_NOT_AWAITING_DEPOSIT);
225 }
226 else if (financialDocumentStatusCode.equals(CashReceipt.INTERIM) || financialDocumentStatusCode.equals(CashReceipt.FINAL)) {
227 CashManagementDocument cmd = SpringContext.getBean(CashManagementService.class).getCashManagementDocumentForCashReceiptId(crd.getDocumentNumber());
228 if (cmd != null) {
229 String cmdFinancialDocNbr = cmd.getDocumentNumber();
230
231 String loadCMDocUrl = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.CashManagement.URL_LOAD_DOCUMENT_CASH_MGMT);
232 loadCMDocUrl = StringUtils.replace(loadCMDocUrl, "{0}", cmdFinancialDocNbr);
233
234 financialDocumentStatusMessage = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.CashReceipt.MSG_VERIFIED_AND_AWAITING_DEPOSIT);
235 financialDocumentStatusMessage = StringUtils.replace(financialDocumentStatusMessage, "{0}", loadCMDocUrl);
236 }
237 }
238 else if (financialDocumentStatusCode.equals(OLEConstants.DocumentStatusCodes.APPROVED)) {
239 CashManagementDocument cmd = SpringContext.getBean(CashManagementService.class).getCashManagementDocumentForCashReceiptId(crd.getDocumentNumber());
240 if (cmd != null) {
241 String cmdFinancialDocNbr = cmd.getDocumentNumber();
242
243 String loadCMDocUrl = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.CashManagement.URL_LOAD_DOCUMENT_CASH_MGMT);
244 loadCMDocUrl = StringUtils.replace(loadCMDocUrl, "{0}", cmdFinancialDocNbr);
245
246 financialDocumentStatusMessage = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.CashReceipt.MSG_VERIFIED_AND_DEPOSITED);
247 financialDocumentStatusMessage = StringUtils.replace(financialDocumentStatusMessage, "{0}", loadCMDocUrl);
248 }
249 }
250 return financialDocumentStatusMessage;
251 }
252
253
254
255
256
257
258 public String getCashDrawerStatusMessage() {
259 String cashDrawerStatusMessage = "";
260 CashReceiptDocument crd = getCashReceiptDocument();
261
262
263 if (crd != null
264 && crd.getDocumentHeader() != null
265 && crd.getDocumentHeader().getWorkflowDocument() != null) {
266 if (crd.getDocumentHeader().getWorkflowDocument().isEnroute()) {
267 CashDrawer cd = SpringContext.getBean(CashDrawerService.class).getByCampusCode(crd.getCampusLocationCode());
268 if ( cd != null ) {
269 if (crd.getDocumentHeader().getWorkflowDocument().isApprovalRequested()
270 && cd.isClosed()
271 && !SpringContext.getBean(FinancialSystemWorkflowHelperService.class).isAdhocApprovalRequestedForPrincipal(crd.getDocumentHeader().getWorkflowDocument(), GlobalVariables.getUserSession().getPrincipalId())) {
272 cashDrawerStatusMessage = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEKeyConstants.CashReceipt.MSG_CASH_DRAWER_CLOSED_VERIFICATION_NOT_ALLOWED);
273 cashDrawerStatusMessage = StringUtils.replace(cashDrawerStatusMessage, "{0}", crd.getCampusLocationCode());
274 }
275 }
276 }
277 }
278
279 return cashDrawerStatusMessage;
280 }
281
282
283
284
285
286
287 public boolean isCoverSheetPrintingAllowed() {
288 return SpringContext.getBean(CashReceiptCoverSheetService.class).isCoverSheetPrintingAllowed(getCashReceiptDocument());
289 }
290
291
292
293
294 @Override
295 public List<CapitalAssetInformation> getCapitalAssetInformation() {
296 return this.capitalAssetInformation;
297 }
298
299
300
301
302 @Override
303 public void setCapitalAssetInformation(List<CapitalAssetInformation> capitalAssetInformation) {
304 this.capitalAssetInformation = capitalAssetInformation;
305 }
306
307
308
309
310 @Override
311 protected List<String> getExcludedmethodToCall() {
312 List<String> execludedMethodToCall = super.getExcludedmethodToCall();
313 execludedMethodToCall.add("printCoverSheet");
314
315 return execludedMethodToCall;
316 }
317 }