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 import java.util.Map;
21
22 import org.kuali.ole.fp.businessobject.Check;
23 import org.kuali.ole.fp.businessobject.CheckBase;
24 import org.kuali.ole.fp.businessobject.CoinDetail;
25 import org.kuali.ole.fp.businessobject.CurrencyDetail;
26 import org.kuali.ole.fp.businessobject.DepositWizardCashieringCheckHelper;
27 import org.kuali.ole.fp.businessobject.DepositWizardHelper;
28 import org.kuali.ole.fp.businessobject.format.CashReceiptDepositTypeFormatter;
29 import org.kuali.ole.fp.document.CashReceiptDocument;
30 import org.kuali.ole.sys.OLEConstants;
31 import org.kuali.ole.sys.OLEKeyConstants;
32 import org.kuali.ole.sys.businessobject.Bank;
33 import org.kuali.ole.sys.context.SpringContext;
34 import org.kuali.ole.sys.service.BankService;
35 import org.kuali.rice.core.api.util.type.KualiDecimal;
36 import org.kuali.rice.core.web.format.CurrencyFormatter;
37 import org.kuali.rice.kns.util.WebUtils;
38 import org.kuali.rice.kns.web.struts.form.KualiForm;
39
40
41
42
43 public class DepositWizardForm extends KualiForm {
44 private String cashDrawerCampusCode;
45 private String cashManagementDocId;
46
47 private List<CashReceiptDocument> depositableCashReceipts;
48 private List depositWizardHelpers;
49 private List<Check> depositableCashieringChecks;
50 private transient List<DepositWizardCashieringCheckHelper> depositWizardCashieringCheckHelpers;
51 private List<CashReceiptDocument> checkFreeCashReceipts;
52
53
54 private Bank bank;
55 private String bankCode;
56
57 private String depositTypeCode;
58 private String depositTicketNumber;
59
60 private CurrencyDetail currencyDetail;
61 private CoinDetail coinDetail;
62
63 private KualiDecimal targetDepositAmount;
64 private KualiDecimal currentCheckTotal;
65
66
67 protected Map editingMode;
68 protected Map documentActions;
69
70 protected String noVerifiedCashErrorMessage = "";
71
72
73
74
75 public DepositWizardForm() {
76 depositableCashReceipts = new ArrayList();
77 depositableCashieringChecks = new ArrayList<Check>();
78 depositWizardHelpers = new ArrayList();
79 depositWizardCashieringCheckHelpers = new ArrayList<DepositWizardCashieringCheckHelper>();
80
81 setFormatterType("depositTypeCode", CashReceiptDepositTypeFormatter.class);
82 setDefaultBankCode();
83 }
84
85
86
87
88 public void setDefaultBankCode() {
89 Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(OLEConstants.FinancialDocumentTypeCodes.CASH_MANAGEMENT);
90 if (defaultBank != null) {
91 this.bankCode = defaultBank.getBankCode();
92 this.bank = defaultBank;
93 }
94 }
95
96
97
98
99 public String getCashManagementDocId() {
100 return cashManagementDocId;
101 }
102
103
104
105
106
107
108 public void setCashManagementDocId(String cashManagementDocId) {
109 this.cashManagementDocId = cashManagementDocId;
110 }
111
112
113
114
115
116 public void setDepositTypeCode(String depositTypeCode) {
117 this.depositTypeCode = depositTypeCode;
118 }
119
120
121
122
123 public String getDepositTypeCode() {
124 return depositTypeCode;
125 }
126
127
128
129
130
131
132 public String getDepositTypeString() {
133 CashReceiptDepositTypeFormatter f = new CashReceiptDepositTypeFormatter();
134 return (String) f.format(getDepositTypeCode());
135 }
136
137
138
139
140
141 public List<CashReceiptDocument> getDepositableCashReceipts() {
142 return depositableCashReceipts;
143 }
144
145
146
147
148 public void setDepositableCashReceipts(List cashReceiptsReadyForDeposit) {
149 this.depositableCashReceipts = cashReceiptsReadyForDeposit;
150 }
151
152 public CashReceiptDocument getDepositableCashReceipt(int i) {
153 while (depositableCashReceipts.size() <= i) {
154 depositableCashReceipts.add(new CashReceiptDocument());
155 }
156
157 return (CashReceiptDocument) depositableCashReceipts.get(i);
158 }
159
160
161
162
163 public List getDepositWizardHelpers() {
164 return depositWizardHelpers;
165 }
166
167
168
169
170 public void setDepositWizardHelpers(List depositWizardHelpers) {
171 this.depositWizardHelpers = depositWizardHelpers;
172 }
173
174
175
176
177
178
179
180 public DepositWizardHelper getDepositWizardHelper(int index) {
181 while (this.depositWizardHelpers.size() <= index) {
182 this.depositWizardHelpers.add(new DepositWizardHelper());
183
184 }
185 return (DepositWizardHelper) this.depositWizardHelpers.get(index);
186 }
187
188
189
190
191
192 public String getCashDrawerCampusCode() {
193 return cashDrawerCampusCode;
194 }
195
196
197
198
199
200
201 public void setCashDrawerCampusCode(String cashDrawerVerificationUnit) {
202 this.cashDrawerCampusCode = cashDrawerVerificationUnit;
203 }
204
205
206
207
208
209 public String getBankCode() {
210 return bankCode;
211 }
212
213
214
215
216
217
218 public void setBankCode(String bankCode) {
219 this.bankCode = bankCode;
220 }
221
222
223
224
225 public String getDepositTicketNumber() {
226 return depositTicketNumber;
227 }
228
229
230
231
232
233
234 public void setDepositTicketNumber(String depositTicketNumber) {
235 this.depositTicketNumber = depositTicketNumber;
236 }
237
238
239
240
241 public Bank getBank() {
242 return bank;
243 }
244
245
246
247
248
249
250 public void setBank(Bank bank) {
251 this.bank = bank;
252 }
253
254
255
256
257
258
259 public CoinDetail getCoinDetail() {
260 return coinDetail;
261 }
262
263
264
265
266
267
268
269 public void setCoinDetail(CoinDetail coinDetail) {
270 this.coinDetail = coinDetail;
271 }
272
273
274
275
276
277
278
279 public CurrencyDetail getCurrencyDetail() {
280 return currencyDetail;
281 }
282
283
284
285
286
287
288
289 public void setCurrencyDetail(CurrencyDetail currencyDetail) {
290 this.currencyDetail = currencyDetail;
291 }
292
293
294
295
296
297
298 public String getCurrencyFormattedSumTotalAmount() {
299 return (String) new CurrencyFormatter().format(getTotalDollarAmount());
300 }
301
302
303
304
305
306
307 public KualiDecimal getTotalDollarAmount() {
308 KualiDecimal sumTotalAmount = getTotalCoinAmount().add(getTotalCashAmount());
309 return sumTotalAmount;
310 }
311
312
313
314
315
316
317 public KualiDecimal getTotalCoinAmount() {
318 return (coinDetail != null) ? coinDetail.getTotalAmount() : KualiDecimal.ZERO;
319 }
320
321
322
323
324
325
326 public KualiDecimal getTotalCashAmount() {
327 return (currencyDetail != null) ? currencyDetail.getTotalAmount() : KualiDecimal.ZERO;
328 }
329
330
331
332
333
334
335 public boolean isDepositFinal() {
336 return (depositTypeCode.equals(OLEConstants.DepositConstants.DEPOSIT_TYPE_FINAL));
337 }
338
339
340
341
342
343
344 public List<Check> getDepositableCashieringChecks() {
345 return depositableCashieringChecks;
346 }
347
348
349
350
351
352
353 public void setDepositableCashieringChecks(List<Check> depositableCashieringChecks) {
354 this.depositableCashieringChecks = depositableCashieringChecks;
355 }
356
357
358
359
360
361
362
363 public Check getDepositableCashieringCheck(int index) {
364 while (this.depositableCashieringChecks.size() <= index) {
365 this.depositableCashieringChecks.add(new CheckBase());
366 }
367 return this.depositableCashieringChecks.get(index);
368 }
369
370
371
372
373
374
375 public List<DepositWizardCashieringCheckHelper> getDepositWizardCashieringCheckHelpers() {
376 return depositWizardCashieringCheckHelpers;
377 }
378
379
380
381
382
383
384 public List<CashReceiptDocument> getCheckFreeCashReceipts() {
385 return checkFreeCashReceipts;
386 }
387
388
389
390
391
392
393
394 public void setCheckFreeCashReceipts(List<CashReceiptDocument> checkFreeCashReceipts) {
395 this.checkFreeCashReceipts = checkFreeCashReceipts;
396 }
397
398
399
400
401
402
403
404 public CashReceiptDocument getCheckFreeCashReceipt(int index) {
405 while (this.checkFreeCashReceipts.size() <= index) {
406 this.checkFreeCashReceipts.add(new CashReceiptDocument());
407 }
408 return this.checkFreeCashReceipts.get(index);
409 }
410
411
412
413
414
415
416 public void setDepositWizardCashieringCheckHelpers(List<DepositWizardCashieringCheckHelper> depositWizardCashieringCheckHelpers) {
417 this.depositWizardCashieringCheckHelpers = depositWizardCashieringCheckHelpers;
418 }
419
420 public DepositWizardCashieringCheckHelper getDepositWizardCashieringCheckHelper(int index) {
421 while (this.depositWizardCashieringCheckHelpers.size() <= index) {
422 this.depositWizardCashieringCheckHelpers.add(new DepositWizardCashieringCheckHelper());
423 }
424 return this.depositWizardCashieringCheckHelpers.get(index);
425 }
426
427
428
429
430
431 public Map getDocumentActions() {
432 return documentActions;
433 }
434
435
436
437
438
439 public void setDocumentActions(Map documentActions) {
440 this.documentActions = documentActions;
441 }
442
443
444
445
446
447 public Map getEditingMode() {
448 return editingMode;
449 }
450
451
452
453
454
455 public void setEditingMode(Map editingMode) {
456 this.editingMode = editingMode;
457 }
458
459
460
461
462 public KualiDecimal getTargetDepositAmount() {
463 return targetDepositAmount;
464 }
465
466
467
468
469
470
471
472 public void addCashReceiptToTargetTotal(CashReceiptDocument crDoc) {
473 if (targetDepositAmount == null) {
474 targetDepositAmount = KualiDecimal.ZERO;
475 }
476 if (crDoc.getFinancialSystemDocumentHeader().getFinancialDocumentStatusCode().equals(OLEConstants.DocumentStatusCodes.CashReceipt.VERIFIED) || crDoc.getFinancialSystemDocumentHeader().getFinancialDocumentStatusCode().equals(OLEConstants.DocumentStatusCodes.CashReceipt.FINAL)) {
477 targetDepositAmount = targetDepositAmount.add(crDoc.getTotalConfirmedCheckAmount());
478 }
479 targetDepositAmount = targetDepositAmount.add(crDoc.getConfirmedCurrencyDetail().getTotalAmount()).subtract(crDoc.getChangeCurrencyDetail().getTotalAmount()).add(crDoc.getConfirmedCoinDetail().getTotalAmount()).subtract(crDoc.getChangeCoinDetail().getTotalAmount());
480 }
481
482
483
484
485
486 public void addCashieringTransactionToTargetTotal(KualiDecimal undepositedCheckAmount) {
487 if (targetDepositAmount == null) {
488 targetDepositAmount = KualiDecimal.ZERO;
489 }
490 targetDepositAmount = targetDepositAmount.subtract(undepositedCheckAmount);
491 }
492
493
494
495
496 public KualiDecimal getCurrentCheckTotal() {
497 return currentCheckTotal;
498 }
499
500
501
502
503
504 public void addCashReceiptToChecks(CashReceiptDocument crDoc) {
505 if (currentCheckTotal == null) {
506 currentCheckTotal = KualiDecimal.ZERO;
507 }
508 currentCheckTotal = currentCheckTotal.add(crDoc.getTotalConfirmedCheckAmount());
509 }
510
511
512
513
514 public String getNoVerifiedCashErrorMessage() {
515 String errorMessage = WebUtils.getKualiConfigurationService().getPropertyValueAsString(OLEKeyConstants.CashManagement.ERROR_NO_VERIFIED_CASH);
516 errorMessage = errorMessage.replace("{0}", getCashDrawerCampusCode());
517 errorMessage = errorMessage.replace("{1}", getCashManagementDocId());
518 return WebUtils.filterHtmlAndReplaceRiceMarkup(errorMessage);
519 }
520
521
522
523
524 public void setNoVerifiedCashErrorMessage(String noVerifiedCashErrorMessage) {
525 this.noVerifiedCashErrorMessage = noVerifiedCashErrorMessage;
526 }
527
528
529 }