Source Code Cross Referenced for CashManagementForm.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » web » struts » form » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.financial.web.struts.form 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2006-2007 The Kuali Foundation.
0003:         * 
0004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
0005:         * you may not use this file except in compliance with the License.
0006:         * You may obtain a copy of the License at
0007:         * 
0008:         * http://www.opensource.org/licenses/ecl1.php
0009:         * 
0010:         * Unless required by applicable law or agreed to in writing, software
0011:         * distributed under the License is distributed on an "AS IS" BASIS,
0012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013:         * See the License for the specific language governing permissions and
0014:         * limitations under the License.
0015:         */
0016:        package org.kuali.module.financial.web.struts.form;
0017:
0018:        import java.sql.Timestamp;
0019:        import java.util.ArrayList;
0020:        import java.util.HashMap;
0021:        import java.util.Iterator;
0022:        import java.util.List;
0023:        import java.util.Map;
0024:
0025:        import org.apache.log4j.Logger;
0026:        import org.kuali.core.service.DateTimeService;
0027:        import org.kuali.core.util.KualiDecimal;
0028:        import org.kuali.core.web.format.CurrencyFormatter;
0029:        import org.kuali.core.web.format.TimestampAMPMFormatter;
0030:        import org.kuali.core.web.struts.form.KualiDocumentFormBase;
0031:        import org.kuali.kfs.KFSConstants.DepositConstants;
0032:        import org.kuali.kfs.KFSConstants.DocumentStatusCodes.CashReceipt;
0033:        import org.kuali.kfs.context.SpringContext;
0034:        import org.kuali.module.financial.bo.CashDrawer;
0035:        import org.kuali.module.financial.bo.CashieringItemInProcess;
0036:        import org.kuali.module.financial.bo.Check;
0037:        import org.kuali.module.financial.bo.CheckBase;
0038:        import org.kuali.module.financial.bo.CoinDetail;
0039:        import org.kuali.module.financial.bo.CurrencyDetail;
0040:        import org.kuali.module.financial.bo.Deposit;
0041:        import org.kuali.module.financial.document.CashManagementDocument;
0042:        import org.kuali.module.financial.document.CashReceiptDocument;
0043:        import org.kuali.module.financial.service.CashDrawerService;
0044:        import org.kuali.module.financial.service.CashManagementService;
0045:        import org.kuali.module.financial.service.CashReceiptService;
0046:
0047:        /**
0048:         * This class is the action form for CashManagement
0049:         */
0050:        public class CashManagementForm extends KualiDocumentFormBase {
0051:            private static final long serialVersionUID = 1L;
0052:            private static Logger LOG = Logger
0053:                    .getLogger(CashManagementForm.class);
0054:
0055:            private static final String WORKGROUP_NAME_PROPERTY = "document.workgroupName";
0056:
0057:            private List depositHelpers;
0058:            private CashDrawerSummary cashDrawerSummary;
0059:            private List<CashieringItemInProcess> recentlyClosedItemsInProcess;
0060:
0061:            /**
0062:             * Constructs a CashManagementForm.
0063:             */
0064:            public CashManagementForm() {
0065:                super ();
0066:
0067:                setDocument(new CashManagementDocument());
0068:                depositHelpers = new ArrayList();
0069:
0070:                setFormatterType("document.cashDrawerStatus",
0071:                        CashDrawerStatusCodeFormatter.class);
0072:                setFormatterType("document.deposit.depositTypeCode",
0073:                        CashReceiptDepositTypeFormatter.class);
0074:
0075:                setFormatterType("cashDrawerSummary.timeOpened",
0076:                        TimestampAMPMFormatter.class);
0077:                setFormatterType("cashDrawerSummary.timeRefreshed",
0078:                        TimestampAMPMFormatter.class);
0079:                setFormatterType("cashDrawerSummary.*Total",
0080:                        CurrencyFormatter.class);
0081:
0082:                setFormatterType(
0083:                        "document.currentTransaction.transactionStarted",
0084:                        TimestampAMPMFormatter.class);
0085:            }
0086:
0087:            /**
0088:             * @return cashManagementDocument
0089:             */
0090:            public CashManagementDocument getCashManagementDocument() {
0091:                return (CashManagementDocument) getDocument();
0092:            }
0093:
0094:            /**
0095:             * Creates a DepositHelper foreach Deposit associated with this form's document
0096:             */
0097:            public void populateDepositHelpers() {
0098:                depositHelpers.clear();
0099:
0100:                List deposits = getCashManagementDocument().getDeposits();
0101:                for (Iterator i = deposits.iterator(); i.hasNext();) {
0102:                    Deposit d = (Deposit) i.next();
0103:
0104:                    DepositHelper dh = new DepositHelper(d);
0105:                    depositHelpers.add(dh);
0106:                }
0107:            }
0108:
0109:            /**
0110:             * Creates and initializes a CashDrawerSummary for the related CashManagementDocument, if it is not currently closed
0111:             */
0112:            public void populateCashDrawerSummary() {
0113:                CashManagementDocument cmd = getCashManagementDocument();
0114:                if (cmd != null) {
0115:                    CashDrawer cd = SpringContext.getBean(
0116:                            CashDrawerService.class).getByWorkgroupName(
0117:                            cmd.getWorkgroupName(), true);
0118:                    if (!cd.isClosed()) {
0119:                        cashDrawerSummary = new CashDrawerSummary(cmd);
0120:                    }
0121:                }
0122:            }
0123:
0124:            /**
0125:             * Tells any JSP page using this form whether an action can be taken to make the last interim deposit the final deposit
0126:             * 
0127:             * @return true if last interim deposit could be the final deposit, false if otherwise
0128:             */
0129:            public boolean isLastInterimDepositFinalizable() {
0130:                boolean result = true;
0131:                CashManagementDocument cmDoc = getCashManagementDocument();
0132:                result &= !cmDoc.hasFinalDeposit();
0133:                result &= (cmDoc.getDeposits().size() > 0);
0134:                if (result) {
0135:                    result &= SpringContext
0136:                            .getBean(CashManagementService.class)
0137:                            .allVerifiedCashReceiptsAreDeposited(cmDoc);
0138:                }
0139:                return result;
0140:            }
0141:
0142:            /**
0143:             * @return CashDrawerSummary instance associated with this form, if any
0144:             */
0145:            public CashDrawerSummary getCashDrawerSummary() {
0146:                return cashDrawerSummary;
0147:            }
0148:
0149:            /**
0150:             * Sets the CashDrawerSummary
0151:             */
0152:            public void setCashDrawerSummary(CashDrawerSummary cashDrawerSummary) {
0153:                this .cashDrawerSummary = cashDrawerSummary;
0154:            }
0155:
0156:            /**
0157:             * @return List
0158:             */
0159:            public List getDepositHelpers() {
0160:                return depositHelpers;
0161:            }
0162:
0163:            /**
0164:             * Gets the recentlyClosedItemsInProcess attribute.
0165:             * 
0166:             * @return Returns the recentlyClosedItemsInProcess.
0167:             */
0168:            public List<CashieringItemInProcess> getRecentlyClosedItemsInProcess() {
0169:                return recentlyClosedItemsInProcess;
0170:            }
0171:
0172:            /**
0173:             * Sets the recentlyClosedItemsInProcess attribute value.
0174:             * 
0175:             * @param recentlyClosedItemsInProcess The recentlyClosedItemsInProcess to set.
0176:             */
0177:            public void setRecentlyClosedItemsInProcess(
0178:                    List<CashieringItemInProcess> recentlyClosedItemsInProcess) {
0179:                this .recentlyClosedItemsInProcess = recentlyClosedItemsInProcess;
0180:            }
0181:
0182:            /**
0183:             * @param i
0184:             * @return DepositHelper
0185:             */
0186:            public DepositHelper getDepositHelper(int i) {
0187:                while (depositHelpers.size() <= i) {
0188:                    depositHelpers.add(new DepositHelper());
0189:                }
0190:                DepositHelper dh = (DepositHelper) depositHelpers.get(i);
0191:
0192:                return dh;
0193:            }
0194:
0195:            /**
0196:             * Removes and returns DepositHelper at the given index
0197:             * 
0198:             * @param i
0199:             * @return
0200:             */
0201:            public DepositHelper removeDepositHelper(int i) {
0202:                return (DepositHelper) depositHelpers.remove(i);
0203:            }
0204:
0205:            /**
0206:             * Inner helper class.
0207:             */
0208:            public static final class DepositHelper {
0209:                private Integer depositLineNumber;
0210:                private List<CashReceiptSummary> cashReceiptSummarys;
0211:                private List<Check> cashieringChecks;
0212:
0213:                /**
0214:                 * Constructs a DepositHelper - default constructor used by PojoProcessor.
0215:                 */
0216:                public DepositHelper() {
0217:                    cashReceiptSummarys = new ArrayList<CashReceiptSummary>();
0218:                    cashieringChecks = new ArrayList<Check>();
0219:                    depositLineNumber = new Integer(1);
0220:                }
0221:
0222:                /**
0223:                 * Constructs a DepositHelper
0224:                 * 
0225:                 * @param deposit
0226:                 */
0227:                public DepositHelper(Deposit deposit) {
0228:                    depositLineNumber = deposit
0229:                            .getFinancialDocumentDepositLineNumber();
0230:
0231:                    cashReceiptSummarys = new ArrayList<CashReceiptSummary>();
0232:
0233:                    CashManagementService cmService = SpringContext
0234:                            .getBean(CashManagementService.class);
0235:                    List<CashReceiptDocument> cashReceipts = cmService
0236:                            .retrieveCashReceipts(deposit);
0237:                    for (CashReceiptDocument document : cashReceipts) {
0238:                        cashReceiptSummarys
0239:                                .add(new CashReceiptSummary(document));
0240:                    }
0241:
0242:                    cashieringChecks = cmService
0243:                            .selectCashieringChecksForDeposit(deposit
0244:                                    .getDocumentNumber(), depositLineNumber);
0245:                }
0246:
0247:                /**
0248:                 * @return List
0249:                 */
0250:                public List<CashReceiptSummary> getCashReceiptSummarys() {
0251:                    return cashReceiptSummarys;
0252:                }
0253:
0254:                /**
0255:                 * @param i
0256:                 * @return CashReceiptSummary
0257:                 */
0258:                public CashReceiptSummary getCashReceiptSummary(int index) {
0259:                    extendCashReceiptSummarys(index + 1);
0260:
0261:                    return cashReceiptSummarys.get(index);
0262:                }
0263:
0264:                /**
0265:                 * Ensures that there are at least minSize entries in the cashReceiptSummarys list
0266:                 * 
0267:                 * @param minSize
0268:                 */
0269:                private void extendCashReceiptSummarys(int minSize) {
0270:                    while (cashReceiptSummarys.size() < minSize) {
0271:                        cashReceiptSummarys.add(new CashReceiptSummary());
0272:                    }
0273:                }
0274:
0275:                /**
0276:                 * Gets the cashieringChecks attribute.
0277:                 * 
0278:                 * @return Returns the cashieringChecks.
0279:                 */
0280:                public List<Check> getCashieringChecks() {
0281:                    return cashieringChecks;
0282:                }
0283:
0284:                /**
0285:                 * Get a specific cashiering check in the list of cashiering checks
0286:                 * 
0287:                 * @param index the index of the check to retrieve
0288:                 * @return a check
0289:                 */
0290:                public Check getCashieringCheck(int index) {
0291:                    extendCashieringChecks(index);
0292:                    return cashieringChecks.get(index);
0293:                }
0294:
0295:                /**
0296:                 * This method makes the cashiering checks list longer, to avoid Array Index out of bounds issues
0297:                 * 
0298:                 * @param minSize the minimum size to make the list
0299:                 */
0300:                private void extendCashieringChecks(int minSize) {
0301:                    while (cashieringChecks.size() <= minSize) {
0302:                        cashieringChecks.add(new CheckBase());
0303:                    }
0304:                }
0305:
0306:                /**
0307:                 * @return Integer
0308:                 */
0309:                public Integer getDepositLineNumber() {
0310:                    return depositLineNumber;
0311:                }
0312:
0313:                /**
0314:                 * @see java.lang.Object#toString()
0315:                 */
0316:                @Override
0317:                public String toString() {
0318:                    return "deposit #" + depositLineNumber;
0319:                }
0320:            }
0321:
0322:            public static final class CashReceiptSummary {
0323:                private String documentNumber;
0324:                private String description;
0325:                private Timestamp createDate;
0326:                private KualiDecimal totalAmount;
0327:                private KualiDecimal checkAmount;
0328:
0329:                /**
0330:                 * Default constructor used by PojoProcessor.
0331:                 */
0332:                public CashReceiptSummary() {
0333:                }
0334:
0335:                /**
0336:                 * Constructs a CashReceiptSummary from the given CashReceiptDocument.
0337:                 * 
0338:                 * @param crd
0339:                 */
0340:                public CashReceiptSummary(CashReceiptDocument crd) {
0341:                    documentNumber = crd.getDocumentNumber();
0342:                    description = crd.getDocumentHeader()
0343:                            .getFinancialDocumentDescription();
0344:                    createDate = crd.getDocumentHeader().getWorkflowDocument()
0345:                            .getCreateDate();
0346:                    checkAmount = crd.getTotalCheckAmount();
0347:                    totalAmount = crd.getTotalDollarAmount();
0348:                }
0349:
0350:                /**
0351:                 * @return current value of createDate.
0352:                 */
0353:                public Timestamp getCreateDate() {
0354:                    return createDate;
0355:                }
0356:
0357:                /**
0358:                 * Sets the createDate attribute value.
0359:                 * 
0360:                 * @param createDate The createDate to set.
0361:                 */
0362:                public void setCreateDate(Timestamp createDate) {
0363:                    this .createDate = createDate;
0364:                }
0365:
0366:                /**
0367:                 * @return current value of description.
0368:                 */
0369:                public String getDescription() {
0370:                    return description;
0371:                }
0372:
0373:                /**
0374:                 * Sets the description attribute value.
0375:                 * 
0376:                 * @param description The description to set.
0377:                 */
0378:                public void setDescription(String description) {
0379:                    this .description = description;
0380:                }
0381:
0382:                /**
0383:                 * @return current value of documentNumber.
0384:                 */
0385:                public String getDocumentNumber() {
0386:                    return documentNumber;
0387:                }
0388:
0389:                /**
0390:                 * Sets the documentNumber attribute value.
0391:                 * 
0392:                 * @param docNumber The documentNumber to set.
0393:                 */
0394:                public void setDocumentNumber(String documentNumber) {
0395:                    this .documentNumber = documentNumber;
0396:                }
0397:
0398:                /**
0399:                 * @return current value of totalAmount.
0400:                 */
0401:                public KualiDecimal getTotalAmount() {
0402:                    return totalAmount;
0403:                }
0404:
0405:                /**
0406:                 * Sets the totalAmount attribute value.
0407:                 * 
0408:                 * @param totalAmount The totalAmount to set.
0409:                 */
0410:                public void setTotalAmount(KualiDecimal totalAmount) {
0411:                    this .totalAmount = totalAmount;
0412:                }
0413:
0414:                /**
0415:                 * Returns the total check amount for this CR
0416:                 * 
0417:                 * @return a total of checks
0418:                 */
0419:                public KualiDecimal getCheckAmount() {
0420:                    return this .checkAmount;
0421:                }
0422:
0423:                /**
0424:                 * Sets the checkAmount attribute value.
0425:                 */
0426:                public void setCheckAmount(KualiDecimal checkAmount) {
0427:                    this .checkAmount = checkAmount;
0428:                }
0429:
0430:                /**
0431:                 * @see java.lang.Object#toString()
0432:                 */
0433:                @Override
0434:                public String toString() {
0435:                    return "CRSummary " + getDocumentNumber();
0436:                }
0437:            }
0438:
0439:            public static final class CashDrawerSummary {
0440:                private Timestamp timeOpened;
0441:                private Timestamp timeRefreshed;
0442:
0443:                // directly calculated
0444:                private int overallReceiptCount;
0445:                private int depositedReceiptCount;
0446:
0447:                private CashReceiptStatistics verifiedReceiptStats = new CashReceiptStatistics();
0448:                private CashReceiptStatistics interimReceiptStats = new CashReceiptStatistics();
0449:                private CashReceiptStatistics finalReceiptStats = new CashReceiptStatistics();
0450:                private CashReceiptStatistics overallReceiptStats = new CashReceiptStatistics();
0451:
0452:                // derived
0453:                private KualiDecimal verifiedReceiptSumTotal;
0454:                private KualiDecimal interimReceiptSumTotal;
0455:                private KualiDecimal finalReceiptSumTotal;
0456:                private KualiDecimal overallReceiptSumTotal;
0457:
0458:                private KualiDecimal remainingCheckTotal;
0459:                private KualiDecimal remainingCurrencyTotal;
0460:                private KualiDecimal remainingCoinTotal;
0461:                private KualiDecimal remainingSumTotal;
0462:
0463:                private boolean isDepositsFinal = false;
0464:                private KualiDecimal cashieringChecksTotal;
0465:                private KualiDecimal depositedCashieringChecksTotal;
0466:                private KualiDecimal undepositedCashieringChecksTotal;
0467:                private KualiDecimal cashDrawerCurrencyTotal;
0468:                private KualiDecimal cashDrawerCoinTotal;
0469:                private KualiDecimal openItemsTotal;
0470:                private KualiDecimal cashDrawerTotal;
0471:                private KualiDecimal interimDepositedCashieringChecksTotal;
0472:                private KualiDecimal finalDepositedCashieringChecksTotal;
0473:
0474:                public CashDrawerSummary(CashManagementDocument cmDoc) {
0475:                    timeOpened = cmDoc.getDocumentHeader()
0476:                            .getWorkflowDocument().getCreateDate();
0477:
0478:                    resummarize(cmDoc);
0479:                }
0480:
0481:                public CashDrawerSummary() {
0482:                }
0483:
0484:                private static final String[] INTERESTING_STATII = {
0485:                        CashReceipt.VERIFIED, CashReceipt.INTERIM,
0486:                        CashReceipt.FINAL };
0487:
0488:                public void resummarize(CashManagementDocument cmDoc) {
0489:                    //
0490:                    // get all interesting CRs
0491:                    String workgroupName = cmDoc.getWorkgroupName();
0492:                    List<CashReceiptDocument> interestingReceipts = SpringContext
0493:                            .getBean(CashReceiptService.class).getCashReceipts(
0494:                                    workgroupName, INTERESTING_STATII);
0495:
0496:                    //
0497:                    // rather than separating into lists by status, gather statistics in one fell swoop
0498:                    overallReceiptStats.clear();
0499:                    verifiedReceiptStats.clear();
0500:                    interimReceiptStats.clear();
0501:                    finalReceiptStats.clear();
0502:
0503:                    for (CashReceiptDocument receipt : interestingReceipts) {
0504:                        String status = receipt.getDocumentHeader()
0505:                                .getFinancialDocumentStatusCode();
0506:                        overallReceiptStats.add(receipt);
0507:                        if (status.equals(CashReceipt.VERIFIED)) {
0508:                            verifiedReceiptStats.add(receipt);
0509:                        } else if (status.equals(CashReceipt.INTERIM)) {
0510:                            interimReceiptStats.add(receipt);
0511:                        } else if (status.equals(CashReceipt.FINAL)) {
0512:                            finalReceiptStats.add(receipt);
0513:                        } else {
0514:                            throw new IllegalStateException(
0515:                                    "invalid (unknown) financialDocumentStatusCode '"
0516:                                            + status + "'");
0517:                        }
0518:                    }
0519:
0520:                    overallReceiptCount = overallReceiptStats.getReceiptCount();
0521:                    depositedReceiptCount = interimReceiptStats
0522:                            .getReceiptCount()
0523:                            + finalReceiptStats.getReceiptCount();
0524:
0525:                    // get cash drawer summary info
0526:                    depositedCashieringChecksTotal = calculateDepositedCashieringChecksTotal(cmDoc);
0527:                    undepositedCashieringChecksTotal = calculateUndepositedCashieringChecksTotal(cmDoc);
0528:                    cashieringChecksTotal = depositedCashieringChecksTotal
0529:                            .add(undepositedCashieringChecksTotal);
0530:                    openItemsTotal = calculateOpenItemsTotal(cmDoc);
0531:                    cashDrawerCurrencyTotal = cmDoc.getCashDrawer()
0532:                            .getCurrencyTotalAmount();
0533:                    cashDrawerCoinTotal = cmDoc.getCashDrawer()
0534:                            .getCoinTotalAmount();
0535:                    cashDrawerTotal = undepositedCashieringChecksTotal
0536:                            .add(openItemsTotal.add(cashDrawerCurrencyTotal
0537:                                    .add(cashDrawerCoinTotal)));
0538:                    Map<String, KualiDecimal> results = calculateDepositedCashieringChecksTotalByDepositType(cmDoc);
0539:                    interimDepositedCashieringChecksTotal = results
0540:                            .get(DepositConstants.DEPOSIT_TYPE_INTERIM);
0541:                    KualiDecimal finalDepositCashTotal = new KualiDecimal(0);
0542:                    Map<Class, Object> finalDepositCashDetails = SpringContext
0543:                            .getBean(CashManagementService.class)
0544:                            .getCashDetailsForFinalDeposit(
0545:                                    cmDoc.getDocumentNumber());
0546:                    KualiDecimal currencyDepositAmount = KualiDecimal.ZERO;
0547:                    if (finalDepositCashDetails.get(CurrencyDetail.class) != null) {
0548:                        currencyDepositAmount = ((CurrencyDetail) finalDepositCashDetails
0549:                                .get(CurrencyDetail.class)).getTotalAmount();
0550:                    }
0551:                    KualiDecimal coinDepositAmount = KualiDecimal.ZERO;
0552:                    if (finalDepositCashDetails.get(CoinDetail.class) != null) {
0553:                        coinDepositAmount = ((CoinDetail) finalDepositCashDetails
0554:                                .get(CoinDetail.class)).getTotalAmount();
0555:                    }
0556:                    finalDepositCashTotal = finalDepositCashTotal.add(
0557:                            currencyDepositAmount).add(coinDepositAmount);
0558:                    finalDepositedCashieringChecksTotal = results.get(
0559:                            DepositConstants.DEPOSIT_TYPE_FINAL).add(
0560:                            finalDepositCashTotal);
0561:
0562:                    verifiedReceiptSumTotal = verifiedReceiptStats
0563:                            .getSumTotal();
0564:                    interimReceiptSumTotal = interimReceiptStats
0565:                            .getCheckTotal().add(
0566:                                    interimDepositedCashieringChecksTotal);
0567:                    finalReceiptSumTotal = finalReceiptStats.getCheckTotal()
0568:                            .add(finalDepositedCashieringChecksTotal);
0569:                    overallReceiptSumTotal = overallReceiptStats.getSumTotal();
0570:
0571:                    remainingCheckTotal = overallReceiptStats.getCheckTotal()
0572:                            .subtract(interimReceiptStats.getCheckTotal())
0573:                            .subtract(finalReceiptStats.getCheckTotal());
0574:                    remainingCurrencyTotal = overallReceiptStats
0575:                            .getCurrencyTotal().subtract(currencyDepositAmount)
0576:                            .subtract(depositedCashieringChecksTotal);
0577:                    remainingCoinTotal = overallReceiptStats.getCoinTotal()
0578:                            .subtract(coinDepositAmount);
0579:                    remainingSumTotal = remainingCheckTotal
0580:                            .add(remainingCurrencyTotal.add(remainingCoinTotal));
0581:
0582:                    isDepositsFinal = cmDoc.hasFinalDeposit();
0583:
0584:                    timeRefreshed = SpringContext
0585:                            .getBean(DateTimeService.class)
0586:                            .getCurrentTimestamp();
0587:                }
0588:
0589:                private KualiDecimal calculateDepositedCashieringChecksTotal(
0590:                        CashManagementDocument cmDoc) {
0591:                    return SpringContext.getBean(CashManagementService.class)
0592:                            .calculateDepositedCheckTotal(
0593:                                    cmDoc.getDocumentNumber());
0594:                }
0595:
0596:                private KualiDecimal calculateUndepositedCashieringChecksTotal(
0597:                        CashManagementDocument cmDoc) {
0598:                    return SpringContext.getBean(CashManagementService.class)
0599:                            .calculateUndepositedCheckTotal(
0600:                                    cmDoc.getDocumentNumber());
0601:                }
0602:
0603:                private KualiDecimal calculateOpenItemsTotal(
0604:                        CashManagementDocument cmDoc) {
0605:                    KualiDecimal total = new KualiDecimal(0);
0606:                    for (CashieringItemInProcess itemInProcess : SpringContext
0607:                            .getBean(CashManagementService.class)
0608:                            .getOpenItemsInProcess(cmDoc)) {
0609:                        if (itemInProcess.getItemRemainingAmount() != null) {
0610:                            total = total.add(itemInProcess
0611:                                    .getItemRemainingAmount());
0612:                        }
0613:                    }
0614:                    return total;
0615:                }
0616:
0617:                private Map<String, KualiDecimal> calculateDepositedCashieringChecksTotalByDepositType(
0618:                        CashManagementDocument cmDoc) {
0619:                    Map<String, KualiDecimal> result = new HashMap<String, KualiDecimal>();
0620:                    result.put(DepositConstants.DEPOSIT_TYPE_INTERIM,
0621:                            new KualiDecimal(0));
0622:                    result.put(DepositConstants.DEPOSIT_TYPE_FINAL,
0623:                            new KualiDecimal(0));
0624:                    // 1. get all deposited cashiering checks
0625:                    List<Check> checks = SpringContext.getBean(
0626:                            CashManagementService.class)
0627:                            .selectDepositedCashieringChecks(
0628:                                    cmDoc.getDocumentNumber());
0629:                    // 2. get all deposits
0630:                    List<Deposit> deposits = cmDoc.getDeposits();
0631:                    Map<Integer, String> depositTypes = new HashMap<Integer, String>();
0632:                    for (Deposit deposit : deposits) {
0633:                        depositTypes.put(deposit
0634:                                .getFinancialDocumentDepositLineNumber(),
0635:                                deposit.getDepositTypeCode());
0636:                    }
0637:                    // 3. now, go through all cashiering checks, totalling them to the right deposit type
0638:                    for (Check check : checks) {
0639:                        KualiDecimal properTotal = result
0640:                                .get(depositTypes
0641:                                        .get(check
0642:                                                .getFinancialDocumentDepositLineNumber()));
0643:                        properTotal = properTotal.add(check.getAmount());
0644:                        result.put(depositTypes.get(check
0645:                                .getFinancialDocumentDepositLineNumber()),
0646:                                properTotal);
0647:                    }
0648:                    return result;
0649:                }
0650:
0651:                /**
0652:                 * @return current value of depositedReceiptCount.
0653:                 */
0654:                public int getDepositedReceiptCount() {
0655:                    return depositedReceiptCount;
0656:                }
0657:
0658:                /**
0659:                 * Sets the depositedReceiptCount attribute value.
0660:                 * 
0661:                 * @param depositedReceiptCount The depositedReceiptCount to set.
0662:                 */
0663:                public void setDepositedReceiptCount(int depositedReceiptCount) {
0664:                    this .depositedReceiptCount = depositedReceiptCount;
0665:                }
0666:
0667:                /**
0668:                 * @return current value of finalReceiptSumTotal.
0669:                 */
0670:                public KualiDecimal getFinalReceiptSumTotal() {
0671:                    return finalReceiptSumTotal;
0672:                }
0673:
0674:                /**
0675:                 * Sets the finalReceiptSumTotal attribute value.
0676:                 * 
0677:                 * @param finalReceiptSumTotal The finalReceiptSumTotal to set.
0678:                 */
0679:                public void setFinalReceiptSumTotal(KualiDecimal finalSumTotal) {
0680:                    this .finalReceiptSumTotal = finalSumTotal;
0681:                }
0682:
0683:                /**
0684:                 * @return current value of interimReceiptSumTotal.
0685:                 */
0686:                public KualiDecimal getInterimReceiptSumTotal() {
0687:                    return interimReceiptSumTotal;
0688:                }
0689:
0690:                /**
0691:                 * Sets the interimReceiptSumTotal attribute value.
0692:                 * 
0693:                 * @param interimReceiptSumTotal The interimReceiptSumTotal to set.
0694:                 */
0695:                public void setInterimReceiptSumTotal(
0696:                        KualiDecimal interimSumTotal) {
0697:                    this .interimReceiptSumTotal = interimSumTotal;
0698:                }
0699:
0700:                /**
0701:                 * @return current value of overallReceiptCount.
0702:                 */
0703:                public int getOverallReceiptCount() {
0704:                    return overallReceiptCount;
0705:                }
0706:
0707:                /**
0708:                 * Sets the overallReceiptCount attribute value.
0709:                 * 
0710:                 * @param overallReceiptCount The overallReceiptCount to set.
0711:                 */
0712:                public void setOverallReceiptCount(int overallReceiptCount) {
0713:                    this .overallReceiptCount = overallReceiptCount;
0714:                }
0715:
0716:                /**
0717:                 * @return current value of remainingCheckTotal.
0718:                 */
0719:                public KualiDecimal getRemainingCheckTotal() {
0720:                    return remainingCheckTotal;
0721:                }
0722:
0723:                /**
0724:                 * Sets the remainingCheckTotal attribute value.
0725:                 * 
0726:                 * @param remainingCheckTotal The remainingCheckTotal to set.
0727:                 */
0728:                public void setRemainingCheckTotal(
0729:                        KualiDecimal remainingCheckTotal) {
0730:                    this .remainingCheckTotal = remainingCheckTotal;
0731:                }
0732:
0733:                /**
0734:                 * @return current value of remainingCoinTotal.
0735:                 */
0736:                public KualiDecimal getRemainingCoinTotal() {
0737:                    return remainingCoinTotal;
0738:                }
0739:
0740:                /**
0741:                 * Sets the remainingCoinTotal attribute value.
0742:                 * 
0743:                 * @param remainingCoinTotal The remainingCoinTotal to set.
0744:                 */
0745:                public void setRemainingCoinTotal(
0746:                        KualiDecimal remainingCoinTotal) {
0747:                    this .remainingCoinTotal = remainingCoinTotal;
0748:                }
0749:
0750:                /**
0751:                 * @return current value of remainingCurrencyTotal.
0752:                 */
0753:                public KualiDecimal getRemainingCurrencyTotal() {
0754:                    return remainingCurrencyTotal;
0755:                }
0756:
0757:                /**
0758:                 * Sets the remainingCurrencyTotal attribute value.
0759:                 * 
0760:                 * @param remainingCurrencyTotal The remainingCurrencyTotal to set.
0761:                 */
0762:                public void setRemainingCurrencyTotal(
0763:                        KualiDecimal remainingCurrencyTotal) {
0764:                    this .remainingCurrencyTotal = remainingCurrencyTotal;
0765:                }
0766:
0767:                /**
0768:                 * @return current value of remainingSumTotal.
0769:                 */
0770:                public KualiDecimal getRemainingSumTotal() {
0771:                    return remainingSumTotal;
0772:                }
0773:
0774:                /**
0775:                 * Sets the remainingSumTotal attribute value.
0776:                 * 
0777:                 * @param remainingSumTotal The remainingSumTotal to set.
0778:                 */
0779:                public void setRemainingSumTotal(KualiDecimal remainingSumTotal) {
0780:                    this .remainingSumTotal = remainingSumTotal;
0781:                }
0782:
0783:                /**
0784:                 * @return current value of timeOpened.
0785:                 */
0786:                public Timestamp getTimeOpened() {
0787:                    return timeOpened;
0788:                }
0789:
0790:                /**
0791:                 * Sets the timeOpened attribute value.
0792:                 * 
0793:                 * @param timeOpened The timeOpened to set.
0794:                 */
0795:                public void setTimeOpened(Timestamp timeOpened) {
0796:                    this .timeOpened = timeOpened;
0797:                }
0798:
0799:                /**
0800:                 * @return current value of timeRefreshed.
0801:                 */
0802:                public Timestamp getTimeRefreshed() {
0803:                    return timeRefreshed;
0804:                }
0805:
0806:                /**
0807:                 * Sets the timeRefreshed attribute value.
0808:                 * 
0809:                 * @param timeRefreshed The timeRefreshed to set.
0810:                 */
0811:                public void setTimeRefreshed(Timestamp timeRefreshed) {
0812:                    this .timeRefreshed = timeRefreshed;
0813:                }
0814:
0815:                /**
0816:                 * @return current value of verifiedReceiptSumTotal.
0817:                 */
0818:                public KualiDecimal getVerifiedReceiptSumTotal() {
0819:                    return verifiedReceiptSumTotal;
0820:                }
0821:
0822:                /**
0823:                 * Sets the verifiedReceiptSumTotal attribute value.
0824:                 * 
0825:                 * @param verifiedReceiptSumTotal The verifiedReceiptSumTotal to set.
0826:                 */
0827:                public void setVerifiedReceiptSumTotal(
0828:                        KualiDecimal verifiedSumTotal) {
0829:                    this .verifiedReceiptSumTotal = verifiedSumTotal;
0830:                }
0831:
0832:                /**
0833:                 * @return current value of overallReceiptSumTotal.
0834:                 */
0835:                public KualiDecimal getOverallReceiptSumTotal() {
0836:                    return overallReceiptSumTotal;
0837:                }
0838:
0839:                /**
0840:                 * Sets the overallReceiptSumTotal attribute value.
0841:                 * 
0842:                 * @param overallReceiptSumTotal The overallReceiptSumTotal to set.
0843:                 */
0844:                public void setOverallReceiptSumTotal(
0845:                        KualiDecimal overallSumTotal) {
0846:                    this .overallReceiptSumTotal = overallSumTotal;
0847:                }
0848:
0849:                /**
0850:                 * @return current value of finalReceiptStats.
0851:                 */
0852:                public CashReceiptStatistics getFinalReceiptStats() {
0853:                    return finalReceiptStats;
0854:                }
0855:
0856:                /**
0857:                 * @return current value of interimReceiptStats.
0858:                 */
0859:                public CashReceiptStatistics getInterimReceiptStats() {
0860:                    return interimReceiptStats;
0861:                }
0862:
0863:                /**
0864:                 * @return current value of verifiedReceiptStats.
0865:                 */
0866:                public CashReceiptStatistics getVerifiedReceiptStats() {
0867:                    return verifiedReceiptStats;
0868:                }
0869:
0870:                /**
0871:                 * Gets the cashDrawerCoinTotal attribute.
0872:                 * 
0873:                 * @return Returns the cashDrawerCoinTotal.
0874:                 */
0875:                public KualiDecimal getCashDrawerCoinTotal() {
0876:                    return cashDrawerCoinTotal;
0877:                }
0878:
0879:                /**
0880:                 * Gets the cashDrawerCurrencyTotal attribute.
0881:                 * 
0882:                 * @return Returns the cashDrawerCurrencyTotal.
0883:                 */
0884:                public KualiDecimal getCashDrawerCurrencyTotal() {
0885:                    return cashDrawerCurrencyTotal;
0886:                }
0887:
0888:                /**
0889:                 * Gets the cashDrawerTotal attribute.
0890:                 * 
0891:                 * @return Returns the cashDrawerTotal.
0892:                 */
0893:                public KualiDecimal getCashDrawerTotal() {
0894:                    return cashDrawerTotal;
0895:                }
0896:
0897:                /**
0898:                 * Gets the cashieringChecksTotal attribute.
0899:                 * 
0900:                 * @return Returns the cashieringChecksTotal.
0901:                 */
0902:                public KualiDecimal getCashieringChecksTotal() {
0903:                    return cashieringChecksTotal;
0904:                }
0905:
0906:                /**
0907:                 * Sets the cashieringChecksTotal attribute value.
0908:                 * 
0909:                 * @param cashieringChecksTotal The cashieringChecksTotal to set.
0910:                 */
0911:                public void setCashieringChecksTotal(
0912:                        KualiDecimal cashieringChecksTotal) {
0913:                    this .cashieringChecksTotal = cashieringChecksTotal;
0914:                }
0915:
0916:                /**
0917:                 * Sets the depositedCashieringChecksTotal attribute value.
0918:                 * 
0919:                 * @param depositedCashieringChecksTotal The depositedCashieringChecksTotal to set.
0920:                 */
0921:                public void setDepositedCashieringChecksTotal(
0922:                        KualiDecimal depositedCashieringChecksTotal) {
0923:                    this .depositedCashieringChecksTotal = depositedCashieringChecksTotal;
0924:                }
0925:
0926:                /**
0927:                 * Gets the isDepositsFinal attribute.
0928:                 * 
0929:                 * @return Returns the isDepositsFinal.
0930:                 */
0931:                public boolean isDepositsFinal() {
0932:                    return isDepositsFinal;
0933:                }
0934:
0935:                /**
0936:                 * Sets the cashDrawerCoinTotal attribute value.
0937:                 * 
0938:                 * @param cashDrawerCoinTotal The cashDrawerCoinTotal to set.
0939:                 */
0940:                public void setCashDrawerCoinTotal(
0941:                        KualiDecimal cashDrawerCoinTotal) {
0942:                    this .cashDrawerCoinTotal = cashDrawerCoinTotal;
0943:                }
0944:
0945:                /**
0946:                 * Sets the cashDrawerCurrencyTotal attribute value.
0947:                 * 
0948:                 * @param cashDrawerCurrencyTotal The cashDrawerCurrencyTotal to set.
0949:                 */
0950:                public void setCashDrawerCurrencyTotal(
0951:                        KualiDecimal cashDrawerCurrencyTotal) {
0952:                    this .cashDrawerCurrencyTotal = cashDrawerCurrencyTotal;
0953:                }
0954:
0955:                /**
0956:                 * Sets the cashDrawerTotal attribute value.
0957:                 * 
0958:                 * @param cashDrawerTotal The cashDrawerTotal to set.
0959:                 */
0960:                public void setCashDrawerTotal(KualiDecimal cashDrawerTotal) {
0961:                    this .cashDrawerTotal = cashDrawerTotal;
0962:                }
0963:
0964:                /**
0965:                 * Sets the openItemsTotal attribute value.
0966:                 * 
0967:                 * @param openItemsTotal The openItemsTotal to set.
0968:                 */
0969:                public void setOpenItemsTotal(KualiDecimal openItemsTotal) {
0970:                    this .openItemsTotal = openItemsTotal;
0971:                }
0972:
0973:                /**
0974:                 * Sets the undepositedCashieringChecksTotal attribute value.
0975:                 * 
0976:                 * @param undepositedCashieringChecksTotal The undepositedCashieringChecksTotal to set.
0977:                 */
0978:                public void setUndepositedCashieringChecksTotal(
0979:                        KualiDecimal undepositedCashieringChecksTotal) {
0980:                    this .undepositedCashieringChecksTotal = undepositedCashieringChecksTotal;
0981:                }
0982:
0983:                /**
0984:                 * Gets the openItemsTotal attribute.
0985:                 * 
0986:                 * @return Returns the openItemsTotal.
0987:                 */
0988:                public KualiDecimal getOpenItemsTotal() {
0989:                    return openItemsTotal;
0990:                }
0991:
0992:                /**
0993:                 * Gets the depositedCashieringChecksTotal attribute.
0994:                 * 
0995:                 * @return Returns the depositedCashieringChecksTotal.
0996:                 */
0997:                public KualiDecimal getDepositedCashieringChecksTotal() {
0998:                    return depositedCashieringChecksTotal;
0999:                }
1000:
1001:                /**
1002:                 * Gets the undepositedCashieringChecksTotal attribute.
1003:                 * 
1004:                 * @return Returns the undepositedCashieringChecksTotal.
1005:                 */
1006:                public KualiDecimal getUndepositedCashieringChecksTotal() {
1007:                    return undepositedCashieringChecksTotal;
1008:                }
1009:
1010:                /**
1011:                 * @return current value of overalllStats.
1012:                 */
1013:                public CashReceiptStatistics getOverallReceiptStats() {
1014:                    return overallReceiptStats;
1015:                }
1016:
1017:                public static final class CashReceiptStatistics {
1018:                    private int receiptCount;
1019:                    private KualiDecimal checkTotal;
1020:                    private KualiDecimal currencyTotal;
1021:                    private KualiDecimal coinTotal;
1022:
1023:                    /**
1024:                     * Constructs a SubSummary.
1025:                     */
1026:                    public CashReceiptStatistics() {
1027:                        clear();
1028:                    }
1029:
1030:                    /**
1031:                     * Increments the counter by 1, and the various totals by the amounts in the given CashReceiptDocument
1032:                     * 
1033:                     * @param receipt
1034:                     */
1035:                    public void add(CashReceiptDocument receipt) {
1036:                        receipt.refreshCashDetails();
1037:                        receiptCount++;
1038:                        checkTotal = checkTotal.add(receipt
1039:                                .getTotalCheckAmount());
1040:                        currencyTotal = currencyTotal.add(receipt
1041:                                .getTotalCashAmount());
1042:                        coinTotal = coinTotal.add(receipt.getTotalCoinAmount());
1043:                    }
1044:
1045:                    /**
1046:                     * Zeros counter and totals.
1047:                     */
1048:                    public void clear() {
1049:                        receiptCount = 0;
1050:                        checkTotal = KualiDecimal.ZERO;
1051:                        currencyTotal = KualiDecimal.ZERO;
1052:                        coinTotal = KualiDecimal.ZERO;
1053:                    }
1054:
1055:                    /**
1056:                     * Returns total of all check, coin, and currency totals
1057:                     */
1058:                    public KualiDecimal getSumTotal() {
1059:                        KualiDecimal sumTotal = getCheckTotal().add(
1060:                                getCoinTotal().add(getCurrencyTotal()));
1061:
1062:                        return sumTotal;
1063:                    }
1064:
1065:                    /**
1066:                     * This method doesn't do anything but appease the demands of POJO form population...I mean...er...this sets the sum
1067:                     * total, now doesn't it?
1068:                     * 
1069:                     * @param total total you want this method to ignore
1070:                     */
1071:                    public void setSumTotal(KualiDecimal total) {
1072:                        // don't do anything. just be very quiet and maybe the POJO loader will be satisfied
1073:                    }
1074:
1075:                    /**
1076:                     * @return current value of checkTotal.
1077:                     */
1078:                    public KualiDecimal getCheckTotal() {
1079:                        return checkTotal;
1080:                    }
1081:
1082:                    /**
1083:                     * Sets the checkTotal attribute value.
1084:                     * 
1085:                     * @param checkTotal The checkTotal to set.
1086:                     */
1087:                    public void setCheckTotal(KualiDecimal checkTotal) {
1088:                        this .checkTotal = checkTotal;
1089:                    }
1090:
1091:                    /**
1092:                     * @return current value of coinTotal.
1093:                     */
1094:                    public KualiDecimal getCoinTotal() {
1095:                        return coinTotal;
1096:                    }
1097:
1098:                    /**
1099:                     * Sets the coinTotal attribute value.
1100:                     * 
1101:                     * @param coinTotal The coinTotal to set.
1102:                     */
1103:                    public void setCoinTotal(KualiDecimal coinTotal) {
1104:                        this .coinTotal = coinTotal;
1105:                    }
1106:
1107:                    /**
1108:                     * @return current value of currencyTotal.
1109:                     */
1110:                    public KualiDecimal getCurrencyTotal() {
1111:                        return currencyTotal;
1112:                    }
1113:
1114:                    /**
1115:                     * Sets the currencyTotal attribute value.
1116:                     * 
1117:                     * @param currencyTotal The currencyTotal to set.
1118:                     */
1119:                    public void setCurrencyTotal(KualiDecimal currencyTotal) {
1120:                        this .currencyTotal = currencyTotal;
1121:                    }
1122:
1123:                    /**
1124:                     * @return current value of receiptCount.
1125:                     */
1126:                    public int getReceiptCount() {
1127:                        return receiptCount;
1128:                    }
1129:
1130:                    /**
1131:                     * Sets the receiptCount attribute value.
1132:                     * 
1133:                     * @param receiptCount The receiptCount to set.
1134:                     */
1135:                    public void setReceiptCount(int receiptCount) {
1136:                        this .receiptCount = receiptCount;
1137:                    }
1138:
1139:                    /**
1140:                     * @see java.lang.Object#toString()
1141:                     */
1142:                    @Override
1143:                    public String toString() {
1144:                        return "CashDrawerSummary(" + getSumTotal() + " = "
1145:                                + getCheckTotal() + " + " + getCurrencyTotal()
1146:                                + " + " + getCoinTotal() + ")";
1147:                    }
1148:                }
1149:            }
1150:
1151:            /**
1152:             * @see org.kuali.core.web.struts.pojo.PojoFormBase#postprocessRequestParameters(java.util.Map)
1153:             */
1154:            @Override
1155:            public void postprocessRequestParameters(Map requestParameters) {
1156:                super .postprocessRequestParameters(requestParameters);
1157:                // fish the workgroup name out of the parameters
1158:                String[] workgroupNames = (String[]) requestParameters
1159:                        .get(CashManagementForm.WORKGROUP_NAME_PROPERTY);
1160:                String workgroupName = null;
1161:                if (workgroupNames != null && workgroupNames.length > 0) {
1162:                    workgroupName = workgroupNames[0];
1163:                }
1164:                if (workgroupName != null
1165:                        && getCashManagementDocument() != null) {
1166:                    // use that to put the cash drawer back into the cash management document
1167:                    getCashManagementDocument().setCashDrawer(
1168:                            SpringContext.getBean(CashDrawerService.class)
1169:                                    .getByWorkgroupName(workgroupName, false));
1170:                }
1171:            }
1172:
1173:        }
w_ww.___j__a__v___a__2s_.c_o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.