Source Code Cross Referenced for DepositWizardAction.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » web » struts » action » 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.action 
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.action;
0017:
0018:        import java.util.ArrayList;
0019:        import java.util.HashMap;
0020:        import java.util.Iterator;
0021:        import java.util.List;
0022:        import java.util.Map;
0023:        import java.util.Properties;
0024:
0025:        import javax.servlet.http.HttpServletRequest;
0026:        import javax.servlet.http.HttpServletResponse;
0027:
0028:        import org.apache.commons.lang.StringUtils;
0029:        import org.apache.struts.action.ActionForm;
0030:        import org.apache.struts.action.ActionForward;
0031:        import org.apache.struts.action.ActionMapping;
0032:        import org.kuali.core.bo.user.UniversalUser;
0033:        import org.kuali.core.document.authorization.DocumentAuthorizer;
0034:        import org.kuali.core.exceptions.InfrastructureException;
0035:        import org.kuali.core.service.BusinessObjectService;
0036:        import org.kuali.core.service.DataDictionaryService;
0037:        import org.kuali.core.service.DocumentAuthorizationService;
0038:        import org.kuali.core.service.DocumentService;
0039:        import org.kuali.core.service.DocumentTypeService;
0040:        import org.kuali.core.util.GlobalVariables;
0041:        import org.kuali.core.util.KualiDecimal;
0042:        import org.kuali.core.util.UrlFactory;
0043:        import org.kuali.core.web.struts.action.KualiAction;
0044:        import org.kuali.kfs.KFSConstants;
0045:        import org.kuali.kfs.KFSKeyConstants;
0046:        import org.kuali.kfs.KFSConstants.CashDrawerConstants;
0047:        import org.kuali.kfs.KFSConstants.DocumentStatusCodes.CashReceipt;
0048:        import org.kuali.kfs.context.SpringContext;
0049:        import org.kuali.module.financial.bo.Bank;
0050:        import org.kuali.module.financial.bo.BankAccount;
0051:        import org.kuali.module.financial.bo.CashDrawer;
0052:        import org.kuali.module.financial.bo.CashieringTransaction;
0053:        import org.kuali.module.financial.bo.Check;
0054:        import org.kuali.module.financial.bo.CoinDetail;
0055:        import org.kuali.module.financial.bo.CurrencyDetail;
0056:        import org.kuali.module.financial.bo.Deposit;
0057:        import org.kuali.module.financial.bo.DepositWizardCashieringCheckHelper;
0058:        import org.kuali.module.financial.bo.DepositWizardHelper;
0059:        import org.kuali.module.financial.document.CashManagementDocument;
0060:        import org.kuali.module.financial.document.CashReceiptDocument;
0061:        import org.kuali.module.financial.exceptions.CashDrawerStateException;
0062:        import org.kuali.module.financial.service.CashDrawerService;
0063:        import org.kuali.module.financial.service.CashManagementService;
0064:        import org.kuali.module.financial.service.CashReceiptService;
0065:        import org.kuali.module.financial.web.struts.form.CashDrawerStatusCodeFormatter;
0066:        import org.kuali.module.financial.web.struts.form.DepositWizardForm;
0067:
0068:        import edu.iu.uis.eden.exception.WorkflowException;
0069:
0070:        /**
0071:         * This class handles actions for the deposit wizard, which is used to create deposits that bundle groupings of Cash Receipt
0072:         * documents.
0073:         */
0074:        public class DepositWizardAction extends KualiAction {
0075:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
0076:                    .getLogger(DepositWizardAction.class);
0077:
0078:            /**
0079:             * Overrides the parent to validate the document state of the cashManagementDocument which will be updated and redisplayed after
0080:             * the DepositWizard builds and attaches the new Deposit.
0081:             * 
0082:             * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
0083:             *      javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
0084:             */
0085:            @Override
0086:            public ActionForward execute(ActionMapping mapping,
0087:                    ActionForm form, HttpServletRequest request,
0088:                    HttpServletResponse response) throws Exception {
0089:                DepositWizardForm dwForm = (DepositWizardForm) form;
0090:
0091:                ActionForward dest = super .execute(mapping, form, request,
0092:                        response);
0093:
0094:                // check authorization manually, since the auth-check isn't inherited by this class
0095:                String cmDocTypeName = SpringContext.getBean(
0096:                        DataDictionaryService.class)
0097:                        .getDocumentTypeNameByClass(
0098:                                CashManagementDocument.class);
0099:                DocumentAuthorizer cmDocAuthorizer = SpringContext.getBean(
0100:                        DocumentAuthorizationService.class)
0101:                        .getDocumentAuthorizer(cmDocTypeName);
0102:                UniversalUser luser = GlobalVariables.getUserSession()
0103:                        .getUniversalUser();
0104:                cmDocAuthorizer.canInitiate(cmDocTypeName, luser);
0105:
0106:                // populate the outgoing form used by the JSP if it seems empty
0107:                String cmDocId = dwForm.getCashManagementDocId();
0108:                if (StringUtils.isBlank(cmDocId)) {
0109:                    cmDocId = request.getParameter("cmDocId");
0110:                    String depositTypeCode = request
0111:                            .getParameter("depositTypeCode");
0112:
0113:                    CashManagementDocument cmDoc = (CashManagementDocument) SpringContext
0114:                            .getBean(DocumentService.class)
0115:                            .getByDocumentHeaderId(cmDocId);
0116:
0117:                    initializeForm(dwForm, cmDoc, depositTypeCode);
0118:                }
0119:
0120:                return dest;
0121:            }
0122:
0123:            /**
0124:             * Initializes the given form using the given values
0125:             * 
0126:             * @param dform
0127:             * @param cmDoc
0128:             * @param depositTypeCode
0129:             */
0130:            private void initializeForm(DepositWizardForm dform,
0131:                    CashManagementDocument cmDoc, String depositTypeCode) {
0132:                String verificationUnit = cmDoc.getWorkgroupName();
0133:
0134:                CashDrawer cd = SpringContext.getBean(CashDrawerService.class)
0135:                        .getByWorkgroupName(verificationUnit, true);
0136:                if (!cd.isOpen()) {
0137:                    CashDrawerStatusCodeFormatter f = new CashDrawerStatusCodeFormatter();
0138:
0139:                    String cmDocId = cmDoc.getDocumentNumber();
0140:                    String currentState = cd.getStatusCode();
0141:
0142:                    throw new CashDrawerStateException(verificationUnit,
0143:                            cmDocId, (String) f
0144:                                    .format(CashDrawerConstants.STATUS_OPEN),
0145:                            (String) f.format(cd.getStatusCode()));
0146:                }
0147:
0148:                dform.setCashManagementDocId(cmDoc.getDocumentNumber());
0149:                dform.setCashDrawerVerificationUnit(verificationUnit);
0150:
0151:                dform.setDepositTypeCode(depositTypeCode);
0152:
0153:                if (depositTypeCode
0154:                        .equals(KFSConstants.DocumentStatusCodes.CashReceipt.FINAL)) {
0155:                    // hey, we're the magical final deposit. We get currency and coin details!
0156:                    CurrencyDetail currencyDetail = new CurrencyDetail();
0157:                    currencyDetail.setDocumentNumber(cmDoc.getDocumentNumber());
0158:                    currencyDetail
0159:                            .setCashieringRecordSource(KFSConstants.CurrencyCoinSources.DEPOSITS);
0160:                    currencyDetail
0161:                            .setFinancialDocumentTypeCode(CashieringTransaction.DETAIL_DOCUMENT_TYPE);
0162:                    dform.setCurrencyDetail(currencyDetail);
0163:
0164:                    CoinDetail coinDetail = new CoinDetail();
0165:                    coinDetail.setDocumentNumber(cmDoc.getDocumentNumber());
0166:                    coinDetail
0167:                            .setCashieringRecordSource(KFSConstants.CurrencyCoinSources.DEPOSITS);
0168:                    coinDetail
0169:                            .setFinancialDocumentTypeCode(CashieringTransaction.DETAIL_DOCUMENT_TYPE);
0170:                    dform.setCoinDetail(coinDetail);
0171:                }
0172:
0173:                loadCashReceipts(dform);
0174:                loadUndepositedCashieringChecks(dform);
0175:            }
0176:
0177:            /**
0178:             * Loads the CashReceipt information, re/setting the related form fields
0179:             * 
0180:             * @param dform
0181:             */
0182:            private void loadCashReceipts(DepositWizardForm dform) {
0183:                List verifiedReceipts = SpringContext.getBean(
0184:                        CashReceiptService.class).getCashReceipts(
0185:                        dform.getCashDrawerVerificationUnit(),
0186:                        KFSConstants.DocumentStatusCodes.CashReceipt.VERIFIED);
0187:                dform.setDepositableCashReceipts(new ArrayList());
0188:                dform
0189:                        .setCheckFreeCashReceipts(new ArrayList<CashReceiptDocument>());
0190:
0191:                // prepopulate DepositWizardHelpers
0192:                int index = 0;
0193:                for (Iterator i = verifiedReceipts.iterator(); i.hasNext();) {
0194:                    CashReceiptDocument receipt = (CashReceiptDocument) i
0195:                            .next();
0196:                    if (receipt.getCheckCount() == 0
0197:                            && receipt.getTotalCheckAmount().equals(
0198:                                    KualiDecimal.ZERO)) {
0199:                        dform.getCheckFreeCashReceipts().add(receipt);
0200:                    } else {
0201:                        dform.getDepositableCashReceipts().add(receipt);
0202:                        DepositWizardHelper d = dform
0203:                                .getDepositWizardHelper(index++);
0204:                        d.setCashReceiptCreateDate(receipt.getDocumentHeader()
0205:                                .getWorkflowDocument().getCreateDate());
0206:                    }
0207:                }
0208:            }
0209:
0210:            /**
0211:             * This loads any cashiering checks which have not yet been deposited into the DepositWizardForm
0212:             * 
0213:             * @param dform a form to load undeposited checks into
0214:             */
0215:            private void loadUndepositedCashieringChecks(DepositWizardForm dform) {
0216:                List<Check> cashieringChecks = SpringContext.getBean(
0217:                        CashManagementService.class)
0218:                        .selectUndepositedCashieringChecks(
0219:                                dform.getCashManagementDocId());
0220:                dform.setDepositableCashieringChecks(cashieringChecks);
0221:            }
0222:
0223:            /**
0224:             * Reloads the CashReceipts, leaving everything else unchanged
0225:             * 
0226:             * @see org.kuali.core.web.struts.action.KualiAction#refresh(org.apache.struts.action.ActionMapping,
0227:             *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
0228:             */
0229:            @Override
0230:            public ActionForward refresh(ActionMapping mapping,
0231:                    ActionForm form, HttpServletRequest request,
0232:                    HttpServletResponse response) throws Exception {
0233:                loadCashReceipts((DepositWizardForm) form);
0234:                loadUndepositedCashieringChecks((DepositWizardForm) form);
0235:
0236:                return super .refresh(mapping, form, request, response);
0237:            }
0238:
0239:            /**
0240:             * This method is the starting point for the deposit document wizard.
0241:             * 
0242:             * @param mapping
0243:             * @param form
0244:             * @param request
0245:             * @param response
0246:             * @return ActionForward
0247:             * @throws Exception
0248:             */
0249:            public ActionForward startWizard(ActionMapping mapping,
0250:                    ActionForm form, HttpServletRequest request,
0251:                    HttpServletResponse response) throws Exception {
0252:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
0253:            }
0254:
0255:            /**
0256:             * This method is the action method for creating the new deposit document from the information chosen by the user in the UI.
0257:             * 
0258:             * @param mapping
0259:             * @param form
0260:             * @param request
0261:             * @param response
0262:             * @return ActionForward
0263:             */
0264:            public ActionForward createDeposit(ActionMapping mapping,
0265:                    ActionForm form, HttpServletRequest request,
0266:                    HttpServletResponse response) {
0267:                ActionForward dest = mapping
0268:                        .findForward(KFSConstants.MAPPING_BASIC);
0269:
0270:                DepositWizardForm dform = (DepositWizardForm) form;
0271:                BusinessObjectService boService = SpringContext
0272:                        .getBean(BusinessObjectService.class);
0273:
0274:                // validate Bank and BankAccount
0275:                boolean hasBankAccountNumber = false;
0276:                String bankAccountNumber = dform.getBankAccountNumber();
0277:                if (StringUtils.isBlank(bankAccountNumber)) {
0278:                    GlobalVariables
0279:                            .getErrorMap()
0280:                            .putError(
0281:                                    KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0282:                                    KFSKeyConstants.Deposit.ERROR_MISSING_BANKACCOUNT);
0283:                } else {
0284:                    hasBankAccountNumber = true;
0285:                }
0286:
0287:                String bankCode = dform.getBankCode();
0288:                if (StringUtils.isBlank(bankCode)) {
0289:                    GlobalVariables
0290:                            .getErrorMap()
0291:                            .putError(
0292:                                    KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0293:                                    KFSKeyConstants.Deposit.ERROR_MISSING_BANK);
0294:                } else {
0295:                    Map keyMap = new HashMap();
0296:                    keyMap.put("financialDocumentBankCode", bankCode);
0297:
0298:                    Bank bank = (Bank) boService.findByPrimaryKey(Bank.class,
0299:                            keyMap);
0300:                    if (bank == null) {
0301:                        GlobalVariables
0302:                                .getErrorMap()
0303:                                .putError(
0304:                                        KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0305:                                        KFSKeyConstants.Deposit.ERROR_UNKNOWN_BANK,
0306:                                        bankCode);
0307:                    } else {
0308:                        dform.setBank(bank);
0309:
0310:                        if (hasBankAccountNumber) {
0311:                            keyMap.put("finDocumentBankAccountNumber",
0312:                                    bankAccountNumber);
0313:
0314:                            BankAccount bankAccount = (BankAccount) boService
0315:                                    .findByPrimaryKey(BankAccount.class, keyMap);
0316:                            if (bankAccount == null) {
0317:                                String[] msgParams = { bankAccountNumber,
0318:                                        bankCode };
0319:                                GlobalVariables
0320:                                        .getErrorMap()
0321:                                        .putError(
0322:                                                KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0323:                                                KFSKeyConstants.Deposit.ERROR_UNKNOWN_BANKACCOUNT,
0324:                                                msgParams);
0325:                            } else {
0326:                                dform.setBankAccount(bankAccount);
0327:                            }
0328:                        }
0329:                    }
0330:                }
0331:
0332:                boolean depositIsFinal = (StringUtils.equals(dform
0333:                        .getDepositTypeCode(),
0334:                        KFSConstants.DepositConstants.DEPOSIT_TYPE_FINAL));
0335:
0336:                // validate cashReceipt selection
0337:                List selectedIds = new ArrayList();
0338:                for (Iterator i = dform.getDepositWizardHelpers().iterator(); i
0339:                        .hasNext();) {
0340:                    String checkValue = ((DepositWizardHelper) i.next())
0341:                            .getSelectedValue();
0342:
0343:                    if (StringUtils.isNotBlank(checkValue)
0344:                            && !checkValue
0345:                                    .equals(KFSConstants.ParameterValues.NO)) {
0346:                        // removed apparently-unnecessary test for !checkValue.equals(KFSConstants.ParameterValues.YES)
0347:                        selectedIds.add(checkValue);
0348:                    }
0349:                }
0350:
0351:                if (depositIsFinal) {
0352:                    // add check free cash receipts to the selected receipts so they are automatically deposited
0353:                    dform
0354:                            .setCheckFreeCashReceipts(new ArrayList<CashReceiptDocument>());
0355:                    for (Object crDocObj : SpringContext
0356:                            .getBean(CashReceiptService.class)
0357:                            .getCashReceipts(
0358:                                    dform.getCashDrawerVerificationUnit(),
0359:                                    KFSConstants.DocumentStatusCodes.CashReceipt.VERIFIED)) {
0360:                        CashReceiptDocument crDoc = (CashReceiptDocument) crDocObj;
0361:                        if (crDoc.getCheckCount() == 0) {
0362:                            // it's check free; it is automatically deposited as part of the final deposit
0363:                            selectedIds.add(crDoc.getDocumentNumber());
0364:                            dform.getCheckFreeCashReceipts().add(crDoc);
0365:                        }
0366:                    }
0367:                }
0368:
0369:                // make a list of cashiering checks to deposit
0370:                List<Integer> selectedCashieringChecks = new ArrayList<Integer>();
0371:                for (DepositWizardCashieringCheckHelper helper : dform
0372:                        .getDepositWizardCashieringCheckHelpers()) {
0373:                    if (helper.getSequenceId() != null
0374:                            && !helper.getSequenceId().equals(new Integer(-1))) {
0375:                        selectedCashieringChecks.add(helper.getSequenceId());
0376:                    }
0377:                }
0378:
0379:                if (selectedIds.isEmpty() && selectedCashieringChecks.isEmpty()) {
0380:                    GlobalVariables
0381:                            .getErrorMap()
0382:                            .putError(
0383:                                    KFSConstants.DepositConstants.DEPOSIT_WIZARD_CASHRECEIPT_ERROR,
0384:                                    KFSKeyConstants.Deposit.ERROR_NO_CASH_RECEIPTS_SELECTED);
0385:                }
0386:
0387:                //
0388:                // proceed, if possible
0389:                if (GlobalVariables.getErrorMap().isEmpty()) {
0390:                    try {
0391:                        // retrieve selected receipts
0392:                        List selectedReceipts = new ArrayList();
0393:                        if (selectedIds != null && !selectedIds.isEmpty()) {
0394:                            selectedReceipts = SpringContext.getBean(
0395:                                    DocumentService.class)
0396:                                    .getDocumentsByListOfDocumentHeaderIds(
0397:                                            CashReceiptDocument.class,
0398:                                            selectedIds);
0399:                        }
0400:
0401:                        if (depositIsFinal) {
0402:                            // have all verified CRs been deposited? If not, that's an error
0403:                            List verifiedReceipts = SpringContext
0404:                                    .getBean(CashReceiptService.class)
0405:                                    .getCashReceipts(
0406:                                            dform
0407:                                                    .getCashDrawerVerificationUnit(),
0408:                                            KFSConstants.DocumentStatusCodes.CashReceipt.VERIFIED);
0409:                            for (Object o : verifiedReceipts) {
0410:                                CashReceiptDocument crDoc = (CashReceiptDocument) o;
0411:                                if (!selectedReceipts.contains(crDoc)) {
0412:                                    GlobalVariables
0413:                                            .getErrorMap()
0414:                                            .putError(
0415:                                                    KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0416:                                                    KFSKeyConstants.Deposit.ERROR_NON_DEPOSITED_VERIFIED_CASH_RECEIPT,
0417:                                                    new String[] { crDoc
0418:                                                            .getDocumentNumber() });
0419:                                }
0420:                            }
0421:                            KualiDecimal toBeDepositedChecksTotal = new KualiDecimal(
0422:                                    0);
0423:                            // have we selected the rest of the undeposited checks?
0424:                            for (Check check : SpringContext.getBean(
0425:                                    CashManagementService.class)
0426:                                    .selectUndepositedCashieringChecks(
0427:                                            dform.getCashManagementDocId())) {
0428:                                if (!selectedCashieringChecks.contains(check
0429:                                        .getSequenceId())) {
0430:                                    GlobalVariables
0431:                                            .getErrorMap()
0432:                                            .putError(
0433:                                                    KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0434:                                                    KFSKeyConstants.Deposit.ERROR_CASHIERING_CHECK_MUST_BE_DEPOSITED,
0435:                                                    new String[] { check
0436:                                                            .getCheckNumber() });
0437:                                } else {
0438:                                    toBeDepositedChecksTotal = toBeDepositedChecksTotal
0439:                                            .add(check.getAmount());
0440:                                }
0441:                            }
0442:
0443:                            // does the cash drawer have enough currency and coin to fulfill the requested deposit?
0444:                            checkEnoughCurrencyForDeposit(dform);
0445:                            checkEnoughCoinForDeposit(dform);
0446:
0447:                            // does this deposit have currency and coin to match all currency and coin from CRs?
0448:                            List<CashReceiptDocument> interestingReceipts = SpringContext
0449:                                    .getBean(CashReceiptService.class)
0450:                                    .getCashReceipts(
0451:                                            dform
0452:                                                    .getCashDrawerVerificationUnit(),
0453:                                            new String[] {
0454:                                                    CashReceipt.VERIFIED,
0455:                                                    CashReceipt.INTERIM,
0456:                                                    CashReceipt.FINAL });
0457:                            CurrencyDetail currencyTotal = new CurrencyDetail();
0458:                            CoinDetail coinTotal = new CoinDetail();
0459:                            for (CashReceiptDocument receipt : interestingReceipts) {
0460:                                receipt.refreshCashDetails();
0461:                                if (receipt.getCurrencyDetail() != null) {
0462:                                    currencyTotal.add(receipt
0463:                                            .getCurrencyDetail());
0464:                                }
0465:                                if (receipt.getCoinDetail() != null) {
0466:                                    coinTotal.add(receipt.getCoinDetail());
0467:                                }
0468:                            }
0469:
0470:                            KualiDecimal cashReceiptCashTotal = currencyTotal
0471:                                    .getTotalAmount().add(
0472:                                            coinTotal.getTotalAmount());
0473:                            KualiDecimal depositedCashieringChecksTotal = SpringContext
0474:                                    .getBean(CashManagementService.class)
0475:                                    .calculateDepositedCheckTotal(
0476:                                            dform.getCashManagementDocId());
0477:                            // remove the cashiering checks amounts from the cash receipts total; cashiering checks act as if they were CR
0478:                            // currency/coin that gets deposited
0479:                            cashReceiptCashTotal = cashReceiptCashTotal
0480:                                    .subtract(depositedCashieringChecksTotal)
0481:                                    .subtract(toBeDepositedChecksTotal);
0482:                            KualiDecimal depositedCashTotal = dform
0483:                                    .getCurrencyDetail().getTotalAmount().add(
0484:                                            dform.getCoinDetail()
0485:                                                    .getTotalAmount());
0486:                            if (!cashReceiptCashTotal
0487:                                    .equals(depositedCashTotal)) {
0488:                                GlobalVariables
0489:                                        .getErrorMap()
0490:                                        .putError(
0491:                                                KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0492:                                                KFSKeyConstants.Deposit.ERROR_CASH_DEPOSIT_DID_NOT_BALANCE,
0493:                                                new String[] {
0494:                                                        depositedCashTotal
0495:                                                                .toString(),
0496:                                                        cashReceiptCashTotal
0497:                                                                .toString() });
0498:                            }
0499:                        }
0500:
0501:                        // proceed again...if possible
0502:                        if (GlobalVariables.getErrorMap().isEmpty()) {
0503:                            // retrieve CashManagementDocument
0504:                            String cashManagementDocId = dform
0505:                                    .getCashManagementDocId();
0506:                            CashManagementDocument cashManagementDoc = null;
0507:                            try {
0508:                                cashManagementDoc = (CashManagementDocument) SpringContext
0509:                                        .getBean(DocumentService.class)
0510:                                        .getByDocumentHeaderId(
0511:                                                cashManagementDocId);
0512:                                if (cashManagementDoc == null) {
0513:                                    throw new IllegalStateException(
0514:                                            "unable to find cashManagementDocument with id "
0515:                                                    + cashManagementDocId);
0516:                                }
0517:                            } catch (WorkflowException e) {
0518:                                throw new IllegalStateException(
0519:                                        "unable to retrieve cashManagementDocument with id "
0520:                                                + cashManagementDocId, e);
0521:                            }
0522:
0523:                            // create deposit
0524:                            String cmDocId = dform.getCashManagementDocId();
0525:
0526:                            CashManagementService cms = SpringContext
0527:                                    .getBean(CashManagementService.class);
0528:                            cms.addDeposit(cashManagementDoc, dform
0529:                                    .getDepositTicketNumber(), dform
0530:                                    .getBankAccount(), selectedReceipts,
0531:                                    selectedCashieringChecks, depositIsFinal);
0532:
0533:                            if (depositIsFinal) {
0534:                                // find the final deposit
0535:                                Deposit finalDeposit = findFinalDeposit(cashManagementDoc);
0536:                                // if the currency and coin details aren't empty, save them and remove them from the cash drawer
0537:                                if (dform.getCurrencyDetail() != null) {
0538:                                    // do we have enough currency to allow the deposit to leave the drawer?
0539:                                    SpringContext.getBean(
0540:                                            BusinessObjectService.class).save(
0541:                                            dform.getCurrencyDetail());
0542:                                    cashManagementDoc.getCashDrawer()
0543:                                            .removeCurrency(
0544:                                                    dform.getCurrencyDetail());
0545:                                    finalDeposit.setDepositAmount(finalDeposit
0546:                                            .getDepositAmount().add(
0547:                                                    dform.getCurrencyDetail()
0548:                                                            .getTotalAmount()));
0549:                                }
0550:                                if (dform.getCoinDetail() != null) {
0551:                                    // do we have enough coin to allow the deposit to leave the drawer?
0552:                                    SpringContext.getBean(
0553:                                            BusinessObjectService.class).save(
0554:                                            dform.getCoinDetail());
0555:                                    cashManagementDoc.getCashDrawer()
0556:                                            .removeCoin(dform.getCoinDetail());
0557:                                    finalDeposit.setDepositAmount(finalDeposit
0558:                                            .getDepositAmount().add(
0559:                                                    dform.getCoinDetail()
0560:                                                            .getTotalAmount()));
0561:                                }
0562:                                SpringContext.getBean(
0563:                                        BusinessObjectService.class).save(
0564:                                        cashManagementDoc.getCashDrawer());
0565:                            }
0566:
0567:                            // redirect to controlling CashManagementDocument
0568:                            dest = returnToSender(cashManagementDocId);
0569:                        }
0570:                    } catch (WorkflowException e) {
0571:                        throw new InfrastructureException(
0572:                                "unable to retrieve cashReceipts by documentId",
0573:                                e);
0574:                    }
0575:                }
0576:
0577:                return dest;
0578:            }
0579:
0580:            private Deposit findFinalDeposit(CashManagementDocument cmDoc) {
0581:                Deposit finalDeposit = null;
0582:                for (Deposit deposit : cmDoc.getDeposits()) {
0583:                    if (deposit.getDepositTypeCode().equals(
0584:                            KFSConstants.DepositConstants.DEPOSIT_TYPE_FINAL)) {
0585:                        finalDeposit = deposit;
0586:                        break;
0587:                    }
0588:                }
0589:                return finalDeposit;
0590:            }
0591:
0592:            /**
0593:             * Checks that the currency amount requested to be part of a deposit can be fulfilled by the amount of currency in the cash
0594:             * drawer
0595:             * 
0596:             * @param depositForm the deposit form we are checking against
0597:             * @param detail the currency detail to check against the drawer
0598:             * @return true if enough currency, false if otherwise
0599:             */
0600:            private boolean checkEnoughCurrencyForDeposit(
0601:                    DepositWizardForm depositForm) {
0602:                boolean success = true;
0603:                CurrencyDetail detail = depositForm.getCurrencyDetail();
0604:                if (detail != null) {
0605:                    // 1. get the cash drawer
0606:                    CashDrawer drawer = SpringContext.getBean(
0607:                            CashDrawerService.class).getByWorkgroupName(
0608:                            depositForm.getCashDrawerVerificationUnit(), false);
0609:                    // assumptions at this point:
0610:                    // 1. a cash drawer does exist for the unit
0611:                    // 2. we can ignore negative amounts, because if we have negative amounts, we're actually gaining money (and that will
0612:                    // happen with cashiering checks)
0613:                    if (detail.getFinancialDocumentHundredDollarAmount() != null
0614:                            && detail.getFinancialDocumentHundredDollarAmount()
0615:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0616:                        if (drawer.getFinancialDocumentHundredDollarAmount() == null
0617:                                || drawer
0618:                                        .getFinancialDocumentHundredDollarAmount()
0619:                                        .isLessThan(
0620:                                                detail
0621:                                                        .getFinancialDocumentHundredDollarAmount())) {
0622:                            GlobalVariables
0623:                                    .getErrorMap()
0624:                                    .putError(
0625:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0626:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0627:                                            new String[] {
0628:                                                    "hundred dollar amount",
0629:                                                    detail
0630:                                                            .getFinancialDocumentHundredDollarAmount()
0631:                                                            .toString(),
0632:                                                    drawer
0633:                                                            .getFinancialDocumentHundredDollarAmount()
0634:                                                            .toString() });
0635:                            success = false;
0636:                        }
0637:                    }
0638:                    if (detail.getFinancialDocumentFiftyDollarAmount() != null
0639:                            && detail.getFinancialDocumentFiftyDollarAmount()
0640:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0641:                        if (drawer.getFinancialDocumentFiftyDollarAmount() == null
0642:                                || drawer
0643:                                        .getFinancialDocumentFiftyDollarAmount()
0644:                                        .isLessThan(
0645:                                                detail
0646:                                                        .getFinancialDocumentFiftyDollarAmount())) {
0647:                            GlobalVariables
0648:                                    .getErrorMap()
0649:                                    .putError(
0650:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0651:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0652:                                            new String[] {
0653:                                                    "fifty dollar amount",
0654:                                                    detail
0655:                                                            .getFinancialDocumentFiftyDollarAmount()
0656:                                                            .toString(),
0657:                                                    drawer
0658:                                                            .getFinancialDocumentFiftyDollarAmount()
0659:                                                            .toString() });
0660:                            success = false;
0661:                        }
0662:                    }
0663:                    if (detail.getFinancialDocumentTwentyDollarAmount() != null
0664:                            && detail.getFinancialDocumentTwentyDollarAmount()
0665:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0666:                        if (drawer.getFinancialDocumentTwentyDollarAmount() == null
0667:                                || drawer
0668:                                        .getFinancialDocumentTwentyDollarAmount()
0669:                                        .isLessThan(
0670:                                                detail
0671:                                                        .getFinancialDocumentTwentyDollarAmount())) {
0672:                            GlobalVariables
0673:                                    .getErrorMap()
0674:                                    .putError(
0675:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0676:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0677:                                            new String[] {
0678:                                                    "twenty dollar amount",
0679:                                                    detail
0680:                                                            .getFinancialDocumentTwentyDollarAmount()
0681:                                                            .toString(),
0682:                                                    drawer
0683:                                                            .getFinancialDocumentTwentyDollarAmount()
0684:                                                            .toString() });
0685:                            success = false;
0686:                        }
0687:                    }
0688:                    if (detail.getFinancialDocumentTenDollarAmount() != null
0689:                            && detail.getFinancialDocumentTenDollarAmount()
0690:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0691:                        if (drawer.getFinancialDocumentTenDollarAmount() == null
0692:                                || drawer
0693:                                        .getFinancialDocumentTenDollarAmount()
0694:                                        .isLessThan(
0695:                                                detail
0696:                                                        .getFinancialDocumentTenDollarAmount())) {
0697:                            GlobalVariables
0698:                                    .getErrorMap()
0699:                                    .putError(
0700:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0701:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0702:                                            new String[] {
0703:                                                    "ten dollar amount",
0704:                                                    detail
0705:                                                            .getFinancialDocumentTenDollarAmount()
0706:                                                            .toString(),
0707:                                                    drawer
0708:                                                            .getFinancialDocumentTenDollarAmount()
0709:                                                            .toString() });
0710:                            success = false;
0711:                        }
0712:                    }
0713:                    if (detail.getFinancialDocumentFiveDollarAmount() != null
0714:                            && detail.getFinancialDocumentFiveDollarAmount()
0715:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0716:                        if (drawer.getFinancialDocumentFiveDollarAmount() == null
0717:                                || drawer
0718:                                        .getFinancialDocumentFiveDollarAmount()
0719:                                        .isLessThan(
0720:                                                detail
0721:                                                        .getFinancialDocumentFiveDollarAmount())) {
0722:                            GlobalVariables
0723:                                    .getErrorMap()
0724:                                    .putError(
0725:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0726:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0727:                                            new String[] {
0728:                                                    "five dollar amount",
0729:                                                    detail
0730:                                                            .getFinancialDocumentFiveDollarAmount()
0731:                                                            .toString(),
0732:                                                    drawer
0733:                                                            .getFinancialDocumentFiveDollarAmount()
0734:                                                            .toString() });
0735:                            success = false;
0736:                        }
0737:                    }
0738:                    if (detail.getFinancialDocumentTwoDollarAmount() != null
0739:                            && detail.getFinancialDocumentTwoDollarAmount()
0740:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0741:                        if (drawer.getFinancialDocumentTwoDollarAmount() == null
0742:                                || drawer
0743:                                        .getFinancialDocumentTwoDollarAmount()
0744:                                        .isLessThan(
0745:                                                detail
0746:                                                        .getFinancialDocumentTwoDollarAmount())) {
0747:                            GlobalVariables
0748:                                    .getErrorMap()
0749:                                    .putError(
0750:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0751:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0752:                                            new String[] {
0753:                                                    "two dollar amount",
0754:                                                    detail
0755:                                                            .getFinancialDocumentTwoDollarAmount()
0756:                                                            .toString(),
0757:                                                    drawer
0758:                                                            .getFinancialDocumentTwoDollarAmount()
0759:                                                            .toString() });
0760:                            success = false;
0761:                        }
0762:                    }
0763:                    if (detail.getFinancialDocumentOneDollarAmount() != null
0764:                            && detail.getFinancialDocumentOneDollarAmount()
0765:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0766:                        if (drawer.getFinancialDocumentOneDollarAmount() == null
0767:                                || drawer
0768:                                        .getFinancialDocumentOneDollarAmount()
0769:                                        .isLessThan(
0770:                                                detail
0771:                                                        .getFinancialDocumentOneDollarAmount())) {
0772:                            GlobalVariables
0773:                                    .getErrorMap()
0774:                                    .putError(
0775:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0776:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0777:                                            new String[] {
0778:                                                    "one dollar amount",
0779:                                                    detail
0780:                                                            .getFinancialDocumentOneDollarAmount()
0781:                                                            .toString(),
0782:                                                    drawer
0783:                                                            .getFinancialDocumentOneDollarAmount()
0784:                                                            .toString() });
0785:                            success = false;
0786:                        }
0787:                    }
0788:                    if (detail.getFinancialDocumentOtherDollarAmount() != null
0789:                            && detail.getFinancialDocumentOtherDollarAmount()
0790:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0791:                        if (drawer.getFinancialDocumentOtherDollarAmount() == null
0792:                                || drawer
0793:                                        .getFinancialDocumentOtherDollarAmount()
0794:                                        .isLessThan(
0795:                                                detail
0796:                                                        .getFinancialDocumentOtherDollarAmount())) {
0797:                            GlobalVariables
0798:                                    .getErrorMap()
0799:                                    .putError(
0800:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0801:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0802:                                            new String[] {
0803:                                                    "other dollar amount",
0804:                                                    detail
0805:                                                            .getFinancialDocumentOtherDollarAmount()
0806:                                                            .toString(),
0807:                                                    drawer
0808:                                                            .getFinancialDocumentOtherDollarAmount()
0809:                                                            .toString() });
0810:                            success = false;
0811:                        }
0812:                    }
0813:                }
0814:                return success;
0815:            }
0816:
0817:            /**
0818:             * Checks that the coin amount requested by the deposit does not exceed the amount actually in the drawer
0819:             * 
0820:             * @param depositForm the deposit form we are checking against
0821:             * @param detail the coin detail to check against the drawer
0822:             * @return true if there is enough coin, false if otherwise
0823:             */
0824:            public boolean checkEnoughCoinForDeposit(
0825:                    DepositWizardForm depositForm) {
0826:                boolean success = true;
0827:                CoinDetail detail = depositForm.getCoinDetail();
0828:                if (detail != null) {
0829:                    // 1. get the cash drawer
0830:                    CashDrawer drawer = SpringContext.getBean(
0831:                            CashDrawerService.class).getByWorkgroupName(
0832:                            depositForm.getCashDrawerVerificationUnit(), false);
0833:                    // assumptions at this point:
0834:                    // 1. a cash drawer does exist for the unit
0835:                    // 2. we can ignore negative amounts, because if we have negative amounts, we're actually gaining money (and that will
0836:                    // happen with cashiering checks)
0837:                    if (detail.getFinancialDocumentHundredCentAmount() != null
0838:                            && detail.getFinancialDocumentHundredCentAmount()
0839:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0840:                        if (drawer.getFinancialDocumentHundredCentAmount() == null
0841:                                || drawer
0842:                                        .getFinancialDocumentHundredCentAmount()
0843:                                        .isLessThan(
0844:                                                detail
0845:                                                        .getFinancialDocumentHundredCentAmount())) {
0846:                            GlobalVariables
0847:                                    .getErrorMap()
0848:                                    .putError(
0849:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0850:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0851:                                            new String[] {
0852:                                                    "hundred cent amount",
0853:                                                    detail
0854:                                                            .getFinancialDocumentHundredCentAmount()
0855:                                                            .toString(),
0856:                                                    drawer
0857:                                                            .getFinancialDocumentHundredCentAmount()
0858:                                                            .toString() });
0859:                            success = false;
0860:                        }
0861:                    }
0862:                    if (detail.getFinancialDocumentFiftyCentAmount() != null
0863:                            && detail.getFinancialDocumentFiftyCentAmount()
0864:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0865:                        if (drawer.getFinancialDocumentFiftyCentAmount() == null
0866:                                || drawer
0867:                                        .getFinancialDocumentFiftyCentAmount()
0868:                                        .isLessThan(
0869:                                                detail
0870:                                                        .getFinancialDocumentFiftyCentAmount())) {
0871:                            GlobalVariables
0872:                                    .getErrorMap()
0873:                                    .putError(
0874:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0875:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0876:                                            new String[] {
0877:                                                    "fifty cent amount",
0878:                                                    detail
0879:                                                            .getFinancialDocumentFiftyCentAmount()
0880:                                                            .toString(),
0881:                                                    drawer
0882:                                                            .getFinancialDocumentFiftyCentAmount()
0883:                                                            .toString() });
0884:                            success = false;
0885:                        }
0886:                    }
0887:                    if (detail.getFinancialDocumentTwentyFiveCentAmount() != null
0888:                            && detail
0889:                                    .getFinancialDocumentTwentyFiveCentAmount()
0890:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0891:                        if (drawer.getFinancialDocumentTwentyFiveCentAmount() == null
0892:                                || drawer
0893:                                        .getFinancialDocumentTwentyFiveCentAmount()
0894:                                        .isLessThan(
0895:                                                detail
0896:                                                        .getFinancialDocumentTwentyFiveCentAmount())) {
0897:                            GlobalVariables
0898:                                    .getErrorMap()
0899:                                    .putError(
0900:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0901:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0902:                                            new String[] {
0903:                                                    "twenty five cent amount",
0904:                                                    detail
0905:                                                            .getFinancialDocumentTwentyFiveCentAmount()
0906:                                                            .toString(),
0907:                                                    drawer
0908:                                                            .getFinancialDocumentTwentyFiveCentAmount()
0909:                                                            .toString() });
0910:                            success = false;
0911:                        }
0912:                    }
0913:                    if (detail.getFinancialDocumentTenCentAmount() != null
0914:                            && detail.getFinancialDocumentTenCentAmount()
0915:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0916:                        if (drawer.getFinancialDocumentTenCentAmount() == null
0917:                                || drawer
0918:                                        .getFinancialDocumentTenCentAmount()
0919:                                        .isLessThan(
0920:                                                detail
0921:                                                        .getFinancialDocumentTenCentAmount())) {
0922:                            GlobalVariables
0923:                                    .getErrorMap()
0924:                                    .putError(
0925:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0926:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0927:                                            new String[] {
0928:                                                    "ten cent amount",
0929:                                                    detail
0930:                                                            .getFinancialDocumentTenCentAmount()
0931:                                                            .toString(),
0932:                                                    drawer
0933:                                                            .getFinancialDocumentTenCentAmount()
0934:                                                            .toString() });
0935:                            success = false;
0936:                        }
0937:                    }
0938:                    if (detail.getFinancialDocumentFiveCentAmount() != null
0939:                            && detail.getFinancialDocumentFiveCentAmount()
0940:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0941:                        if (drawer.getFinancialDocumentFiveCentAmount() == null
0942:                                || drawer
0943:                                        .getFinancialDocumentFiveCentAmount()
0944:                                        .isLessThan(
0945:                                                detail
0946:                                                        .getFinancialDocumentFiveCentAmount())) {
0947:                            GlobalVariables
0948:                                    .getErrorMap()
0949:                                    .putError(
0950:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0951:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0952:                                            new String[] {
0953:                                                    "five cent amount",
0954:                                                    detail
0955:                                                            .getFinancialDocumentFiveCentAmount()
0956:                                                            .toString(),
0957:                                                    drawer
0958:                                                            .getFinancialDocumentFiveCentAmount()
0959:                                                            .toString() });
0960:                            success = false;
0961:                        }
0962:                    }
0963:                    if (detail.getFinancialDocumentOneCentAmount() != null
0964:                            && detail.getFinancialDocumentOneCentAmount()
0965:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0966:                        if (drawer.getFinancialDocumentOneCentAmount() == null
0967:                                || drawer
0968:                                        .getFinancialDocumentOneCentAmount()
0969:                                        .isLessThan(
0970:                                                detail
0971:                                                        .getFinancialDocumentOneCentAmount())) {
0972:                            GlobalVariables
0973:                                    .getErrorMap()
0974:                                    .putError(
0975:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
0976:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
0977:                                            new String[] {
0978:                                                    "one cent amount",
0979:                                                    detail
0980:                                                            .getFinancialDocumentOneCentAmount()
0981:                                                            .toString(),
0982:                                                    drawer
0983:                                                            .getFinancialDocumentOneCentAmount()
0984:                                                            .toString() });
0985:                            success = false;
0986:                        }
0987:                    }
0988:                    if (detail.getFinancialDocumentOtherCentAmount() != null
0989:                            && detail.getFinancialDocumentOtherCentAmount()
0990:                                    .isGreaterThan(KualiDecimal.ZERO)) {
0991:                        if (drawer.getFinancialDocumentOtherCentAmount() == null
0992:                                || drawer
0993:                                        .getFinancialDocumentOtherCentAmount()
0994:                                        .isLessThan(
0995:                                                detail
0996:                                                        .getFinancialDocumentOtherCentAmount())) {
0997:                            GlobalVariables
0998:                                    .getErrorMap()
0999:                                    .putError(
1000:                                            KFSConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR,
1001:                                            KFSKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT,
1002:                                            new String[] {
1003:                                                    "other cent amount",
1004:                                                    detail
1005:                                                            .getFinancialDocumentOtherCentAmount()
1006:                                                            .toString(),
1007:                                                    drawer
1008:                                                            .getFinancialDocumentOtherCentAmount()
1009:                                                            .toString() });
1010:                            success = false;
1011:                        }
1012:                    }
1013:                }
1014:                return success;
1015:            }
1016:
1017:            /**
1018:             * This method handles canceling (closing) the deposit wizard.
1019:             * 
1020:             * @param mapping
1021:             * @param form
1022:             * @param request
1023:             * @param response
1024:             * @return ActionForward
1025:             * @throws Exception
1026:             */
1027:            public ActionForward cancel(ActionMapping mapping, ActionForm form,
1028:                    HttpServletRequest request, HttpServletResponse response)
1029:                    throws Exception {
1030:                DepositWizardForm dform = (DepositWizardForm) form;
1031:
1032:                ActionForward dest = returnToSender(dform
1033:                        .getCashManagementDocId());
1034:                return dest;
1035:            }
1036:
1037:            /**
1038:             * @param cmDocId
1039:             * @return ActionForward which will redirect the user to the docSearchDisplay for the CashManagementDocument with the given
1040:             *         documentId
1041:             */
1042:            private ActionForward returnToSender(String cmDocId) {
1043:                String cmDocTypeName = SpringContext.getBean(
1044:                        DocumentTypeService.class).getDocumentTypeNameByClass(
1045:                        CashManagementDocument.class);
1046:
1047:                Properties params = new Properties();
1048:                params.setProperty("methodToCall", "docHandler");
1049:                params.setProperty("command", "displayDocSearchView");
1050:                params.setProperty("docId", cmDocId);
1051:
1052:                String cmActionUrl = UrlFactory.parameterizeUrl(
1053:                        KFSConstants.CASH_MANAGEMENT_DOCUMENT_ACTION, params);
1054:
1055:                return new ActionForward(cmActionUrl, true);
1056:            }
1057:        }
ww___w_.___jav_a___2___s___.__c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.