001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.fp.document.web.struts;
017
018 import java.io.Serializable;
019 import java.sql.Timestamp;
020 import java.util.ArrayList;
021 import java.util.HashMap;
022 import java.util.Iterator;
023 import java.util.List;
024 import java.util.Map;
025
026 import org.apache.log4j.Logger;
027 import org.kuali.kfs.fp.businessobject.CashDrawer;
028 import org.kuali.kfs.fp.businessobject.CashieringItemInProcess;
029 import org.kuali.kfs.fp.businessobject.Check;
030 import org.kuali.kfs.fp.businessobject.CheckBase;
031 import org.kuali.kfs.fp.businessobject.CoinDetail;
032 import org.kuali.kfs.fp.businessobject.CurrencyDetail;
033 import org.kuali.kfs.fp.businessobject.Deposit;
034 import org.kuali.kfs.fp.businessobject.format.CashDrawerStatusCodeFormatter;
035 import org.kuali.kfs.fp.businessobject.format.CashReceiptDepositTypeFormatter;
036 import org.kuali.kfs.fp.document.CashManagementDocument;
037 import org.kuali.kfs.fp.document.CashReceiptDocument;
038 import org.kuali.kfs.fp.document.authorization.CashManagementDocumentPresentationController;
039 import org.kuali.kfs.fp.document.service.CashManagementService;
040 import org.kuali.kfs.fp.document.service.CashReceiptService;
041 import org.kuali.kfs.fp.service.CashDrawerService;
042 import org.kuali.kfs.sys.KFSConstants.DepositConstants;
043 import org.kuali.kfs.sys.KFSConstants.DocumentStatusCodes.CashReceipt;
044 import org.kuali.kfs.sys.context.SpringContext;
045 import org.kuali.kfs.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry;
046 import org.kuali.rice.kns.service.DataDictionaryService;
047 import org.kuali.rice.kns.service.DateTimeService;
048 import org.kuali.rice.kns.util.KualiDecimal;
049 import org.kuali.rice.kns.web.format.CurrencyFormatter;
050 import org.kuali.rice.kns.web.format.TimestampAMPMFormatter;
051 import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase;
052
053 /**
054 * This class is the action form for CashManagement
055 */
056 public class CashManagementForm extends KualiDocumentFormBase {
057 protected static final long serialVersionUID = 1L;
058 protected static Logger LOG = Logger.getLogger(CashManagementForm.class);
059
060 protected static final String CAMPUS_CODE_PROPERTY = "document.campusCode";
061
062 protected transient List depositHelpers;
063 protected CashDrawerSummary cashDrawerSummary;
064 protected List<CashieringItemInProcess> recentlyClosedItemsInProcess;
065 protected transient CashManagementDocumentPresentationController cmDocPrezController;
066
067 /**
068 * Constructs a CashManagementForm.
069 */
070 public CashManagementForm() {
071 super();
072
073 depositHelpers = new ArrayList();
074
075 setFormatterType("document.cashDrawerStatus", CashDrawerStatusCodeFormatter.class);
076 setFormatterType("document.deposit.depositTypeCode", CashReceiptDepositTypeFormatter.class);
077
078 setFormatterType("cashDrawerSummary.timeOpened", TimestampAMPMFormatter.class);
079 setFormatterType("cashDrawerSummary.timeRefreshed", TimestampAMPMFormatter.class);
080 setFormatterType("cashDrawerSummary.*Total", CurrencyFormatter.class);
081
082 setFormatterType("document.currentTransaction.transactionStarted", TimestampAMPMFormatter.class);
083 }
084
085 @Override
086 protected String getDefaultDocumentTypeName() {
087 return "CMD";
088 }
089
090 /**
091 * @return cashManagementDocument
092 */
093 public CashManagementDocument getCashManagementDocument() {
094 return (CashManagementDocument) getDocument();
095 }
096
097
098 /**
099 * Creates a DepositHelper foreach Deposit associated with this form's document
100 */
101 public void populateDepositHelpers() {
102 depositHelpers = new ArrayList();
103
104 List deposits = getCashManagementDocument().getDeposits();
105 for (Iterator i = deposits.iterator(); i.hasNext();) {
106 Deposit d = (Deposit) i.next();
107
108 DepositHelper dh = new DepositHelper(d);
109 depositHelpers.add(dh);
110 }
111 }
112
113 /**
114 * Creates and initializes a CashDrawerSummary for the related CashManagementDocument, if it is not currently closed
115 */
116 public void populateCashDrawerSummary() {
117 CashManagementDocument cmd = getCashManagementDocument();
118 if (cmd != null) {
119 CashDrawer cd = SpringContext.getBean(CashDrawerService.class).getByCampusCode(cmd.getCampusCode());
120 if (cd == null) {
121 throw new RuntimeException("No cash drawer exists for campus code "+cmd.getCampusCode()+"; please create on via the Cash Drawer Maintenance Document before attemping to create a CashManagementDocument for campus "+cmd.getCampusCode());
122 }
123 if (!cd.isClosed()) {
124 cashDrawerSummary = new CashDrawerSummary(cmd);
125 }
126 }
127 }
128
129 /**
130 * Tells any JSP page using this form whether an action can be taken to make the last interim deposit the final deposit
131 *
132 * @return true if last interim deposit could be the final deposit, false if otherwise
133 */
134 public boolean isLastInterimDepositFinalizable() {
135 boolean result = true;
136 CashManagementDocument cmDoc = getCashManagementDocument();
137 result &= !cmDoc.hasFinalDeposit();
138 result &= (cmDoc.getDeposits().size() > 0);
139 if (result) {
140 result &= SpringContext.getBean(CashManagementService.class).allVerifiedCashReceiptsAreDeposited(cmDoc);
141 }
142 return result;
143 }
144
145 /**
146 * @return CashDrawerSummary instance associated with this form, if any
147 */
148 public CashDrawerSummary getCashDrawerSummary() {
149 return cashDrawerSummary;
150 }
151
152 /**
153 * Sets the CashDrawerSummary
154 */
155 public void setCashDrawerSummary(CashDrawerSummary cashDrawerSummary) {
156 this.cashDrawerSummary = cashDrawerSummary;
157 }
158
159 /**
160 * @return List
161 */
162 public List getDepositHelpers() {
163 return depositHelpers;
164 }
165
166 /**
167 * Gets the recentlyClosedItemsInProcess attribute.
168 *
169 * @return Returns the recentlyClosedItemsInProcess.
170 */
171 public List<CashieringItemInProcess> getRecentlyClosedItemsInProcess() {
172 return recentlyClosedItemsInProcess;
173 }
174
175 /**
176 * Sets the recentlyClosedItemsInProcess attribute value.
177 *
178 * @param recentlyClosedItemsInProcess The recentlyClosedItemsInProcess to set.
179 */
180 public void setRecentlyClosedItemsInProcess(List<CashieringItemInProcess> recentlyClosedItemsInProcess) {
181 this.recentlyClosedItemsInProcess = recentlyClosedItemsInProcess;
182 }
183
184 /**
185 * @return true if the cash drawer can currently be opened, false otherwise
186 */
187 public boolean getAllowOpenCashDrawer() {
188 if (cmDocPrezController == null) {
189 cmDocPrezController = createCashManagementDocumentPresentationController();
190 }
191 return cmDocPrezController.canOpenCashDrawer(getDocument());
192 }
193
194 /**
195 * Creates an instance of the appropriate implementation of CashManagementDocumentPresentationController to check the cash drawer opening logic
196 * @return an instance of the CashManagementDocumentPresentationController for the document
197 */
198 protected CashManagementDocumentPresentationController createCashManagementDocumentPresentationController() {
199 final DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
200 final FinancialSystemTransactionalDocumentEntry cmDocEntry = (FinancialSystemTransactionalDocumentEntry)dataDictionaryService.getDataDictionary().getDocumentEntry(dataDictionaryService.getDocumentTypeNameByClass(getDocument().getClass()));
201
202 final CashManagementDocumentPresentationController cmDocPrezController;
203 try {
204 cmDocPrezController = (CashManagementDocumentPresentationController)cmDocEntry.getDocumentPresentationControllerClass().newInstance();
205 }
206 catch (InstantiationException ie) {
207 throw new RuntimeException("Cannot instantiate instance of document presentation controller with class "+cmDocEntry.getDocumentPresentationControllerClass().getName(), ie);
208 }
209 catch (IllegalAccessException iae) {
210 throw new RuntimeException("Illegal access occurred while instantiating instance of maintainable implementation "+cmDocEntry.getDocumentPresentationControllerClass().getName(), iae);
211 }
212 return cmDocPrezController;
213 }
214
215 /**
216 * @param i
217 * @return DepositHelper
218 */
219 public DepositHelper getDepositHelper(int i) {
220 while (depositHelpers.size() <= i) {
221 depositHelpers.add(new DepositHelper());
222 }
223 DepositHelper dh = (DepositHelper) depositHelpers.get(i);
224
225 return dh;
226 }
227
228 /**
229 * Removes and returns DepositHelper at the given index
230 *
231 * @param i
232 * @return
233 */
234 public DepositHelper removeDepositHelper(int i) {
235 return (DepositHelper) depositHelpers.remove(i);
236 }
237
238 /**
239 * Inner helper class.
240 */
241 public static final class DepositHelper {
242 protected Integer depositLineNumber;
243 protected List<CashReceiptSummary> cashReceiptSummarys;
244 protected List<Check> cashieringChecks;
245
246 /**
247 * Constructs a DepositHelper - default constructor used by PojoProcessor.
248 */
249 public DepositHelper() {
250 cashReceiptSummarys = new ArrayList<CashReceiptSummary>();
251 cashieringChecks = new ArrayList<Check>();
252 depositLineNumber = new Integer(1);
253 }
254
255 /**
256 * Constructs a DepositHelper
257 *
258 * @param deposit
259 */
260 public DepositHelper(Deposit deposit) {
261 depositLineNumber = deposit.getFinancialDocumentDepositLineNumber();
262
263 cashReceiptSummarys = new ArrayList<CashReceiptSummary>();
264
265 CashManagementService cmService = SpringContext.getBean(CashManagementService.class);
266 List<CashReceiptDocument> cashReceipts = cmService.retrieveCashReceipts(deposit);
267 for (CashReceiptDocument document : cashReceipts) {
268 cashReceiptSummarys.add(new CashReceiptSummary(document));
269 }
270
271 cashieringChecks = cmService.selectCashieringChecksForDeposit(deposit.getDocumentNumber(), depositLineNumber);
272 }
273
274 /**
275 * @return List
276 */
277 public List<CashReceiptSummary> getCashReceiptSummarys() {
278 return cashReceiptSummarys;
279 }
280
281 /**
282 * @param i
283 * @return CashReceiptSummary
284 */
285 public CashReceiptSummary getCashReceiptSummary(int index) {
286 extendCashReceiptSummarys(index + 1);
287
288 return cashReceiptSummarys.get(index);
289 }
290
291 /**
292 * Ensures that there are at least minSize entries in the cashReceiptSummarys list
293 *
294 * @param minSize
295 */
296 protected void extendCashReceiptSummarys(int minSize) {
297 while (cashReceiptSummarys.size() < minSize) {
298 cashReceiptSummarys.add(new CashReceiptSummary());
299 }
300 }
301
302 /**
303 * Gets the cashieringChecks attribute.
304 *
305 * @return Returns the cashieringChecks.
306 */
307 public List<Check> getCashieringChecks() {
308 return cashieringChecks;
309 }
310
311 /**
312 * Get a specific cashiering check in the list of cashiering checks
313 *
314 * @param index the index of the check to retrieve
315 * @return a check
316 */
317 public Check getCashieringCheck(int index) {
318 extendCashieringChecks(index);
319 return cashieringChecks.get(index);
320 }
321
322 /**
323 * This method makes the cashiering checks list longer, to avoid Array Index out of bounds issues
324 *
325 * @param minSize the minimum size to make the list
326 */
327 protected void extendCashieringChecks(int minSize) {
328 while (cashieringChecks.size() <= minSize) {
329 cashieringChecks.add(new CheckBase());
330 }
331 }
332
333 /**
334 * @return Integer
335 */
336 public Integer getDepositLineNumber() {
337 return depositLineNumber;
338 }
339
340 /**
341 * @see java.lang.Object#toString()
342 */
343 @Override
344 public String toString() {
345 return "deposit #" + depositLineNumber;
346 }
347 }
348
349 public static final class CashReceiptSummary {
350 protected String documentNumber;
351 protected String description;
352 protected Timestamp createDate;
353 protected KualiDecimal totalAmount;
354 protected KualiDecimal checkAmount;
355
356 /**
357 * Default constructor used by PojoProcessor.
358 */
359 public CashReceiptSummary() {
360 }
361
362 /**
363 * Constructs a CashReceiptSummary from the given CashReceiptDocument.
364 *
365 * @param crd
366 */
367 public CashReceiptSummary(CashReceiptDocument crd) {
368 documentNumber = crd.getDocumentNumber();
369 description = crd.getDocumentHeader().getDocumentDescription();
370 createDate = crd.getDocumentHeader().getWorkflowDocument().getCreateDate();
371 checkAmount = crd.getTotalCheckAmount();
372 totalAmount = crd.getTotalDollarAmount();
373 }
374
375 /**
376 * @return current value of createDate.
377 */
378 public Timestamp getCreateDate() {
379 return createDate;
380 }
381
382 /**
383 * Sets the createDate attribute value.
384 *
385 * @param createDate The createDate to set.
386 */
387 public void setCreateDate(Timestamp createDate) {
388 this.createDate = createDate;
389 }
390
391 /**
392 * @return current value of description.
393 */
394 public String getDescription() {
395 return description;
396 }
397
398 /**
399 * Sets the description attribute value.
400 *
401 * @param description The description to set.
402 */
403 public void setDescription(String description) {
404 this.description = description;
405 }
406
407 /**
408 * @return current value of documentNumber.
409 */
410 public String getDocumentNumber() {
411 return documentNumber;
412 }
413
414 /**
415 * Sets the documentNumber attribute value.
416 *
417 * @param docNumber The documentNumber to set.
418 */
419 public void setDocumentNumber(String documentNumber) {
420 this.documentNumber = documentNumber;
421 }
422
423 /**
424 * @return current value of totalAmount.
425 */
426 public KualiDecimal getTotalAmount() {
427 return totalAmount;
428 }
429
430 /**
431 * Sets the totalAmount attribute value.
432 *
433 * @param totalAmount The totalAmount to set.
434 */
435 public void setTotalAmount(KualiDecimal totalAmount) {
436 this.totalAmount = totalAmount;
437 }
438
439 /**
440 * Returns the total check amount for this CR
441 *
442 * @return a total of checks
443 */
444 public KualiDecimal getCheckAmount() {
445 return this.checkAmount;
446 }
447
448 /**
449 * Sets the checkAmount attribute value.
450 */
451 public void setCheckAmount(KualiDecimal checkAmount) {
452 this.checkAmount = checkAmount;
453 }
454
455 /**
456 * @see java.lang.Object#toString()
457 */
458 @Override
459 public String toString() {
460 return "CRSummary " + getDocumentNumber();
461 }
462 }
463
464 public static final class CashDrawerSummary implements Serializable {
465 protected Timestamp timeOpened;
466 protected Timestamp timeRefreshed;
467
468 // directly calculated
469 protected int overallReceiptCount;
470 protected int depositedReceiptCount;
471
472 protected CashReceiptStatistics verifiedReceiptStats = new CashReceiptStatistics();
473 protected CashReceiptStatistics interimReceiptStats = new CashReceiptStatistics();
474 protected CashReceiptStatistics finalReceiptStats = new CashReceiptStatistics();
475 protected CashReceiptStatistics overallReceiptStats = new CashReceiptStatistics();
476
477 // derived
478 protected KualiDecimal verifiedReceiptSumTotal;
479 protected KualiDecimal interimReceiptSumTotal;
480 protected KualiDecimal finalReceiptSumTotal;
481 protected KualiDecimal overallReceiptSumTotal;
482
483 protected KualiDecimal remainingCheckTotal;
484 protected KualiDecimal remainingCurrencyTotal;
485 protected KualiDecimal remainingCoinTotal;
486 protected KualiDecimal remainingSumTotal;
487
488 protected boolean isDepositsFinal = false;
489 protected KualiDecimal cashieringChecksTotal;
490 protected KualiDecimal depositedCashieringChecksTotal;
491 protected KualiDecimal undepositedCashieringChecksTotal;
492 protected KualiDecimal cashDrawerCurrencyTotal;
493 protected KualiDecimal cashDrawerCoinTotal;
494 protected KualiDecimal openItemsTotal;
495 protected KualiDecimal cashDrawerTotal;
496 protected KualiDecimal interimDepositedCashieringChecksTotal;
497 protected KualiDecimal finalDepositedCashieringChecksTotal;
498
499 public CashDrawerSummary(CashManagementDocument cmDoc) {
500 timeOpened = cmDoc.getDocumentHeader().getWorkflowDocument().getCreateDate();
501
502 resummarize(cmDoc);
503 }
504
505 public CashDrawerSummary() {
506 }
507
508
509 protected static final String[] INTERESTING_STATII = { CashReceipt.VERIFIED, CashReceipt.INTERIM, CashReceipt.FINAL };
510
511 public void resummarize(CashManagementDocument cmDoc) {
512 //
513 // get all interesting CRs
514 String campusCode = cmDoc.getCampusCode();
515 List<CashReceiptDocument> interestingReceipts = SpringContext.getBean(CashReceiptService.class).getCashReceipts(campusCode, INTERESTING_STATII);
516
517
518 //
519 // rather than separating into lists by status, gather statistics in one fell swoop
520 overallReceiptStats.clear();
521 verifiedReceiptStats.clear();
522 interimReceiptStats.clear();
523 finalReceiptStats.clear();
524
525 for (CashReceiptDocument receipt : interestingReceipts) {
526 String status = receipt.getDocumentHeader().getFinancialDocumentStatusCode();
527 overallReceiptStats.add(receipt);
528 if (status.equals(CashReceipt.VERIFIED)) {
529 verifiedReceiptStats.add(receipt);
530 }
531 else if (status.equals(CashReceipt.INTERIM)) {
532 interimReceiptStats.add(receipt);
533 }
534 else if (status.equals(CashReceipt.FINAL)) {
535 finalReceiptStats.add(receipt);
536 }
537 else {
538 throw new IllegalStateException("invalid (unknown) financialDocumentStatusCode '" + status + "'");
539 }
540 }
541
542 overallReceiptCount = overallReceiptStats.getReceiptCount();
543 depositedReceiptCount = interimReceiptStats.getReceiptCount() + finalReceiptStats.getReceiptCount();
544
545 // get cash drawer summary info
546 depositedCashieringChecksTotal = calculateDepositedCashieringChecksTotal(cmDoc);
547 undepositedCashieringChecksTotal = calculateUndepositedCashieringChecksTotal(cmDoc);
548 cashieringChecksTotal = depositedCashieringChecksTotal.add(undepositedCashieringChecksTotal);
549 openItemsTotal = calculateOpenItemsTotal(cmDoc);
550 cashDrawerCurrencyTotal = cmDoc.getCashDrawer().getCurrencyTotalAmount();
551 cashDrawerCoinTotal = cmDoc.getCashDrawer().getCoinTotalAmount();
552 cashDrawerTotal = undepositedCashieringChecksTotal.add(openItemsTotal.add(cashDrawerCurrencyTotal.add(cashDrawerCoinTotal)));
553 Map<String, KualiDecimal> results = calculateDepositedCashieringChecksTotalByDepositType(cmDoc);
554 interimDepositedCashieringChecksTotal = results.get(DepositConstants.DEPOSIT_TYPE_INTERIM);
555 KualiDecimal finalDepositCashTotal = KualiDecimal.ZERO;
556 Map<Class, Object> finalDepositCashDetails = SpringContext.getBean(CashManagementService.class).getCashDetailsForFinalDeposit(cmDoc.getDocumentNumber());
557 KualiDecimal currencyDepositAmount = KualiDecimal.ZERO;
558 if (finalDepositCashDetails.get(CurrencyDetail.class) != null) {
559 currencyDepositAmount = ((CurrencyDetail) finalDepositCashDetails.get(CurrencyDetail.class)).getTotalAmount();
560 }
561 KualiDecimal coinDepositAmount = KualiDecimal.ZERO;
562 if (finalDepositCashDetails.get(CoinDetail.class) != null) {
563 coinDepositAmount = ((CoinDetail) finalDepositCashDetails.get(CoinDetail.class)).getTotalAmount();
564 }
565 finalDepositCashTotal = finalDepositCashTotal.add(currencyDepositAmount).add(coinDepositAmount);
566 finalDepositedCashieringChecksTotal = results.get(DepositConstants.DEPOSIT_TYPE_FINAL).add(finalDepositCashTotal);
567
568
569 verifiedReceiptSumTotal = verifiedReceiptStats.getSumTotal();
570 interimReceiptSumTotal = interimReceiptStats.getCheckTotal().add(interimDepositedCashieringChecksTotal);
571 finalReceiptSumTotal = finalReceiptStats.getCheckTotal().add(finalDepositedCashieringChecksTotal);
572 overallReceiptSumTotal = overallReceiptStats.getSumTotal();
573
574 remainingCheckTotal = overallReceiptStats.getCheckTotal().subtract(interimReceiptStats.getCheckTotal()).subtract(finalReceiptStats.getCheckTotal());
575 remainingCurrencyTotal = overallReceiptStats.getCurrencyTotal().subtract(currencyDepositAmount).subtract(depositedCashieringChecksTotal);
576 remainingCoinTotal = overallReceiptStats.getCoinTotal().subtract(coinDepositAmount);
577 remainingSumTotal = remainingCheckTotal.add(remainingCurrencyTotal.add(remainingCoinTotal));
578
579 isDepositsFinal = cmDoc.hasFinalDeposit();
580
581 timeRefreshed = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp();
582 }
583
584 protected KualiDecimal calculateDepositedCashieringChecksTotal(CashManagementDocument cmDoc) {
585 return SpringContext.getBean(CashManagementService.class).calculateDepositedCheckTotal(cmDoc.getDocumentNumber());
586 }
587
588 protected KualiDecimal calculateUndepositedCashieringChecksTotal(CashManagementDocument cmDoc) {
589 return SpringContext.getBean(CashManagementService.class).calculateUndepositedCheckTotal(cmDoc.getDocumentNumber());
590 }
591
592 protected KualiDecimal calculateOpenItemsTotal(CashManagementDocument cmDoc) {
593 KualiDecimal total = KualiDecimal.ZERO;
594 for (CashieringItemInProcess itemInProcess : SpringContext.getBean(CashManagementService.class).getOpenItemsInProcess(cmDoc)) {
595 if (itemInProcess.getItemRemainingAmount() != null) {
596 total = total.add(itemInProcess.getItemRemainingAmount());
597 }
598 }
599 return total;
600 }
601
602 protected Map<String, KualiDecimal> calculateDepositedCashieringChecksTotalByDepositType(CashManagementDocument cmDoc) {
603 Map<String, KualiDecimal> result = new HashMap<String, KualiDecimal>();
604 result.put(DepositConstants.DEPOSIT_TYPE_INTERIM, KualiDecimal.ZERO);
605 result.put(DepositConstants.DEPOSIT_TYPE_FINAL, KualiDecimal.ZERO);
606 // 1. get all deposited cashiering checks
607 List<Check> checks = SpringContext.getBean(CashManagementService.class).selectDepositedCashieringChecks(cmDoc.getDocumentNumber());
608 // 2. get all deposits
609 List<Deposit> deposits = cmDoc.getDeposits();
610 Map<Integer, String> depositTypes = new HashMap<Integer, String>();
611 for (Deposit deposit : deposits) {
612 depositTypes.put(deposit.getFinancialDocumentDepositLineNumber(), deposit.getDepositTypeCode());
613 }
614 // 3. now, go through all cashiering checks, totalling them to the right deposit type
615 for (Check check : checks) {
616 KualiDecimal properTotal = result.get(depositTypes.get(check.getFinancialDocumentDepositLineNumber()));
617 properTotal = properTotal.add(check.getAmount());
618 result.put(depositTypes.get(check.getFinancialDocumentDepositLineNumber()), properTotal);
619 }
620 return result;
621 }
622
623 /**
624 * @return current value of depositedReceiptCount.
625 */
626 public int getDepositedReceiptCount() {
627 return depositedReceiptCount;
628 }
629
630 /**
631 * Sets the depositedReceiptCount attribute value.
632 *
633 * @param depositedReceiptCount The depositedReceiptCount to set.
634 */
635 public void setDepositedReceiptCount(int depositedReceiptCount) {
636 this.depositedReceiptCount = depositedReceiptCount;
637 }
638
639
640 /**
641 * @return current value of finalReceiptSumTotal.
642 */
643 public KualiDecimal getFinalReceiptSumTotal() {
644 return finalReceiptSumTotal;
645 }
646
647 /**
648 * Sets the finalReceiptSumTotal attribute value.
649 *
650 * @param finalReceiptSumTotal The finalReceiptSumTotal to set.
651 */
652 public void setFinalReceiptSumTotal(KualiDecimal finalSumTotal) {
653 this.finalReceiptSumTotal = finalSumTotal;
654 }
655
656
657 /**
658 * @return current value of interimReceiptSumTotal.
659 */
660 public KualiDecimal getInterimReceiptSumTotal() {
661 return interimReceiptSumTotal;
662 }
663
664 /**
665 * Sets the interimReceiptSumTotal attribute value.
666 *
667 * @param interimReceiptSumTotal The interimReceiptSumTotal to set.
668 */
669 public void setInterimReceiptSumTotal(KualiDecimal interimSumTotal) {
670 this.interimReceiptSumTotal = interimSumTotal;
671 }
672
673
674 /**
675 * @return current value of overallReceiptCount.
676 */
677 public int getOverallReceiptCount() {
678 return overallReceiptCount;
679 }
680
681 /**
682 * Sets the overallReceiptCount attribute value.
683 *
684 * @param overallReceiptCount The overallReceiptCount to set.
685 */
686 public void setOverallReceiptCount(int overallReceiptCount) {
687 this.overallReceiptCount = overallReceiptCount;
688 }
689
690
691 /**
692 * @return current value of remainingCheckTotal.
693 */
694 public KualiDecimal getRemainingCheckTotal() {
695 return remainingCheckTotal;
696 }
697
698 /**
699 * Sets the remainingCheckTotal attribute value.
700 *
701 * @param remainingCheckTotal The remainingCheckTotal to set.
702 */
703 public void setRemainingCheckTotal(KualiDecimal remainingCheckTotal) {
704 this.remainingCheckTotal = remainingCheckTotal;
705 }
706
707
708 /**
709 * @return current value of remainingCoinTotal.
710 */
711 public KualiDecimal getRemainingCoinTotal() {
712 return remainingCoinTotal;
713 }
714
715 /**
716 * Sets the remainingCoinTotal attribute value.
717 *
718 * @param remainingCoinTotal The remainingCoinTotal to set.
719 */
720 public void setRemainingCoinTotal(KualiDecimal remainingCoinTotal) {
721 this.remainingCoinTotal = remainingCoinTotal;
722 }
723
724 /**
725 * @return current value of remainingCurrencyTotal.
726 */
727 public KualiDecimal getRemainingCurrencyTotal() {
728 return remainingCurrencyTotal;
729 }
730
731 /**
732 * Sets the remainingCurrencyTotal attribute value.
733 *
734 * @param remainingCurrencyTotal The remainingCurrencyTotal to set.
735 */
736 public void setRemainingCurrencyTotal(KualiDecimal remainingCurrencyTotal) {
737 this.remainingCurrencyTotal = remainingCurrencyTotal;
738 }
739
740
741 /**
742 * @return current value of remainingSumTotal.
743 */
744 public KualiDecimal getRemainingSumTotal() {
745 return remainingSumTotal;
746 }
747
748 /**
749 * Sets the remainingSumTotal attribute value.
750 *
751 * @param remainingSumTotal The remainingSumTotal to set.
752 */
753 public void setRemainingSumTotal(KualiDecimal remainingSumTotal) {
754 this.remainingSumTotal = remainingSumTotal;
755 }
756
757
758 /**
759 * @return current value of timeOpened.
760 */
761 public Timestamp getTimeOpened() {
762 return timeOpened;
763 }
764
765 /**
766 * Sets the timeOpened attribute value.
767 *
768 * @param timeOpened The timeOpened to set.
769 */
770 public void setTimeOpened(Timestamp timeOpened) {
771 this.timeOpened = timeOpened;
772 }
773
774
775 /**
776 * @return current value of timeRefreshed.
777 */
778 public Timestamp getTimeRefreshed() {
779 return timeRefreshed;
780 }
781
782 /**
783 * Sets the timeRefreshed attribute value.
784 *
785 * @param timeRefreshed The timeRefreshed to set.
786 */
787 public void setTimeRefreshed(Timestamp timeRefreshed) {
788 this.timeRefreshed = timeRefreshed;
789 }
790
791
792 /**
793 * @return current value of verifiedReceiptSumTotal.
794 */
795 public KualiDecimal getVerifiedReceiptSumTotal() {
796 return verifiedReceiptSumTotal;
797 }
798
799 /**
800 * Sets the verifiedReceiptSumTotal attribute value.
801 *
802 * @param verifiedReceiptSumTotal The verifiedReceiptSumTotal to set.
803 */
804 public void setVerifiedReceiptSumTotal(KualiDecimal verifiedSumTotal) {
805 this.verifiedReceiptSumTotal = verifiedSumTotal;
806 }
807
808
809 /**
810 * @return current value of overallReceiptSumTotal.
811 */
812 public KualiDecimal getOverallReceiptSumTotal() {
813 return overallReceiptSumTotal;
814 }
815
816 /**
817 * Sets the overallReceiptSumTotal attribute value.
818 *
819 * @param overallReceiptSumTotal The overallReceiptSumTotal to set.
820 */
821 public void setOverallReceiptSumTotal(KualiDecimal overallSumTotal) {
822 this.overallReceiptSumTotal = overallSumTotal;
823 }
824
825
826 /**
827 * @return current value of finalReceiptStats.
828 */
829 public CashReceiptStatistics getFinalReceiptStats() {
830 return finalReceiptStats;
831 }
832
833 /**
834 * @return current value of interimReceiptStats.
835 */
836 public CashReceiptStatistics getInterimReceiptStats() {
837 return interimReceiptStats;
838 }
839
840 /**
841 * @return current value of verifiedReceiptStats.
842 */
843 public CashReceiptStatistics getVerifiedReceiptStats() {
844 return verifiedReceiptStats;
845 }
846
847 /**
848 * Gets the cashDrawerCoinTotal attribute.
849 *
850 * @return Returns the cashDrawerCoinTotal.
851 */
852 public KualiDecimal getCashDrawerCoinTotal() {
853 return cashDrawerCoinTotal;
854 }
855
856 /**
857 * Gets the cashDrawerCurrencyTotal attribute.
858 *
859 * @return Returns the cashDrawerCurrencyTotal.
860 */
861 public KualiDecimal getCashDrawerCurrencyTotal() {
862 return cashDrawerCurrencyTotal;
863 }
864
865 /**
866 * Gets the cashDrawerTotal attribute.
867 *
868 * @return Returns the cashDrawerTotal.
869 */
870 public KualiDecimal getCashDrawerTotal() {
871 return cashDrawerTotal;
872 }
873
874 /**
875 * Gets the cashieringChecksTotal attribute.
876 *
877 * @return Returns the cashieringChecksTotal.
878 */
879 public KualiDecimal getCashieringChecksTotal() {
880 return cashieringChecksTotal;
881 }
882
883 /**
884 * Sets the cashieringChecksTotal attribute value.
885 *
886 * @param cashieringChecksTotal The cashieringChecksTotal to set.
887 */
888 public void setCashieringChecksTotal(KualiDecimal cashieringChecksTotal) {
889 this.cashieringChecksTotal = cashieringChecksTotal;
890 }
891
892 /**
893 * Sets the depositedCashieringChecksTotal attribute value.
894 *
895 * @param depositedCashieringChecksTotal The depositedCashieringChecksTotal to set.
896 */
897 public void setDepositedCashieringChecksTotal(KualiDecimal depositedCashieringChecksTotal) {
898 this.depositedCashieringChecksTotal = depositedCashieringChecksTotal;
899 }
900
901 /**
902 * Gets the isDepositsFinal attribute.
903 *
904 * @return Returns the isDepositsFinal.
905 */
906 public boolean isDepositsFinal() {
907 return isDepositsFinal;
908 }
909
910 /**
911 * Sets the cashDrawerCoinTotal attribute value.
912 *
913 * @param cashDrawerCoinTotal The cashDrawerCoinTotal to set.
914 */
915 public void setCashDrawerCoinTotal(KualiDecimal cashDrawerCoinTotal) {
916 this.cashDrawerCoinTotal = cashDrawerCoinTotal;
917 }
918
919 /**
920 * Sets the cashDrawerCurrencyTotal attribute value.
921 *
922 * @param cashDrawerCurrencyTotal The cashDrawerCurrencyTotal to set.
923 */
924 public void setCashDrawerCurrencyTotal(KualiDecimal cashDrawerCurrencyTotal) {
925 this.cashDrawerCurrencyTotal = cashDrawerCurrencyTotal;
926 }
927
928 /**
929 * Sets the cashDrawerTotal attribute value.
930 *
931 * @param cashDrawerTotal The cashDrawerTotal to set.
932 */
933 public void setCashDrawerTotal(KualiDecimal cashDrawerTotal) {
934 this.cashDrawerTotal = cashDrawerTotal;
935 }
936
937 /**
938 * Sets the openItemsTotal attribute value.
939 *
940 * @param openItemsTotal The openItemsTotal to set.
941 */
942 public void setOpenItemsTotal(KualiDecimal openItemsTotal) {
943 this.openItemsTotal = openItemsTotal;
944 }
945
946 /**
947 * Sets the undepositedCashieringChecksTotal attribute value.
948 *
949 * @param undepositedCashieringChecksTotal The undepositedCashieringChecksTotal to set.
950 */
951 public void setUndepositedCashieringChecksTotal(KualiDecimal undepositedCashieringChecksTotal) {
952 this.undepositedCashieringChecksTotal = undepositedCashieringChecksTotal;
953 }
954
955 /**
956 * Gets the openItemsTotal attribute.
957 *
958 * @return Returns the openItemsTotal.
959 */
960 public KualiDecimal getOpenItemsTotal() {
961 return openItemsTotal;
962 }
963
964 /**
965 * Gets the depositedCashieringChecksTotal attribute.
966 *
967 * @return Returns the depositedCashieringChecksTotal.
968 */
969 public KualiDecimal getDepositedCashieringChecksTotal() {
970 return depositedCashieringChecksTotal;
971 }
972
973 /**
974 * Gets the undepositedCashieringChecksTotal attribute.
975 *
976 * @return Returns the undepositedCashieringChecksTotal.
977 */
978 public KualiDecimal getUndepositedCashieringChecksTotal() {
979 return undepositedCashieringChecksTotal;
980 }
981
982 /**
983 * @return current value of overalllStats.
984 */
985 public CashReceiptStatistics getOverallReceiptStats() {
986 return overallReceiptStats;
987 }
988
989 public static final class CashReceiptStatistics implements Serializable{
990 protected int receiptCount;
991 protected KualiDecimal checkTotal;
992 protected KualiDecimal currencyTotal;
993 protected KualiDecimal coinTotal;
994
995 /**
996 * Constructs a SubSummary.
997 */
998 public CashReceiptStatistics() {
999 clear();
1000 }
1001
1002 /**
1003 * Increments the counter by 1, and the various totals by the amounts in the given CashReceiptDocument
1004 *
1005 * @param receipt
1006 */
1007 public void add(CashReceiptDocument receipt) {
1008 receipt.refreshCashDetails();
1009 receiptCount++;
1010 checkTotal = checkTotal.add(receipt.getTotalCheckAmount());
1011 currencyTotal = currencyTotal.add(receipt.getTotalCashAmount());
1012 coinTotal = coinTotal.add(receipt.getTotalCoinAmount());
1013 }
1014
1015 /**
1016 * Zeros counter and totals.
1017 */
1018 public void clear() {
1019 receiptCount = 0;
1020 checkTotal = KualiDecimal.ZERO;
1021 currencyTotal = KualiDecimal.ZERO;
1022 coinTotal = KualiDecimal.ZERO;
1023 }
1024
1025
1026 /**
1027 * Returns total of all check, coin, and currency totals
1028 */
1029 public KualiDecimal getSumTotal() {
1030 KualiDecimal sumTotal = getCheckTotal().add(getCoinTotal().add(getCurrencyTotal()));
1031
1032 return sumTotal;
1033 }
1034
1035 /**
1036 * This method doesn't do anything but appease the demands of POJO form population...I mean...er...this sets the sum
1037 * total, now doesn't it?
1038 *
1039 * @param total total you want this method to ignore
1040 */
1041 public void setSumTotal(KualiDecimal total) {
1042 // don't do anything. just be very quiet and maybe the POJO loader will be satisfied
1043 }
1044
1045
1046 /**
1047 * @return current value of checkTotal.
1048 */
1049 public KualiDecimal getCheckTotal() {
1050 return checkTotal;
1051 }
1052
1053 /**
1054 * Sets the checkTotal attribute value.
1055 *
1056 * @param checkTotal The checkTotal to set.
1057 */
1058 public void setCheckTotal(KualiDecimal checkTotal) {
1059 this.checkTotal = checkTotal;
1060 }
1061
1062
1063 /**
1064 * @return current value of coinTotal.
1065 */
1066 public KualiDecimal getCoinTotal() {
1067 return coinTotal;
1068 }
1069
1070 /**
1071 * Sets the coinTotal attribute value.
1072 *
1073 * @param coinTotal The coinTotal to set.
1074 */
1075 public void setCoinTotal(KualiDecimal coinTotal) {
1076 this.coinTotal = coinTotal;
1077 }
1078
1079
1080 /**
1081 * @return current value of currencyTotal.
1082 */
1083 public KualiDecimal getCurrencyTotal() {
1084 return currencyTotal;
1085 }
1086
1087 /**
1088 * Sets the currencyTotal attribute value.
1089 *
1090 * @param currencyTotal The currencyTotal to set.
1091 */
1092 public void setCurrencyTotal(KualiDecimal currencyTotal) {
1093 this.currencyTotal = currencyTotal;
1094 }
1095
1096
1097 /**
1098 * @return current value of receiptCount.
1099 */
1100 public int getReceiptCount() {
1101 return receiptCount;
1102 }
1103
1104 /**
1105 * Sets the receiptCount attribute value.
1106 *
1107 * @param receiptCount The receiptCount to set.
1108 */
1109 public void setReceiptCount(int receiptCount) {
1110 this.receiptCount = receiptCount;
1111 }
1112
1113
1114 /**
1115 * @see java.lang.Object#toString()
1116 */
1117 @Override
1118 public String toString() {
1119 return "CashDrawerSummary(" + getSumTotal() + " = " + getCheckTotal() + " + " + getCurrencyTotal() + " + " + getCoinTotal() + ")";
1120 }
1121 }
1122 }
1123
1124 /**
1125 * @see org.kuali.rice.kns.web.struts.pojo.PojoFormBase#postprocessRequestParameters(java.util.Map)
1126 */
1127 @Override
1128 public void postprocessRequestParameters(Map requestParameters) {
1129 super.postprocessRequestParameters(requestParameters);
1130 // fish the campus code name out of the parameters
1131 String[] campusCodes = (String[]) requestParameters.get(CashManagementForm.CAMPUS_CODE_PROPERTY);
1132 String campusCode = null;
1133 if (campusCodes != null && campusCodes.length > 0) {
1134 campusCode = campusCodes[0];
1135 }
1136 if (campusCode != null && getCashManagementDocument() != null) {
1137 // use that to put the cash drawer back into the cash management document
1138 getCashManagementDocument().setCashDrawer(SpringContext.getBean(CashDrawerService.class).getByCampusCode(campusCode));
1139 }
1140 }
1141
1142
1143 }