001/* 002 * Copyright 2006 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.fp.document.web.struts; 017 018import java.sql.Timestamp; 019import java.util.ArrayList; 020import java.util.HashMap; 021import java.util.Iterator; 022import java.util.List; 023import java.util.Map; 024import java.util.Properties; 025import java.util.Set; 026 027import javax.servlet.http.HttpServletRequest; 028import javax.servlet.http.HttpServletResponse; 029 030import org.apache.commons.lang.StringUtils; 031import org.apache.struts.action.ActionForm; 032import org.apache.struts.action.ActionForward; 033import org.apache.struts.action.ActionMapping; 034import org.kuali.ole.fp.businessobject.CashDrawer; 035import org.kuali.ole.fp.businessobject.CashieringTransaction; 036import org.kuali.ole.fp.businessobject.Check; 037import org.kuali.ole.fp.businessobject.CoinDetail; 038import org.kuali.ole.fp.businessobject.CurrencyDetail; 039import org.kuali.ole.fp.businessobject.Deposit; 040import org.kuali.ole.fp.businessobject.DepositWizardCashieringCheckHelper; 041import org.kuali.ole.fp.businessobject.DepositWizardHelper; 042import org.kuali.ole.fp.businessobject.format.CashDrawerStatusCodeFormatter; 043import org.kuali.ole.fp.document.CashManagementDocument; 044import org.kuali.ole.fp.document.CashReceiptDocument; 045import org.kuali.ole.fp.document.service.CashManagementService; 046import org.kuali.ole.fp.document.service.CashReceiptService; 047import org.kuali.ole.fp.exception.CashDrawerStateException; 048import org.kuali.ole.fp.service.CashDrawerService; 049import org.kuali.ole.sys.OLEConstants; 050import org.kuali.ole.sys.OLEConstants.CashDrawerConstants; 051import org.kuali.ole.sys.OLEConstants.DocumentStatusCodes.CashReceipt; 052import org.kuali.ole.sys.OLEKeyConstants; 053import org.kuali.ole.sys.OLEPropertyConstants; 054import org.kuali.ole.sys.businessobject.Bank; 055import org.kuali.ole.sys.context.SpringContext; 056import org.kuali.ole.sys.document.datadictionary.FinancialSystemTransactionalDocumentEntry; 057import org.kuali.rice.core.api.datetime.DateTimeService; 058import org.kuali.rice.core.api.util.type.KualiDecimal; 059import org.kuali.rice.core.web.format.CurrencyFormatter; 060import org.kuali.rice.kew.api.exception.WorkflowException; 061import org.kuali.rice.kim.api.identity.Person; 062import org.kuali.rice.kns.document.authorization.DocumentAuthorizer; 063import org.kuali.rice.kns.document.authorization.TransactionalDocumentAuthorizer; 064import org.kuali.rice.kns.document.authorization.TransactionalDocumentPresentationController; 065import org.kuali.rice.kns.service.DataDictionaryService; 066import org.kuali.rice.kns.service.DocumentHelperService; 067import org.kuali.rice.kns.web.struts.action.KualiAction; 068import org.kuali.rice.krad.service.BusinessObjectService; 069import org.kuali.rice.krad.service.DocumentService; 070import org.kuali.rice.krad.util.GlobalVariables; 071import org.kuali.rice.krad.util.KRADConstants; 072import org.kuali.rice.krad.util.UrlFactory; 073 074/** 075 * This class handles actions for the deposit wizard, which is used to create deposits that bundle groupings of Cash Receipt 076 * documents. 077 */ 078public class DepositWizardAction extends KualiAction { 079 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DepositWizardAction.class); 080 private static final String CASH_MANAGEMENT_STATUS_PAGE = "/cashManagementStatus.do"; 081 082 /** 083 * Overrides the parent to validate the document state of the cashManagementDocument which will be updated and redisplayed after 084 * the DepositWizard builds and attaches the new Deposit. 085 * 086 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, 087 * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 088 */ 089 @Override 090 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 091 DepositWizardForm dwForm = (DepositWizardForm) form; 092 093 ActionForward dest = super.execute(mapping, form, request, response); 094 095 // check authorization manually, since the auth-check isn't inherited by this class 096 DocumentAuthorizer cmDocAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(OLEConstants.FinancialDocumentTypeCodes.CASH_MANAGEMENT); 097 Person luser = GlobalVariables.getUserSession().getPerson(); 098 cmDocAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.CASH_MANAGEMENT, luser); 099 100 // populate the outgoing form used by the JSP if it seems empty 101 String cmDocId = dwForm.getCashManagementDocId(); 102 if (StringUtils.isBlank(cmDocId)) { 103 cmDocId = request.getParameter("cmDocId"); 104 String depositTypeCode = request.getParameter("depositTypeCode"); 105 106 CashManagementDocument cmDoc = (CashManagementDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(cmDocId); 107 108 try { 109 initializeForm(dwForm, cmDoc, depositTypeCode); 110 } 111 catch (CashDrawerStateException cdse) { 112 dest = new ActionForward(UrlFactory.parameterizeUrl(CASH_MANAGEMENT_STATUS_PAGE, cdse.toProperties()), true); 113 } 114 } else { // for recalculation 115 loadCashReceipts(dwForm); 116 loadUndepositedCashieringChecks(dwForm); 117 if (dwForm.getTargetDepositAmount() == null) { 118 calculateTargetFinalDepositAmount(dwForm); 119 } 120 //loadEditModesAndDocumentActions(dwForm); 121 } 122 123 return dest; 124 } 125 126 /** 127 * Initializes the given form using the given values 128 * 129 * @param dform 130 * @param cmDoc 131 * @param depositTypeCode 132 */ 133 private void initializeForm(DepositWizardForm dform, CashManagementDocument cmDoc, String depositTypeCode) { 134 CashDrawer cd = SpringContext.getBean(CashDrawerService.class).getByCampusCode(cmDoc.getCampusCode()); 135 if (cd == null) { 136 throw new RuntimeException("No cash drawer exists for campus code " + cmDoc.getCampusCode() + "; please create on via the Cash Drawer Maintenance Document before attemping to create a CashManagementDocument for campus " + cmDoc.getCampusCode()); 137 } 138 if (!cd.isOpen()) { 139 CashDrawerStatusCodeFormatter f = new CashDrawerStatusCodeFormatter(); 140 141 String cmDocId = cmDoc.getDocumentNumber(); 142 String currentState = cd.getStatusCode(); 143 144 throw new CashDrawerStateException(cmDoc.getCampusCode(), cmDocId, (String) f.format(CashDrawerConstants.STATUS_OPEN), (String) f.format(cd.getStatusCode())); 145 } 146 147 dform.setCashManagementDocId(cmDoc.getDocumentNumber()); 148 dform.setCashDrawerCampusCode(cmDoc.getCampusCode()); 149 150 dform.setDepositTypeCode(depositTypeCode); 151 152 if (depositTypeCode.equals(OLEConstants.DocumentStatusCodes.CashReceipt.FINAL)) { 153 // hey, we're the magical final deposit. We get currency and coin details! 154 CurrencyDetail currencyDetail = new CurrencyDetail(); 155 currencyDetail.setDocumentNumber(cmDoc.getDocumentNumber()); 156 currencyDetail.setCashieringStatus(OLEConstants.CurrencyCoinSources.DEPOSITS); 157 currencyDetail.setFinancialDocumentTypeCode(CashieringTransaction.DETAIL_DOCUMENT_TYPE); 158 dform.setCurrencyDetail(currencyDetail); 159 160 CoinDetail coinDetail = new CoinDetail(); 161 coinDetail.setDocumentNumber(cmDoc.getDocumentNumber()); 162 coinDetail.setCashieringStatus(OLEConstants.CurrencyCoinSources.DEPOSITS); 163 coinDetail.setFinancialDocumentTypeCode(CashieringTransaction.DETAIL_DOCUMENT_TYPE); 164 dform.setCoinDetail(coinDetail); 165 } 166 167 loadCashReceipts(dform); 168 loadUndepositedCashieringChecks(dform); 169 if (dform.isDepositFinal() && dform.getTargetDepositAmount() == null) { 170 calculateTargetFinalDepositAmount(dform); 171 } 172 loadEditModesAndDocumentActions(dform); 173 } 174 175 /** 176 * Loads the CashReceipt information, re/setting the related form fields 177 * 178 * @param dform 179 */ 180 private void loadCashReceipts(DepositWizardForm dform) { 181 List<CashReceiptDocument> verifiedReceipts = SpringContext.getBean(CashReceiptService.class).getCashReceipts(dform.getCashDrawerCampusCode(), new String[] { CashReceipt.VERIFIED, CashReceipt.INTERIM }); 182 dform.setDepositableCashReceipts(new ArrayList()); 183 dform.setCheckFreeCashReceipts(new ArrayList<CashReceiptDocument>()); 184 185 // prepopulate DepositWizardHelpers 186 int index = 0; 187 for (Iterator i = verifiedReceipts.iterator(); i.hasNext();) { 188 CashReceiptDocument receipt = (CashReceiptDocument) i.next(); 189 receipt.processAfterRetrieve(); // To populate Currency and Coin details 190 String docStatus = receipt.getFinancialSystemDocumentHeader().getFinancialDocumentStatusCode(); 191 if (docStatus.equalsIgnoreCase(CashReceipt.VERIFIED)) { // for interim or final deposit 192 if (receipt.getCheckCount() == 0 && receipt.getTotalConfirmedCheckAmount().equals(KualiDecimal.ZERO)) { 193 dform.getCheckFreeCashReceipts().add(receipt); 194 } 195 else { 196 dform.getDepositableCashReceipts().add(receipt); 197 DepositWizardHelper d = dform.getDepositWizardHelper(index++); 198 // KFSMI-5232 Jira fix. Convert the time stamp to SQL date format 199 Timestamp ts = new Timestamp(receipt.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()); 200 try { 201 d.setCashReceiptCreateDate(SpringContext.getBean(DateTimeService.class).convertToSqlDate(ts)); 202 } 203 catch (Exception e) { 204 205 } 206 } 207 } 208 else if (docStatus.equalsIgnoreCase(CashReceipt.INTERIM)) { // for final deposit 209 // checks are already deposited but there are cash to be deposited 210 if (receipt.getTotalConfirmedCashAmount().isGreaterThan(KualiDecimal.ZERO)) { 211 dform.getCheckFreeCashReceipts().add(receipt); 212 } 213 } 214 dform.addCashReceiptToChecks(receipt); 215 } 216 } 217 218 /** 219 * Loads cashiering transactions for final deposit target amount 220 * @param dwform 221 */ 222 private void calculateTargetFinalDepositAmount(DepositWizardForm dwform) { 223 final CashReceiptService cashReceiptService = SpringContext.getBean(CashReceiptService.class); 224 final List<CashReceiptDocument> interestingReceipts = 225 cashReceiptService.getCashReceipts(dwform.getCashDrawerCampusCode(), new String[] { CashReceipt.VERIFIED, CashReceipt.INTERIM, CashReceipt.FINAL }); 226 for (CashReceiptDocument crDoc : interestingReceipts) { 227 crDoc.refreshCashDetails(); 228 dwform.addCashReceiptToTargetTotal(crDoc); 229 } 230 231 final CashManagementService cashManagementService = SpringContext.getBean(CashManagementService.class); 232 KualiDecimal toBeDepositedChecksTotal = KualiDecimal.ZERO; 233 for (Check check : cashManagementService.selectUndepositedCashieringChecks(dwform.getCashManagementDocId())) { 234 toBeDepositedChecksTotal = toBeDepositedChecksTotal.add(check.getAmount()); 235 } 236 // since final, include deposited checks as well (see OLECNTRB-160) 237 for (Check check : cashManagementService.selectDepositedCashieringChecks(dwform.getCashManagementDocId())) { 238 toBeDepositedChecksTotal = toBeDepositedChecksTotal.add(check.getAmount()); 239 } 240 dwform.addCashieringTransactionToTargetTotal(toBeDepositedChecksTotal); 241 } 242 243 /** 244 * This loads any cashiering checks which have not yet been deposited into the DepositWizardForm 245 * 246 * @param dform a form to load undeposited checks into 247 */ 248 private void loadUndepositedCashieringChecks(DepositWizardForm dform) { 249 List<Check> cashieringChecks = SpringContext.getBean(CashManagementService.class).selectUndepositedCashieringChecks(dform.getCashManagementDocId()); 250 dform.setDepositableCashieringChecks(cashieringChecks); 251 } 252 253 private void loadEditModesAndDocumentActions(DepositWizardForm dform) { 254 final FinancialSystemTransactionalDocumentEntry ddEntry = getCashManagementDataDictionaryEntry(); 255 final TransactionalDocumentPresentationController presentationController = getCashManagementPresentationController(ddEntry); 256 final TransactionalDocumentAuthorizer docAuthorizer = getCashManagementDocumentAuthorizer(ddEntry); 257 258 dform.setEditingMode(retrieveEditingModes(dform.getCashManagementDocId(), presentationController, docAuthorizer)); 259 dform.setDocumentActions(retrieveDocumentActions(dform.getCashManagementDocId(), presentationController, docAuthorizer)); 260 } 261 262 /** 263 * @return the class of the cash management document 264 */ 265 protected String getCashManagementDocumentTypeName() { 266 return "CMD"; 267 } 268 269 /** 270 * @return the data dictionary entry for the cash management class 271 */ 272 private FinancialSystemTransactionalDocumentEntry getCashManagementDataDictionaryEntry() { 273 final DataDictionaryService ddService = SpringContext.getBean(DataDictionaryService.class); 274 return (FinancialSystemTransactionalDocumentEntry)ddService.getDataDictionary().getDocumentEntry(getCashManagementDocumentTypeName()); 275 } 276 277 /** 278 * Returns an instance of the document presentation controller for the cash management class 279 * @param cashManagementEntry the data dictionary entry for the cash management document 280 * @return an instance of the proper document presentation controller 281 */ 282 private TransactionalDocumentPresentationController getCashManagementPresentationController(FinancialSystemTransactionalDocumentEntry cashManagementEntry) { 283 final Class presentationControllerClass = cashManagementEntry.getDocumentPresentationControllerClass(); 284 TransactionalDocumentPresentationController presentationController = null; 285 try { 286 presentationController = (TransactionalDocumentPresentationController)presentationControllerClass.newInstance(); 287 } 288 catch (InstantiationException ie) { 289 throw new RuntimeException("Could not instantiate cash management presentation controller of class " + presentationControllerClass.getName(), ie); 290 } 291 catch (IllegalAccessException iae) { 292 throw new RuntimeException("Could not instantiate cash management presentation controller of class " + presentationControllerClass.getName(), iae); 293 } 294 return presentationController; 295 } 296 297 /** 298 * Returns an instance of the document authorizer for the cash management class 299 * @param cashManagementEntry the data dictionary entry for the cash management document 300 * @return an instance of the proper document authorizer 301 */ 302 private TransactionalDocumentAuthorizer getCashManagementDocumentAuthorizer(FinancialSystemTransactionalDocumentEntry cashManagementEntry) { 303 final Class docAuthorizerClass = cashManagementEntry.getDocumentAuthorizerClass(); 304 TransactionalDocumentAuthorizer docAuthorizer = null; 305 try { 306 docAuthorizer = (TransactionalDocumentAuthorizer)docAuthorizerClass.newInstance(); 307 } 308 catch (InstantiationException ie) { 309 throw new RuntimeException("Could not instantiate cash management document authorizer of class " + docAuthorizerClass.getName(), ie); 310 } 311 catch (IllegalAccessException iae) { 312 throw new RuntimeException("Could not instantiate cash management document authorizer of class " + docAuthorizerClass.getName(), iae); 313 } 314 return docAuthorizer; 315 } 316 317 /** 318 * Retrieves the edit modes for the given cash management document 319 * @param cashManagementDocId the id of the cash management document to check 320 * @param presentationController the presentation controller of the cash management document 321 * @param docAuthorizer the cash management document authorizer 322 * @return a Map of edit modes 323 */ 324 private Map retrieveEditingModes(String cashManagementDocId, TransactionalDocumentPresentationController presentationController, TransactionalDocumentAuthorizer docAuthorizer) { 325 Map editModeMap = null; 326 try { 327 final CashManagementDocument cmDoc = (CashManagementDocument)SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(cashManagementDocId); 328 Set<String> editModes = presentationController.getEditModes(cmDoc); 329 editModes = docAuthorizer.getEditModes(cmDoc, GlobalVariables.getUserSession().getPerson(), editModes); 330 editModeMap = convertSetToMap(editModes); 331 } 332 catch (WorkflowException we) { 333 throw new RuntimeException("Workflow exception while retrieving document " + cashManagementDocId, we); 334 } 335 return editModeMap; 336 } 337 338 /** 339 * Retrieves the document actions for the given cash management document 340 * @param cashManagementDocId the id of the cash management document to check 341 * @param presentationController the presentation controller of the cash management document 342 * @param docAuthorizer the cash management document authorizer 343 * @return a Map of document actions 344 */ 345 private Map retrieveDocumentActions(String cashManagementDocId, TransactionalDocumentPresentationController presentationController, TransactionalDocumentAuthorizer docAuthorizer) { 346 Map documentActionsMap = null; 347 try { 348 final CashManagementDocument cmDoc = (CashManagementDocument)SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(cashManagementDocId); 349 Set<String> documentActions = presentationController.getDocumentActions(cmDoc); 350 documentActions = docAuthorizer.getEditModes(cmDoc, GlobalVariables.getUserSession().getPerson(), documentActions); 351 documentActionsMap = convertSetToMap(documentActions); 352 } 353 catch (WorkflowException we) { 354 throw new RuntimeException("Workflow exception while retrieving document " + cashManagementDocId, we); 355 } 356 return documentActionsMap; 357 } 358 359 /** 360 * Converts a set into a map, where each value in the set becomes a key and each value becomes KNSConstants.KUALI_DEFAULT_TRUE_VALUE 361 * @param s a set 362 * @return a map 363 */ 364 protected Map convertSetToMap(Set s){ 365 Map map = new HashMap(); 366 Iterator i = s.iterator(); 367 while(i.hasNext()) { 368 Object key = i.next(); 369 map.put(key, KRADConstants.KUALI_DEFAULT_TRUE_VALUE); 370 } 371 return map; 372 } 373 374 /** 375 * Reloads the CashReceipts, leaving everything else unchanged 376 * 377 * @see org.kuali.rice.kns.web.struts.action.KualiAction#refresh(org.apache.struts.action.ActionMapping, 378 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 379 */ 380 @Override 381 public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 382 loadCashReceipts((DepositWizardForm) form); 383 loadUndepositedCashieringChecks((DepositWizardForm) form); 384 if (((DepositWizardForm) form).isDepositFinal() && ((DepositWizardForm)form).getTargetDepositAmount() == null) { 385 calculateTargetFinalDepositAmount((DepositWizardForm) form); 386 } 387 loadEditModesAndDocumentActions((DepositWizardForm) form); 388 389 return super.refresh(mapping, form, request, response); 390 } 391 392 /** 393 * This method is the starting point for the deposit document wizard. 394 * 395 * @param mapping 396 * @param form 397 * @param request 398 * @param response 399 * @return ActionForward 400 * @throws Exception 401 */ 402 public ActionForward startWizard(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 403 return mapping.findForward(OLEConstants.MAPPING_BASIC); 404 } 405 406 /** 407 * This method is the action method for creating the new deposit document from the information chosen by the user in the UI. 408 * 409 * @param mapping 410 * @param form 411 * @param request 412 * @param response 413 * @return ActionForward 414 */ 415 public ActionForward createDeposit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 416 ActionForward dest = mapping.findForward(OLEConstants.MAPPING_BASIC); 417 418 DepositWizardForm dform = (DepositWizardForm) form; 419 final BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class); 420 final CashReceiptService cashReceiptService = SpringContext.getBean(CashReceiptService.class); 421 final DocumentService documentService = SpringContext.getBean(DocumentService.class); 422 final CashManagementService cashManagementService = SpringContext.getBean(CashManagementService.class); 423 424 CurrencyFormatter formatter = new CurrencyFormatter(); 425 426 // reload edit modes and summary totals - just in case we have to return to the deposit wizard page 427 loadCashReceipts((DepositWizardForm) form); 428 if (((DepositWizardForm) form).isDepositFinal() && ((DepositWizardForm)form).getTargetDepositAmount() == null) { 429 calculateTargetFinalDepositAmount((DepositWizardForm) form); 430 } 431 loadEditModesAndDocumentActions(dform); 432 433 // validate Bank 434 String bankCode = dform.getBankCode(); 435 if (StringUtils.isBlank(bankCode)) { 436 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_MISSING_BANK); 437 } 438 else { 439 Map keyMap = new HashMap(); 440 keyMap.put(OLEPropertyConstants.BANK_CODE, bankCode); 441 442 Bank bank = boService.findByPrimaryKey(Bank.class, keyMap); 443 if (bank == null) { 444 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_UNKNOWN_BANK, bankCode); 445 } 446 else { 447 dform.setBank(bank); 448 } 449 } 450 451 boolean depositIsFinal = (StringUtils.equals(dform.getDepositTypeCode(), OLEConstants.DepositConstants.DEPOSIT_TYPE_FINAL)); 452 453 // validate cashReceipt selection 454 List selectedIds = new ArrayList(); 455 for (Iterator i = dform.getDepositWizardHelpers().iterator(); i.hasNext();) { 456 String checkValue = ((DepositWizardHelper) i.next()).getSelectedValue(); 457 458 if (StringUtils.isNotBlank(checkValue) && !checkValue.equals(OLEConstants.ParameterValues.NO)) { 459 // removed apparently-unnecessary test for !checkValue.equals(OLEConstants.ParameterValues.YES) 460 selectedIds.add(checkValue); 461 } 462 } 463 464 if (depositIsFinal) { 465 // add check free cash receipts to the selected receipts so they are automatically deposited 466 dform.setCheckFreeCashReceipts(new ArrayList<CashReceiptDocument>()); 467 List<CashReceiptDocument> cashReceipts = cashReceiptService.getCashReceipts(dform.getCashDrawerCampusCode(), new String[] {CashReceipt.VERIFIED, CashReceipt.INTERIM}); 468 for (Object crDocObj : cashReceipts) { 469 CashReceiptDocument crDoc = (CashReceiptDocument) crDocObj; 470 crDoc.refreshCashDetails(); 471 if (crDoc.getFinancialSystemDocumentHeader().getFinancialDocumentStatusCode().equals(CashReceipt.VERIFIED) && crDoc.getCheckCount() == 0) { 472 // it's check free; it is automatically deposited as part of the final deposit 473 selectedIds.add(crDoc.getDocumentNumber()); 474 dform.getCheckFreeCashReceipts().add(crDoc); 475 } 476 else if (crDoc.getFinancialSystemDocumentHeader().getFinancialDocumentStatusCode().equals(CashReceipt.INTERIM) && 477 crDoc.getGrandTotalConfirmedCashAmount().isGreaterThan(KualiDecimal.ZERO)) { 478// crDoc.setChecks(null); 479// crDoc.setConfirmedChecks(new ArrayList<Check>()); 480// crDoc.setTotalConfirmedCheckAmount(null); 481 selectedIds.add(crDoc.getDocumentNumber()); 482 dform.getCheckFreeCashReceipts().add(crDoc); 483 } 484 } 485 } 486 487 // make a list of cashiering checks to deposit 488 List<Integer> selectedCashieringChecks = new ArrayList<Integer>(); 489 for (DepositWizardCashieringCheckHelper helper : dform.getDepositWizardCashieringCheckHelpers()) { 490 if (helper.getSequenceId() != null && !helper.getSequenceId().equals(new Integer(-1))) { 491 selectedCashieringChecks.add(helper.getSequenceId()); 492 } 493 } 494 495 if (selectedIds.isEmpty() && selectedCashieringChecks.isEmpty()) { 496 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_CASHRECEIPT_ERROR, OLEKeyConstants.Deposit.ERROR_NO_CASH_RECEIPTS_SELECTED); 497 } 498 499 // 500 // proceed, if possible 501 if (GlobalVariables.getMessageMap().hasNoErrors()) { 502 try { 503 // retrieve selected receipts 504 List selectedReceipts = new ArrayList(); 505 if (selectedIds != null && !selectedIds.isEmpty()) { 506 selectedReceipts = documentService.getDocumentsByListOfDocumentHeaderIds(CashReceiptDocument.class, selectedIds); 507 } 508 509 if (depositIsFinal) { 510 // have all verified CRs been deposited? If not, that's an error 511// List verifiedReceipts = cashReceiptService.getCashReceipts(dform.getCashDrawerCampusCode(), new String[] {CashReceipt.VERIFIED, CashReceipt.INTERIM}); 512// for (Object o : verifiedReceipts) { 513// CashReceiptDocument crDoc = (CashReceiptDocument) o; 514// if (!selectedReceipts.contains(crDoc)) { 515// GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NON_DEPOSITED_VERIFIED_CASH_RECEIPT, new String[] { crDoc.getDocumentNumber() }); 516// } 517// } 518 KualiDecimal toBeDepositedChecksTotal = KualiDecimal.ZERO; 519 // have we selected the rest of the undeposited checks? 520 for (Check check : cashManagementService.selectUndepositedCashieringChecks(dform.getCashManagementDocId())) { 521 if (!selectedCashieringChecks.contains(check.getSequenceId())) { 522 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_CASHIERING_CHECK_MUST_BE_DEPOSITED, new String[] { check.getCheckNumber() }); 523 } 524 else { 525 toBeDepositedChecksTotal = toBeDepositedChecksTotal.add(check.getAmount()); 526 } 527 } 528 // add the rest of the deposited cashiering checks to the toBeDepositedChecksTotal 529 for (Check check : cashManagementService.selectDepositedCashieringChecks(dform.getCashManagementDocId())) { 530 toBeDepositedChecksTotal = toBeDepositedChecksTotal.add(check.getAmount()); 531 } 532 533 // does the cash drawer have enough currency and coin to fulfill the requested deposit? 534 checkEnoughCurrencyForDeposit(dform); 535 checkEnoughCoinForDeposit(dform); 536 537 // does this deposit have currency and coin to match all currency and coin from CRs? 538 List<CashReceiptDocument> interestingReceipts = cashReceiptService.getCashReceipts(dform.getCashDrawerCampusCode(), new String[] { CashReceipt.VERIFIED, CashReceipt.INTERIM, CashReceipt.FINAL }); 539 CurrencyDetail currencyTotal = new CurrencyDetail(); 540 CoinDetail coinTotal = new CoinDetail(); 541 for (CashReceiptDocument receipt : interestingReceipts) { 542 receipt.refreshCashDetails(); 543 if (receipt.getCurrencyDetail() != null) { 544 currencyTotal.add(receipt.getConfirmedCurrencyDetail()); 545 currencyTotal.subtract(receipt.getChangeCurrencyDetail()); 546 } 547 if (receipt.getCoinDetail() != null) { 548 coinTotal.add(receipt.getConfirmedCoinDetail()); 549 coinTotal.subtract(receipt.getChangeCoinDetail()); 550 } 551 } 552 553 KualiDecimal cashReceiptCashTotal = currencyTotal.getTotalAmount().add(coinTotal.getTotalAmount()); 554 // remove the cashiering checks amounts from the cash receipts total; cashiering checks act as if they were CR 555 // currency/coin that gets deposited 556 cashReceiptCashTotal = cashReceiptCashTotal.subtract(toBeDepositedChecksTotal); 557 KualiDecimal depositedCashTotal = dform.getCurrencyDetail().getTotalAmount().add(dform.getCoinDetail().getTotalAmount()); 558 if (!cashReceiptCashTotal.equals(depositedCashTotal)) { 559 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_CASH_DEPOSIT_DID_NOT_BALANCE, new String[] { formatter.format(depositedCashTotal).toString(), formatter.format(cashReceiptCashTotal).toString() }); 560 } 561 } 562 563 // proceed again...if possible 564 if (GlobalVariables.getMessageMap().hasNoErrors()) { 565 // retrieve CashManagementDocument 566 String cashManagementDocId = dform.getCashManagementDocId(); 567 CashManagementDocument cashManagementDoc = null; 568 try { 569 cashManagementDoc = (CashManagementDocument) documentService.getByDocumentHeaderId(cashManagementDocId); 570 if (cashManagementDoc == null) { 571 throw new IllegalStateException("unable to find cashManagementDocument with id " + cashManagementDocId); 572 } 573 } 574 catch (WorkflowException e) { 575 throw new IllegalStateException("unable to retrieve cashManagementDocument with id " + cashManagementDocId, e); 576 } 577 578 // create deposit 579 String cmDocId = dform.getCashManagementDocId(); 580 581 cashManagementService.addDeposit(cashManagementDoc, dform.getDepositTicketNumber(), dform.getBank(), selectedReceipts, selectedCashieringChecks, depositIsFinal); 582 583 if (depositIsFinal) { 584 // find the final deposit 585 Deposit finalDeposit = findFinalDeposit(cashManagementDoc); 586 // if the currency and coin details aren't empty, save them and remove them from the cash drawer 587 if (dform.getCurrencyDetail() != null) { 588 // do we have enough currency to allow the deposit to leave the drawer? 589 boService.save(dform.getCurrencyDetail()); 590 cashManagementDoc.getCashDrawer().removeCurrency(dform.getCurrencyDetail()); 591 finalDeposit.setDepositAmount(finalDeposit.getDepositAmount().add(dform.getCurrencyDetail().getTotalAmount())); 592 } 593 if (dform.getCoinDetail() != null) { 594 // do we have enough coin to allow the deposit to leave the drawer? 595 boService.save(dform.getCoinDetail()); 596 cashManagementDoc.getCashDrawer().removeCoin(dform.getCoinDetail()); 597 finalDeposit.setDepositAmount(finalDeposit.getDepositAmount().add(dform.getCoinDetail().getTotalAmount())); 598 } 599 boService.save(cashManagementDoc.getCashDrawer()); 600 boService.save(finalDeposit); 601 } 602 603 // redirect to controlling CashManagementDocument 604 dest = returnToSender(cashManagementDocId); 605 } 606 } 607 catch (WorkflowException e) { 608 throw new IllegalArgumentException("unable to retrieve cashReceipts by documentId", e); 609 } 610 } 611 612 return dest; 613 } 614 615 private Deposit findFinalDeposit(CashManagementDocument cmDoc) { 616 Deposit finalDeposit = null; 617 for (Deposit deposit : cmDoc.getDeposits()) { 618 if (deposit.getDepositTypeCode().equals(OLEConstants.DepositConstants.DEPOSIT_TYPE_FINAL)) { 619 finalDeposit = deposit; 620 break; 621 } 622 } 623 return finalDeposit; 624 } 625 626 /** 627 * Checks that the currency amount requested to be part of a deposit can be fulfilled by the amount of currency in the cash 628 * drawer 629 * 630 * @param depositForm the deposit form we are checking against 631 * @param detail the currency detail to check against the drawer 632 * @return true if enough currency, false if otherwise 633 */ 634 private boolean checkEnoughCurrencyForDeposit(DepositWizardForm depositForm) { 635 boolean success = true; 636 CurrencyDetail detail = depositForm.getCurrencyDetail(); 637 if (detail != null) { 638 // 1. get the cash drawer 639 CashDrawer drawer = SpringContext.getBean(CashDrawerService.class).getByCampusCode(depositForm.getCashDrawerCampusCode()); 640 // assumptions at this point: 641 // 1. a cash drawer does exist for the unit 642 // 2. we can ignore negative amounts, because if we have negative amounts, we're actually gaining money (and that will 643 // happen with cashiering checks) 644 CurrencyFormatter formatter = new CurrencyFormatter(); 645 if (detail.getFinancialDocumentHundredDollarAmount() != null && detail.getFinancialDocumentHundredDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 646 if (drawer.getFinancialDocumentHundredDollarAmount() == null || drawer.getFinancialDocumentHundredDollarAmount().isLessThan(detail.getFinancialDocumentHundredDollarAmount())) { 647 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "hundred dollar amount", formatter.format(detail.getFinancialDocumentHundredDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentHundredDollarAmount()).toString() }); 648 success = false; 649 } 650 } 651 if (detail.getFinancialDocumentFiftyDollarAmount() != null && detail.getFinancialDocumentFiftyDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 652 if (drawer.getFinancialDocumentFiftyDollarAmount() == null || drawer.getFinancialDocumentFiftyDollarAmount().isLessThan(detail.getFinancialDocumentFiftyDollarAmount())) { 653 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "fifty dollar amount", formatter.format(detail.getFinancialDocumentFiftyDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentFiftyDollarAmount()).toString() }); 654 success = false; 655 } 656 } 657 if (detail.getFinancialDocumentTwentyDollarAmount() != null && detail.getFinancialDocumentTwentyDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 658 if (drawer.getFinancialDocumentTwentyDollarAmount() == null || drawer.getFinancialDocumentTwentyDollarAmount().isLessThan(detail.getFinancialDocumentTwentyDollarAmount())) { 659 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "twenty dollar amount", formatter.format(detail.getFinancialDocumentTwentyDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentTwentyDollarAmount()).toString() }); 660 success = false; 661 } 662 } 663 if (detail.getFinancialDocumentTenDollarAmount() != null && detail.getFinancialDocumentTenDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 664 if (drawer.getFinancialDocumentTenDollarAmount() == null || drawer.getFinancialDocumentTenDollarAmount().isLessThan(detail.getFinancialDocumentTenDollarAmount())) { 665 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "ten dollar amount", formatter.format(detail.getFinancialDocumentTenDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentTenDollarAmount()).toString() }); 666 success = false; 667 } 668 } 669 if (detail.getFinancialDocumentFiveDollarAmount() != null && detail.getFinancialDocumentFiveDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 670 if (drawer.getFinancialDocumentFiveDollarAmount() == null || drawer.getFinancialDocumentFiveDollarAmount().isLessThan(detail.getFinancialDocumentFiveDollarAmount())) { 671 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "five dollar amount", formatter.format(detail.getFinancialDocumentFiveDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentFiveDollarAmount()).toString() }); 672 success = false; 673 } 674 } 675 if (detail.getFinancialDocumentTwoDollarAmount() != null && detail.getFinancialDocumentTwoDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 676 if (drawer.getFinancialDocumentTwoDollarAmount() == null || drawer.getFinancialDocumentTwoDollarAmount().isLessThan(detail.getFinancialDocumentTwoDollarAmount())) { 677 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "two dollar amount", formatter.format(detail.getFinancialDocumentTwoDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentTwoDollarAmount()).toString() }); 678 success = false; 679 } 680 } 681 if (detail.getFinancialDocumentOneDollarAmount() != null && detail.getFinancialDocumentOneDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 682 if (drawer.getFinancialDocumentOneDollarAmount() == null || drawer.getFinancialDocumentOneDollarAmount().isLessThan(detail.getFinancialDocumentOneDollarAmount())) { 683 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "one dollar amount", formatter.format(detail.getFinancialDocumentOneDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentOneDollarAmount()).toString() }); 684 success = false; 685 } 686 } 687 if (detail.getFinancialDocumentOtherDollarAmount() != null && detail.getFinancialDocumentOtherDollarAmount().isGreaterThan(KualiDecimal.ZERO)) { 688 if (drawer.getFinancialDocumentOtherDollarAmount() == null || drawer.getFinancialDocumentOtherDollarAmount().isLessThan(detail.getFinancialDocumentOtherDollarAmount())) { 689 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "other dollar amount", formatter.format(detail.getFinancialDocumentOtherDollarAmount()).toString(), formatter.format(drawer.getFinancialDocumentOtherDollarAmount()).toString() }); 690 success = false; 691 } 692 } 693 } 694 return success; 695 } 696 697 /** 698 * Checks that the coin amount requested by the deposit does not exceed the amount actually in the drawer 699 * 700 * @param depositForm the deposit form we are checking against 701 * @param detail the coin detail to check against the drawer 702 * @return true if there is enough coin, false if otherwise 703 */ 704 public boolean checkEnoughCoinForDeposit(DepositWizardForm depositForm) { 705 boolean success = true; 706 CoinDetail detail = depositForm.getCoinDetail(); 707 if (detail != null) { 708 // 1. get the cash drawer 709 CashDrawer drawer = SpringContext.getBean(CashDrawerService.class).getByCampusCode(depositForm.getCashDrawerCampusCode()); 710 // assumptions at this point: 711 // 1. a cash drawer does exist for the unit 712 // 2. we can ignore negative amounts, because if we have negative amounts, we're actually gaining money (and that will 713 // happen with cashiering checks) 714 CurrencyFormatter formatter = new CurrencyFormatter(); 715 if (detail.getFinancialDocumentHundredCentAmount() != null && detail.getFinancialDocumentHundredCentAmount().isGreaterThan(KualiDecimal.ZERO)) { 716 if (drawer.getFinancialDocumentHundredCentAmount() == null || drawer.getFinancialDocumentHundredCentAmount().isLessThan(detail.getFinancialDocumentHundredCentAmount())) { 717 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "hundred cent amount", formatter.format(detail.getFinancialDocumentHundredCentAmount()).toString(), formatter.format(drawer.getFinancialDocumentHundredCentAmount()).toString() }); 718 success = false; 719 } 720 } 721 if (detail.getFinancialDocumentFiftyCentAmount() != null && detail.getFinancialDocumentFiftyCentAmount().isGreaterThan(KualiDecimal.ZERO)) { 722 if (drawer.getFinancialDocumentFiftyCentAmount() == null || drawer.getFinancialDocumentFiftyCentAmount().isLessThan(detail.getFinancialDocumentFiftyCentAmount())) { 723 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "fifty cent amount", formatter.format(detail.getFinancialDocumentFiftyCentAmount()).toString(), formatter.format(drawer.getFinancialDocumentFiftyCentAmount()).toString() }); 724 success = false; 725 } 726 } 727 if (detail.getFinancialDocumentTwentyFiveCentAmount() != null && detail.getFinancialDocumentTwentyFiveCentAmount().isGreaterThan(KualiDecimal.ZERO)) { 728 if (drawer.getFinancialDocumentTwentyFiveCentAmount() == null || drawer.getFinancialDocumentTwentyFiveCentAmount().isLessThan(detail.getFinancialDocumentTwentyFiveCentAmount())) { 729 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "twenty five cent amount", formatter.format(detail.getFinancialDocumentTwentyFiveCentAmount()).toString(), formatter.format(drawer.getFinancialDocumentTwentyFiveCentAmount()).toString() }); 730 success = false; 731 } 732 } 733 if (detail.getFinancialDocumentTenCentAmount() != null && detail.getFinancialDocumentTenCentAmount().isGreaterThan(KualiDecimal.ZERO)) { 734 if (drawer.getFinancialDocumentTenCentAmount() == null || drawer.getFinancialDocumentTenCentAmount().isLessThan(detail.getFinancialDocumentTenCentAmount())) { 735 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "ten cent amount", formatter.format(detail.getFinancialDocumentTenCentAmount()).toString(), formatter.format(drawer.getFinancialDocumentTenCentAmount()).toString() }); 736 success = false; 737 } 738 } 739 if (detail.getFinancialDocumentFiveCentAmount() != null && detail.getFinancialDocumentFiveCentAmount().isGreaterThan(KualiDecimal.ZERO)) { 740 if (drawer.getFinancialDocumentFiveCentAmount() == null || drawer.getFinancialDocumentFiveCentAmount().isLessThan(detail.getFinancialDocumentFiveCentAmount())) { 741 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "five cent amount", formatter.format(detail.getFinancialDocumentFiveCentAmount()).toString(), formatter.format(drawer.getFinancialDocumentFiveCentAmount()).toString() }); 742 success = false; 743 } 744 } 745 if (detail.getFinancialDocumentOneCentAmount() != null && detail.getFinancialDocumentOneCentAmount().isGreaterThan(KualiDecimal.ZERO)) { 746 if (drawer.getFinancialDocumentOneCentAmount() == null || drawer.getFinancialDocumentOneCentAmount().isLessThan(detail.getFinancialDocumentOneCentAmount())) { 747 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "one cent amount", formatter.format(detail.getFinancialDocumentOneCentAmount()).toString(), formatter.format(drawer.getFinancialDocumentOneCentAmount()).toString() }); 748 success = false; 749 } 750 } 751 if (detail.getFinancialDocumentOtherCentAmount() != null && detail.getFinancialDocumentOtherCentAmount().isGreaterThan(KualiDecimal.ZERO)) { 752 if (drawer.getFinancialDocumentOtherCentAmount() == null || drawer.getFinancialDocumentOtherCentAmount().isLessThan(detail.getFinancialDocumentOtherCentAmount())) { 753 GlobalVariables.getMessageMap().putError(OLEConstants.DepositConstants.DEPOSIT_WIZARD_DEPOSITHEADER_ERROR, OLEKeyConstants.Deposit.ERROR_NOT_ENOUGH_CASH_TO_COMPLETE_DEPOSIT, new String[] { "other cent amount", formatter.format(detail.getFinancialDocumentOtherCentAmount()).toString(), formatter.format(drawer.getFinancialDocumentOtherCentAmount()).toString() }); 754 success = false; 755 } 756 } 757 } 758 return success; 759 } 760 761 762 /** 763 * This method handles canceling (closing) the deposit wizard. 764 * 765 * @param mapping 766 * @param form 767 * @param request 768 * @param response 769 * @return ActionForward 770 * @throws Exception 771 */ 772 public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 773 DepositWizardForm dform = (DepositWizardForm) form; 774 775 ActionForward dest = returnToSender(dform.getCashManagementDocId()); 776 return dest; 777 } 778 779 780 /** 781 * @param cmDocId 782 * @return ActionForward which will redirect the user to the docSearchDisplay for the CashManagementDocument with the given 783 * documentId 784 */ 785 private ActionForward returnToSender(String cmDocId) { 786 Properties params = new Properties(); 787 params.setProperty("methodToCall", "docHandler"); 788 params.setProperty("command", "displayDocSearchView"); 789 params.setProperty("docId", cmDocId); 790 791 String cmActionUrl = UrlFactory.parameterizeUrl(OLEConstants.CASH_MANAGEMENT_DOCUMENT_ACTION, params); 792 793 return new ActionForward(cmActionUrl, true); 794 } 795}