001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.fp.document.web.struts; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 import java.util.Map; 021 022 import org.kuali.kfs.fp.businessobject.Check; 023 import org.kuali.kfs.fp.businessobject.CheckBase; 024 import org.kuali.kfs.fp.businessobject.CoinDetail; 025 import org.kuali.kfs.fp.businessobject.CurrencyDetail; 026 import org.kuali.kfs.fp.businessobject.DepositWizardCashieringCheckHelper; 027 import org.kuali.kfs.fp.businessobject.DepositWizardHelper; 028 import org.kuali.kfs.fp.businessobject.format.CashReceiptDepositTypeFormatter; 029 import org.kuali.kfs.fp.document.CashManagementDocument; 030 import org.kuali.kfs.fp.document.CashReceiptDocument; 031 import org.kuali.kfs.sys.KFSConstants; 032 import org.kuali.kfs.sys.businessobject.Bank; 033 import org.kuali.kfs.sys.context.SpringContext; 034 import org.kuali.kfs.sys.service.BankService; 035 import org.kuali.rice.kns.web.struts.form.KualiForm; 036 037 /** 038 * This class is the action form for the deposit document wizard. 039 */ 040 public class DepositWizardForm extends KualiForm { 041 private String cashDrawerCampusCode; 042 private String cashManagementDocId; 043 044 private List depositableCashReceipts; 045 private List depositWizardHelpers; 046 private List<Check> depositableCashieringChecks; 047 private transient List<DepositWizardCashieringCheckHelper> depositWizardCashieringCheckHelpers; 048 private List<CashReceiptDocument> checkFreeCashReceipts; 049 050 // Deposit fields 051 private Bank bank; 052 private String bankCode; 053 054 private String depositTypeCode; 055 private String depositTicketNumber; 056 057 private CurrencyDetail currencyDetail; 058 private CoinDetail coinDetail; 059 060 // carried over editing modes and document actions to make the bank tags happy 061 protected Map editingMode; 062 protected Map documentActions; 063 064 /** 065 * Constructs a DepositWizardForm class instance. 066 */ 067 public DepositWizardForm() { 068 depositableCashReceipts = new ArrayList(); 069 depositableCashieringChecks = new ArrayList<Check>(); 070 depositWizardHelpers = new ArrayList(); 071 depositWizardCashieringCheckHelpers = new ArrayList<DepositWizardCashieringCheckHelper>(); 072 073 setFormatterType("depositTypeCode", CashReceiptDepositTypeFormatter.class); 074 setDefautBankCode(); 075 } 076 077 /** 078 * Sets the bank code for a new deposit to the setup default for the Cash Management document. 079 */ 080 public void setDefautBankCode() { 081 Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(KFSConstants.FinancialDocumentTypeCodes.CASH_MANAGEMENT); 082 if (defaultBank != null) { 083 this.bankCode = defaultBank.getBankCode(); 084 this.bank = defaultBank; 085 } 086 } 087 088 /** 089 * @return current value of cashManagementDocId. 090 */ 091 public String getCashManagementDocId() { 092 return cashManagementDocId; 093 } 094 095 /** 096 * Sets the cashManagementDocId attribute value. 097 * 098 * @param cashManagementDocId The cashManagementDocId to set. 099 */ 100 public void setCashManagementDocId(String cashManagementDocId) { 101 this.cashManagementDocId = cashManagementDocId; 102 } 103 104 105 /** 106 * @param depositTypeCode 107 */ 108 public void setDepositTypeCode(String depositTypeCode) { 109 this.depositTypeCode = depositTypeCode; 110 } 111 112 /** 113 * @return depositTypeCode 114 */ 115 public String getDepositTypeCode() { 116 return depositTypeCode; 117 } 118 119 /** 120 * Hack to make the translated depositTypeCode more readily available to the JSP 121 * 122 * @return translated depositTypeCode 123 */ 124 public String getDepositTypeString() { 125 CashReceiptDepositTypeFormatter f = new CashReceiptDepositTypeFormatter(); 126 return (String) f.format(getDepositTypeCode()); 127 } 128 129 130 /** 131 * @return List 132 */ 133 public List getDepositableCashReceipts() { 134 return depositableCashReceipts; 135 } 136 137 /** 138 * @param cashReceiptsReadyForDeposit 139 */ 140 public void setDepositableCashReceipts(List cashReceiptsReadyForDeposit) { 141 this.depositableCashReceipts = cashReceiptsReadyForDeposit; 142 } 143 144 public CashReceiptDocument getDepositableCashReceipt(int i) { 145 while (depositableCashReceipts.size() <= i) { 146 depositableCashReceipts.add(new CashReceiptDocument()); 147 } 148 149 return (CashReceiptDocument) depositableCashReceipts.get(i); 150 } 151 152 /** 153 * @return ArrayList 154 */ 155 public List getDepositWizardHelpers() { 156 return depositWizardHelpers; 157 } 158 159 /** 160 * @param depositWizardHelpers 161 */ 162 public void setDepositWizardHelpers(List depositWizardHelpers) { 163 this.depositWizardHelpers = depositWizardHelpers; 164 } 165 166 /** 167 * This method retrieves whether the cash receipt ID at the specified index will be selected or not. 168 * 169 * @param index 170 * @return DepositWizarHelper 171 */ 172 public DepositWizardHelper getDepositWizardHelper(int index) { 173 while (this.depositWizardHelpers.size() <= index) { 174 this.depositWizardHelpers.add(new DepositWizardHelper()); 175 // default to no check 176 } 177 return (DepositWizardHelper) this.depositWizardHelpers.get(index); 178 } 179 180 181 /** 182 * @return current value of cashDrawerCampusCode. 183 */ 184 public String getCashDrawerCampusCode() { 185 return cashDrawerCampusCode; 186 } 187 188 /** 189 * Sets the cashDrawerCampusCode attribute value. 190 * 191 * @param cashDrawerCampusCode The cashDrawerCampusCode to set. 192 */ 193 public void setCashDrawerCampusCode(String cashDrawerVerificationUnit) { 194 this.cashDrawerCampusCode = cashDrawerVerificationUnit; 195 } 196 197 198 /** 199 * @return current value of bankCode. 200 */ 201 public String getBankCode() { 202 return bankCode; 203 } 204 205 /** 206 * Sets the bankCode attribute value. 207 * 208 * @param bankCode The bankCode to set. 209 */ 210 public void setBankCode(String bankCode) { 211 this.bankCode = bankCode; 212 } 213 214 /** 215 * @return current value of depositTicketNumber. 216 */ 217 public String getDepositTicketNumber() { 218 return depositTicketNumber; 219 } 220 221 /** 222 * Sets the depositTicketNumber attribute value. 223 * 224 * @param depositTicketNumber The depositTicketNumber to set. 225 */ 226 public void setDepositTicketNumber(String depositTicketNumber) { 227 this.depositTicketNumber = depositTicketNumber; 228 } 229 230 /** 231 * @return current value of bank. 232 */ 233 public Bank getBank() { 234 return bank; 235 } 236 237 /** 238 * Sets the bank attribute value. 239 * 240 * @param bank The bank to set. 241 */ 242 public void setBank(Bank bank) { 243 this.bank = bank; 244 } 245 246 /** 247 * Gets the coinDetail attribute. 248 * 249 * @return Returns the coinDetail. 250 */ 251 public CoinDetail getCoinDetail() { 252 return coinDetail; 253 } 254 255 256 /** 257 * Sets the coinDetail attribute value. 258 * 259 * @param coinDetail The coinDetail to set. 260 */ 261 public void setCoinDetail(CoinDetail coinDetail) { 262 this.coinDetail = coinDetail; 263 } 264 265 266 /** 267 * Gets the currencyDetail attribute. 268 * 269 * @return Returns the currencyDetail. 270 */ 271 public CurrencyDetail getCurrencyDetail() { 272 return currencyDetail; 273 } 274 275 276 /** 277 * Sets the currencyDetail attribute value. 278 * 279 * @param currencyDetail The currencyDetail to set. 280 */ 281 public void setCurrencyDetail(CurrencyDetail currencyDetail) { 282 this.currencyDetail = currencyDetail; 283 } 284 285 /** 286 * Explains if this deposit form is for creating a final deposit or not 287 * 288 * @return true if this deposit form will create a final deposit, false if it will create an interim 289 */ 290 public boolean isDepositFinal() { 291 return (depositTypeCode.equals(KFSConstants.DepositConstants.DEPOSIT_TYPE_FINAL)); 292 } 293 294 /** 295 * Gets the depositableCashieringChecks attribute. 296 * 297 * @return Returns the depositableCashieringChecks. 298 */ 299 public List<Check> getDepositableCashieringChecks() { 300 return depositableCashieringChecks; 301 } 302 303 /** 304 * Sets the depositableCashieringChecks attribute value. 305 * 306 * @param depositableCashieringChecks The depositableCashieringChecks to set. 307 */ 308 public void setDepositableCashieringChecks(List<Check> depositableCashieringChecks) { 309 this.depositableCashieringChecks = depositableCashieringChecks; 310 } 311 312 /** 313 * Return the deposit cashiering check at the given index 314 * 315 * @param index index of check to retrieve 316 * @return a check 317 */ 318 public Check getDepositableCashieringCheck(int index) { 319 while (this.depositableCashieringChecks.size() <= index) { 320 this.depositableCashieringChecks.add(new CheckBase()); 321 } 322 return this.depositableCashieringChecks.get(index); 323 } 324 325 /** 326 * Gets the depositWizardCashieringCheckHelpers attribute. 327 * 328 * @return Returns the depositWizardCashieringCheckHelpers. 329 */ 330 public List<DepositWizardCashieringCheckHelper> getDepositWizardCashieringCheckHelpers() { 331 return depositWizardCashieringCheckHelpers; 332 } 333 334 /** 335 * Gets the checkFreeCashReceipts attribute. 336 * 337 * @return Returns the checkFreeCashReceipts. 338 */ 339 public List<CashReceiptDocument> getCheckFreeCashReceipts() { 340 return checkFreeCashReceipts; 341 } 342 343 344 /** 345 * Sets the checkFreeCashReceipts attribute value. 346 * 347 * @param checkFreeCashReceipts The checkFreeCashReceipts to set. 348 */ 349 public void setCheckFreeCashReceipts(List<CashReceiptDocument> checkFreeCashReceipts) { 350 this.checkFreeCashReceipts = checkFreeCashReceipts; 351 } 352 353 /** 354 * Retreive a single check free cash receipt 355 * 356 * @param index the index of the cash receipt 357 * @return a cash receipt document 358 */ 359 public CashReceiptDocument getCheckFreeCashReceipt(int index) { 360 while (this.checkFreeCashReceipts.size() <= index) { 361 this.checkFreeCashReceipts.add(new CashReceiptDocument()); 362 } 363 return this.checkFreeCashReceipts.get(index); 364 } 365 366 /** 367 * Sets the depositWizardCashieringCheckHelpers attribute value. 368 * 369 * @param depositWizardCashieringCheckHelpers The depositWizardCashieringCheckHelpers to set. 370 */ 371 public void setDepositWizardCashieringCheckHelpers(List<DepositWizardCashieringCheckHelper> depositWizardCashieringCheckHelpers) { 372 this.depositWizardCashieringCheckHelpers = depositWizardCashieringCheckHelpers; 373 } 374 375 public DepositWizardCashieringCheckHelper getDepositWizardCashieringCheckHelper(int index) { 376 while (this.depositWizardCashieringCheckHelpers.size() <= index) { 377 this.depositWizardCashieringCheckHelpers.add(new DepositWizardCashieringCheckHelper()); 378 } 379 return this.depositWizardCashieringCheckHelpers.get(index); 380 } 381 382 /** 383 * Gets the documentActions attribute. 384 * @return Returns the documentActions. 385 */ 386 public Map getDocumentActions() { 387 return documentActions; 388 } 389 390 /** 391 * Sets the documentActions attribute value. 392 * @param documentActions The documentActions to set. 393 */ 394 public void setDocumentActions(Map documentActions) { 395 this.documentActions = documentActions; 396 } 397 398 /** 399 * Gets the editingMode attribute. 400 * @return Returns the editingMode. 401 */ 402 public Map getEditingMode() { 403 return editingMode; 404 } 405 406 /** 407 * Sets the editingMode attribute value. 408 * @param editingMode The editingMode to set. 409 */ 410 public void setEditingMode(Map editingMode) { 411 this.editingMode = editingMode; 412 } 413 }