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
017 package org.kuali.kfs.fp.businessobject;
018
019 import java.util.HashMap;
020 import java.util.LinkedHashMap;
021 import java.util.Map;
022
023 import org.apache.commons.lang.StringUtils;
024 import org.kuali.kfs.sys.KFSConstants;
025 import org.kuali.kfs.sys.context.SpringContext;
026 import org.kuali.rice.kns.bo.Campus;
027 import org.kuali.rice.kns.bo.CampusImpl;
028 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
029 import org.kuali.rice.kns.service.BusinessObjectService;
030 import org.kuali.rice.kns.service.KualiModuleService;
031 import org.kuali.rice.kns.util.KNSPropertyConstants;
032 import org.kuali.rice.kns.util.KualiDecimal;
033
034 /**
035 * This class represents a cash drawer used in cash management document. It contains amounts for
036 * different types of denominations for currency and coin.
037 */
038 public class CashDrawer extends PersistableBusinessObjectBase {
039 private String campusCode;
040 private String statusCode;
041
042 private KualiDecimal cashDrawerTotalAmount;
043
044 private KualiDecimal financialDocumentHundredDollarAmount;
045 private KualiDecimal financialDocumentFiftyDollarAmount;
046 private KualiDecimal financialDocumentTwentyDollarAmount;
047 private KualiDecimal financialDocumentTenDollarAmount;
048 private KualiDecimal financialDocumentFiveDollarAmount;
049 private KualiDecimal financialDocumentTwoDollarAmount;
050 private KualiDecimal financialDocumentOneDollarAmount;
051 private KualiDecimal financialDocumentOtherDollarAmount;
052
053 private KualiDecimal financialDocumentHundredCentAmount;
054 private KualiDecimal financialDocumentFiftyCentAmount;
055 private KualiDecimal financialDocumentTwentyFiveCentAmount;
056 private KualiDecimal financialDocumentTenCentAmount;
057 private KualiDecimal financialDocumentFiveCentAmount;
058 private KualiDecimal financialDocumentOneCentAmount;
059 private KualiDecimal financialDocumentOtherCentAmount;
060
061 private KualiDecimal financialDocumentMiscellaneousAdvanceAmount;
062
063 private String referenceFinancialDocumentNumber;
064 private Campus campus;
065
066 /**
067 * Default constructor.
068 */
069 public CashDrawer() {
070
071 }
072
073 /**
074 * This method returns true if the cash drawer is open.
075 *
076 * @return boolean
077 */
078 public boolean isOpen() {
079 return StringUtils.equals(KFSConstants.CashDrawerConstants.STATUS_OPEN, statusCode);
080 }
081
082 /**
083 * This method returns true if the cash drawer is closed.
084 *
085 * @return boolean
086 */
087 public boolean isClosed() {
088 return (statusCode == null || StringUtils.equals(KFSConstants.CashDrawerConstants.STATUS_CLOSED, statusCode) || referenceFinancialDocumentNumber == null);
089 }
090
091 /**
092 * This method returns true if the cash drawer is locked.
093 *
094 * @return boolean
095 */
096 public boolean isLocked() {
097 return StringUtils.equals(KFSConstants.CashDrawerConstants.STATUS_LOCKED, statusCode);
098 }
099
100
101 /**
102 * Gets the campusCode attribute.
103 *
104 * @return Returns the campusCode
105 */
106 public String getCampusCode() {
107 return campusCode;
108 }
109
110 /**
111 * Sets the campusCode attribute.
112 *
113 * @param campusCode The campusCode to set.
114 */
115 public void setCampusCode(String campusCode) {
116 this.campusCode = campusCode;
117 }
118
119
120 /**
121 * Gets the statusCode attribute.
122 *
123 * @return Returns the statusCode
124 */
125 public String getStatusCode() {
126 return statusCode;
127 }
128
129 /**
130 * Sets the statusCode attribute.
131 *
132 * @param financialDocumentOpenDepositCode The statusCode to set.
133 */
134 public void setStatusCode(String financialDocumentOpenDepositCode) {
135 this.statusCode = financialDocumentOpenDepositCode;
136 }
137
138
139 /**
140 * Gets the cashDrawerTotalAmount attribute.
141 *
142 * @return Returns the cashDrawerTotalAmount
143 */
144 public KualiDecimal getCashDrawerTotalAmount() {
145 return cashDrawerTotalAmount;
146 }
147
148 /**
149 * Sets the cashDrawerTotalAmount attribute.
150 *
151 * @param cashDrawerTotalAmount The cashDrawerTotalAmount to set.
152 */
153 public void setCashDrawerTotalAmount(KualiDecimal cashDrawerTotalAmount) {
154 this.cashDrawerTotalAmount = cashDrawerTotalAmount;
155 }
156
157
158 /**
159 * Gets the financialDocumentHundredDollarAmount attribute.
160 *
161 * @return Returns the financialDocumentHundredDollarAmount
162 */
163 public KualiDecimal getFinancialDocumentHundredDollarAmount() {
164 return financialDocumentHundredDollarAmount;
165 }
166
167 /**
168 * Sets the financialDocumentHundredDollarAmount attribute.
169 *
170 * @param financialDocumentHundredDollarAmount The financialDocumentHundredDollarAmount to set.
171 */
172 public void setFinancialDocumentHundredDollarAmount(KualiDecimal financialDocumentHundredDollarAmount) {
173 this.financialDocumentHundredDollarAmount = financialDocumentHundredDollarAmount;
174 }
175
176 /**
177 * Returns the actual count of hundred dollar bills
178 *
179 * @return the number of hundred dollar bills present in the drawer
180 */
181 public Integer getHundredDollarCount() {
182 return (financialDocumentHundredDollarAmount != null) ? new Integer(financialDocumentHundredDollarAmount.divide(KFSConstants.CurrencyTypeAmounts.HUNDRED_DOLLAR_AMOUNT).intValue()) : new Integer(0);
183 }
184
185 /**
186 * This sets the count of hundred dollar bills present in the drawer
187 *
188 * @param count the number of hundred dollar bills present in the drawer
189 */
190 public void setHundredDollarCount(Integer count) {
191 if (count != null) {
192 this.financialDocumentHundredDollarAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CurrencyTypeAmounts.HUNDRED_DOLLAR_AMOUNT);
193 }
194 }
195
196 /**
197 * Gets the financialDocumentFiftyDollarAmount attribute.
198 *
199 * @return Returns the financialDocumentFiftyDollarAmount
200 */
201 public KualiDecimal getFinancialDocumentFiftyDollarAmount() {
202 return financialDocumentFiftyDollarAmount;
203 }
204
205 /**
206 * Sets the financialDocumentFiftyDollarAmount attribute.
207 *
208 * @param financialDocumentFiftyDollarAmount The financialDocumentFiftyDollarAmount to set.
209 */
210 public void setFinancialDocumentFiftyDollarAmount(KualiDecimal financialDocumentFiftyDollarAmount) {
211 this.financialDocumentFiftyDollarAmount = financialDocumentFiftyDollarAmount;
212 }
213
214 /**
215 * Returns the actual count of fifty dollar bills
216 *
217 * @return the number of fifty dollar bills present in the drawer
218 */
219 public Integer getFiftyDollarCount() {
220 return (financialDocumentFiftyDollarAmount != null) ? new Integer(financialDocumentFiftyDollarAmount.divide(KFSConstants.CurrencyTypeAmounts.FIFTY_DOLLAR_AMOUNT).intValue()) : new Integer(0);
221 }
222
223 /**
224 * This sets the count of hundred dollar bills present in the drawer
225 *
226 * @param count the number of hundred dollar bills present in the drawer
227 */
228 public void setFiftyDollarCount(Integer count) {
229 if (count != null) {
230 this.financialDocumentFiftyDollarAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CurrencyTypeAmounts.FIFTY_DOLLAR_AMOUNT);
231 }
232 }
233
234 /**
235 * Gets the financialDocumentTwentyDollarAmount attribute.
236 *
237 * @return Returns the financialDocumentTwentyDollarAmount
238 */
239 public KualiDecimal getFinancialDocumentTwentyDollarAmount() {
240 return financialDocumentTwentyDollarAmount;
241 }
242
243 /**
244 * Sets the financialDocumentTwentyDollarAmount attribute.
245 *
246 * @param financialDocumentTwentyDollarAmount The financialDocumentTwentyDollarAmount to set.
247 */
248 public void setFinancialDocumentTwentyDollarAmount(KualiDecimal financialDocumentTwentyDollarAmount) {
249 this.financialDocumentTwentyDollarAmount = financialDocumentTwentyDollarAmount;
250 }
251
252 /**
253 * Returns the actual count of twenty dollar bills
254 *
255 * @return the number of twenty dollar bills present in the drawer
256 */
257 public Integer getTwentyDollarCount() {
258 return (financialDocumentTwentyDollarAmount != null) ? new Integer(financialDocumentTwentyDollarAmount.divide(KFSConstants.CurrencyTypeAmounts.TWENTY_DOLLAR_AMOUNT).intValue()) : new Integer(0);
259 }
260
261 /**
262 * This sets the count of twenty dollar bills present in the drawer
263 *
264 * @param count the number of twenty dollar bills present in the drawer
265 */
266 public void setTwentyDollarCount(Integer count) {
267 if (count != null) {
268 this.financialDocumentTwentyDollarAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CurrencyTypeAmounts.TWENTY_DOLLAR_AMOUNT);
269 }
270 }
271
272 /**
273 * Gets the financialDocumentTenDollarAmount attribute.
274 *
275 * @return Returns the financialDocumentTenDollarAmount
276 */
277 public KualiDecimal getFinancialDocumentTenDollarAmount() {
278 return financialDocumentTenDollarAmount;
279 }
280
281 /**
282 * Sets the financialDocumentTenDollarAmount attribute.
283 *
284 * @param financialDocumentTenDollarAmount The financialDocumentTenDollarAmount to set.
285 */
286 public void setFinancialDocumentTenDollarAmount(KualiDecimal financialDocumentTenDollarAmount) {
287 this.financialDocumentTenDollarAmount = financialDocumentTenDollarAmount;
288 }
289
290 /**
291 * Returns the actual count of ten dollar bills
292 *
293 * @return the number of ten dollar bills present in the drawer
294 */
295 public Integer getTenDollarCount() {
296 return (financialDocumentTenDollarAmount != null) ? new Integer(financialDocumentTenDollarAmount.divide(KFSConstants.CurrencyTypeAmounts.TEN_DOLLAR_AMOUNT).intValue()) : new Integer(0);
297 }
298
299 /**
300 * This sets the count of ten dollar bills present in the drawer
301 *
302 * @param count the number of ten dollar bills present in the drawer
303 */
304 public void setTenDollarCount(Integer count) {
305 if (count != null) {
306 this.financialDocumentTenDollarAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CurrencyTypeAmounts.TEN_DOLLAR_AMOUNT);
307 }
308 }
309
310 /**
311 * Gets the financialDocumentFiveDollarAmount attribute.
312 *
313 * @return Returns the financialDocumentFiveDollarAmount
314 */
315 public KualiDecimal getFinancialDocumentFiveDollarAmount() {
316 return financialDocumentFiveDollarAmount;
317 }
318
319 /**
320 * Sets the financialDocumentFiveDollarAmount attribute.
321 *
322 * @param financialDocumentFiveDollarAmount The financialDocumentFiveDollarAmount to set.
323 */
324 public void setFinancialDocumentFiveDollarAmount(KualiDecimal financialDocumentFiveDollarAmount) {
325 this.financialDocumentFiveDollarAmount = financialDocumentFiveDollarAmount;
326 }
327
328 /**
329 * Returns the actual count of five dollar bills
330 *
331 * @return the number of five dollar bills present in the drawer
332 */
333 public Integer getFiveDollarCount() {
334 return (financialDocumentFiveDollarAmount != null) ? new Integer(financialDocumentFiveDollarAmount.divide(KFSConstants.CurrencyTypeAmounts.FIVE_DOLLAR_AMOUNT).intValue()) : new Integer(0);
335 }
336
337 /**
338 * This sets the count of five dollar bills present in the drawer
339 *
340 * @param count the number of five dollar bills present in the drawer
341 */
342 public void setFiveDollarCount(Integer count) {
343 if (count != null) {
344 this.financialDocumentFiveDollarAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CurrencyTypeAmounts.FIVE_DOLLAR_AMOUNT);
345 }
346 }
347
348 /**
349 * Gets the financialDocumentTwoDollarAmount attribute.
350 *
351 * @return Returns the financialDocumentTwoDollarAmount
352 */
353 public KualiDecimal getFinancialDocumentTwoDollarAmount() {
354 return financialDocumentTwoDollarAmount;
355 }
356
357 /**
358 * Sets the financialDocumentTwoDollarAmount attribute.
359 *
360 * @param financialDocumentTwoDollarAmount The financialDocumentTwoDollarAmount to set.
361 */
362 public void setFinancialDocumentTwoDollarAmount(KualiDecimal financialDocumentTwoDollarAmount) {
363 this.financialDocumentTwoDollarAmount = financialDocumentTwoDollarAmount;
364 }
365
366 /**
367 * Returns the actual count of two dollar bills
368 *
369 * @return the number of two dollar bills present in the drawer
370 */
371 public Integer getTwoDollarCount() {
372 return (financialDocumentTwoDollarAmount != null) ? new Integer(financialDocumentTwoDollarAmount.divide(KFSConstants.CurrencyTypeAmounts.TWO_DOLLAR_AMOUNT).intValue()) : new Integer(0);
373 }
374
375 /**
376 * This sets the count of two dollar bills present in the drawer
377 *
378 * @param count the number of two dollar bills present in the drawer
379 */
380 public void setTwoDollarCount(Integer count) {
381 if (count != null) {
382 this.financialDocumentTwoDollarAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CurrencyTypeAmounts.TWO_DOLLAR_AMOUNT);
383 }
384 }
385
386 /**
387 * Gets the financialDocumentOneDollarAmount attribute.
388 *
389 * @return Returns the financialDocumentOneDollarAmount
390 */
391 public KualiDecimal getFinancialDocumentOneDollarAmount() {
392 return financialDocumentOneDollarAmount;
393 }
394
395 /**
396 * Sets the financialDocumentOneDollarAmount attribute.
397 *
398 * @param financialDocumentOneDollarAmount The financialDocumentOneDollarAmount to set.
399 */
400 public void setFinancialDocumentOneDollarAmount(KualiDecimal financialDocumentOneDollarAmount) {
401 this.financialDocumentOneDollarAmount = financialDocumentOneDollarAmount;
402 }
403
404 /**
405 * Returns the actual count of one dollar bills
406 *
407 * @return the number of one dollar bills present in the drawer
408 */
409 public Integer getOneDollarCount() {
410 return (financialDocumentOneDollarAmount != null) ? new Integer(financialDocumentOneDollarAmount.divide(KFSConstants.CurrencyTypeAmounts.ONE_DOLLAR_AMOUNT).intValue()) : new Integer(0);
411 }
412
413 /**
414 * This sets the count of one dollar bills present in the drawer
415 *
416 * @param count the number of one dollar bills present in the drawer
417 */
418 public void setOneDollarCount(Integer count) {
419 if (count != null) {
420 this.financialDocumentOneDollarAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CurrencyTypeAmounts.ONE_DOLLAR_AMOUNT);
421 }
422 }
423
424 /**
425 * Gets the financialDocumentOtherDollarAmount attribute.
426 *
427 * @return Returns the financialDocumentOtherDollarAmount
428 */
429 public KualiDecimal getFinancialDocumentOtherDollarAmount() {
430 return financialDocumentOtherDollarAmount;
431 }
432
433 /**
434 * Sets the financialDocumentOtherDollarAmount attribute.
435 *
436 * @param financialDocumentOtherDollarAmount The financialDocumentOtherDollarAmount to set.
437 */
438 public void setFinancialDocumentOtherDollarAmount(KualiDecimal financialDocumentOtherDollarAmount) {
439 this.financialDocumentOtherDollarAmount = financialDocumentOtherDollarAmount;
440 }
441
442
443 /**
444 * Gets the financialDocumentFiftyCentAmount attribute.
445 *
446 * @return Returns the financialDocumentFiftyCentAmount
447 */
448 public KualiDecimal getFinancialDocumentFiftyCentAmount() {
449 return financialDocumentFiftyCentAmount;
450 }
451
452 /**
453 * Sets the financialDocumentFiftyCentAmount attribute.
454 *
455 * @param financialDocumentFiftyCentAmount The financialDocumentFiftyCentAmount to set.
456 */
457 public void setFinancialDocumentFiftyCentAmount(KualiDecimal financialDocumentFiftyCentAmount) {
458 this.financialDocumentFiftyCentAmount = financialDocumentFiftyCentAmount;
459 }
460
461 /**
462 * Returns the number of half-cent coins in the drawer
463 *
464 * @return the count of half cent coins in the drawer
465 */
466 public Integer getFiftyCentCount() {
467 return (financialDocumentFiftyCentAmount != null) ? new Integer(financialDocumentFiftyCentAmount.divide(KFSConstants.CoinTypeAmounts.FIFTY_CENT_AMOUNT).intValue()) : new Integer(0);
468 }
469
470 /**
471 * Sets the number of fifty cent coins in the drawer. This is useful if, you know, you're in da club, with, say a bottle full of
472 * "bub"
473 *
474 * @param count the number of fifty cent coins present in the drawer
475 */
476 public void setFiftyCentCount(Integer count) {
477 if (count != null) {
478 financialDocumentFiftyCentAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CoinTypeAmounts.FIFTY_CENT_AMOUNT);
479 }
480 }
481
482 /**
483 * Gets the financialDocumentTwentyFiveCentAmount attribute.
484 *
485 * @return Returns the financialDocumentTwentyFiveCentAmount
486 */
487 public KualiDecimal getFinancialDocumentTwentyFiveCentAmount() {
488 return financialDocumentTwentyFiveCentAmount;
489 }
490
491 /**
492 * Sets the financialDocumentTwentyFiveCentAmount attribute.
493 *
494 * @param financialDocumentTwentyFiveCentAmount The financialDocumentTwentyFiveCentAmount to set.
495 */
496 public void setFinancialDocumentTwentyFiveCentAmount(KualiDecimal financialDocumentTwentyFiveCentAmount) {
497 this.financialDocumentTwentyFiveCentAmount = financialDocumentTwentyFiveCentAmount;
498 }
499
500 /**
501 * Returns the number of quarters in the drawer
502 *
503 * @return the count of quarters in the drawer
504 */
505 public Integer getTwentyFiveCentCount() {
506 return (financialDocumentTwentyFiveCentAmount != null) ? new Integer(financialDocumentTwentyFiveCentAmount.divide(KFSConstants.CoinTypeAmounts.TWENTY_FIVE_CENT_AMOUNT).intValue()) : new Integer(0);
507 }
508
509 /**
510 * Sets the number of quarters in the drawer
511 *
512 * @param count the number of quarters present in the drawer
513 */
514 public void setTwentyFiveCentCount(Integer count) {
515 if (count != null) {
516 financialDocumentTwentyFiveCentAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CoinTypeAmounts.TWENTY_FIVE_CENT_AMOUNT);
517 }
518 }
519
520 /**
521 * Gets the financialDocumentTenCentAmount attribute.
522 *
523 * @return Returns the financialDocumentTenCentAmount
524 */
525 public KualiDecimal getFinancialDocumentTenCentAmount() {
526 return financialDocumentTenCentAmount;
527 }
528
529 /**
530 * Sets the financialDocumentTenCentAmount attribute.
531 *
532 * @param financialDocumentTenCentAmount The financialDocumentTenCentAmount to set.
533 */
534 public void setFinancialDocumentTenCentAmount(KualiDecimal financialDocumentTenCentAmount) {
535 this.financialDocumentTenCentAmount = financialDocumentTenCentAmount;
536 }
537
538 /**
539 * Returns the number of dimes in the drawer
540 *
541 * @return the count of dimes in the drawer
542 */
543 public Integer getTenCentCount() {
544 return (financialDocumentTenCentAmount != null) ? new Integer(financialDocumentTenCentAmount.divide(KFSConstants.CoinTypeAmounts.TEN_CENT_AMOUNT).intValue()) : new Integer(0);
545 }
546
547 /**
548 * Sets the number of dimes in the drawer
549 *
550 * @param count the number of dimes present in the drawer
551 */
552 public void setTenCentCount(Integer count) {
553 if (count != null) {
554 financialDocumentTenCentAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CoinTypeAmounts.TEN_CENT_AMOUNT);
555 }
556 }
557
558 /**
559 * Gets the financialDocumentFiveCentAmount attribute.
560 *
561 * @return Returns the financialDocumentFiveCentAmount
562 */
563 public KualiDecimal getFinancialDocumentFiveCentAmount() {
564 return financialDocumentFiveCentAmount;
565 }
566
567 /**
568 * Sets the financialDocumentFiveCentAmount attribute.
569 *
570 * @param financialDocumentFiveCentAmount The financialDocumentFiveCentAmount to set.
571 */
572 public void setFinancialDocumentFiveCentAmount(KualiDecimal financialDocumentFiveCentAmount) {
573 this.financialDocumentFiveCentAmount = financialDocumentFiveCentAmount;
574 }
575
576 /**
577 * Returns the number of nickels in the drawer
578 *
579 * @return the count of nickels in the drawer
580 */
581 public Integer getFiveCentCount() {
582 return (financialDocumentFiveCentAmount != null) ? new Integer(financialDocumentFiveCentAmount.divide(KFSConstants.CoinTypeAmounts.FIVE_CENT_AMOUNT).intValue()) : new Integer(0);
583 }
584
585 /**
586 * Sets the number of nickels in the drawer
587 *
588 * @param count the number of nickels present in the drawer
589 */
590 public void setFiveCentCount(Integer count) {
591 if (count != null) {
592 financialDocumentFiveCentAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CoinTypeAmounts.FIVE_CENT_AMOUNT);
593 }
594 }
595
596 /**
597 * Gets the financialDocumentOneCentAmount attribute.
598 *
599 * @return Returns the financialDocumentOneCentAmount
600 */
601 public KualiDecimal getFinancialDocumentOneCentAmount() {
602 return financialDocumentOneCentAmount;
603 }
604
605 /**
606 * Sets the financialDocumentOneCentAmount attribute.
607 *
608 * @param financialDocumentOneCentAmount The financialDocumentOneCentAmount to set.
609 */
610 public void setFinancialDocumentOneCentAmount(KualiDecimal financialDocumentOneCentAmount) {
611 this.financialDocumentOneCentAmount = financialDocumentOneCentAmount;
612 }
613
614 /**
615 * Returns the number of pennies in the drawer
616 *
617 * @return the count of pennies in the drawer
618 */
619 public Integer getOneCentCount() {
620 return (financialDocumentOneCentAmount != null) ? new Integer(financialDocumentOneCentAmount.divide(KFSConstants.CoinTypeAmounts.ONE_CENT_AMOUNT).intValue()) : new Integer(0);
621 }
622
623 /**
624 * Sets the number of pennies in the drawer
625 *
626 * @param count the number of pennies present in the drawer
627 */
628 public void setOneCentCount(Integer count) {
629 if (count != null) {
630 financialDocumentOneCentAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CoinTypeAmounts.ONE_CENT_AMOUNT);
631 }
632 }
633
634 /**
635 * Gets the financialDocumentOtherCentAmount attribute.
636 *
637 * @return Returns the financialDocumentOtherCentAmount
638 */
639 public KualiDecimal getFinancialDocumentOtherCentAmount() {
640 return financialDocumentOtherCentAmount;
641 }
642
643 /**
644 * Sets the financialDocumentOtherCentAmount attribute.
645 *
646 * @param financialDocumentOtherCentAmount The financialDocumentOtherCentAmount to set.
647 */
648 public void setFinancialDocumentOtherCentAmount(KualiDecimal financialDocumentOtherCentAmount) {
649 this.financialDocumentOtherCentAmount = financialDocumentOtherCentAmount;
650 }
651
652
653 /**
654 * Gets the financialDocumentHundredCentAmount attribute.
655 *
656 * @return Returns the financialDocumentHundredCentAmount
657 */
658 public KualiDecimal getFinancialDocumentHundredCentAmount() {
659 return financialDocumentHundredCentAmount;
660 }
661
662 /**
663 * Sets the financialDocumentHundredCentAmount attribute.
664 *
665 * @param financialDocumentHundredCentAmount The financialDocumentHundredCentAmount to set.
666 */
667 public void setFinancialDocumentHundredCentAmount(KualiDecimal financialDocumentHundredCentAmount) {
668 this.financialDocumentHundredCentAmount = financialDocumentHundredCentAmount;
669 }
670
671 /**
672 * Returns the number of dollar coins--Sacajawea, Susan B. Anthony, or otherwise--in the drawer
673 *
674 * @return the count of dollar coins in the drawer
675 */
676 public Integer getHundredCentCount() {
677 return (financialDocumentHundredCentAmount != null) ? new Integer(financialDocumentHundredCentAmount.divide(KFSConstants.CoinTypeAmounts.HUNDRED_CENT_AMOUNT).intValue()) : new Integer(0);
678 }
679
680 /**
681 * Sets the number of hundred cent coins in the drawer
682 *
683 * @param count the number of hundred cent coins present in the drawer
684 */
685 public void setHundredCentCount(Integer count) {
686 if (count != null) {
687 financialDocumentHundredCentAmount = new KualiDecimal(count.intValue()).multiply(KFSConstants.CoinTypeAmounts.HUNDRED_CENT_AMOUNT);
688 }
689 }
690
691 /**
692 * Gets the financialDocumentMiscellaneousAdvanceAmount attribute.
693 *
694 * @return Returns the financialDocumentMiscellaneousAdvanceAmount
695 */
696 public KualiDecimal getFinancialDocumentMiscellaneousAdvanceAmount() {
697 return financialDocumentMiscellaneousAdvanceAmount;
698 }
699
700 /**
701 * Sets the financialDocumentMiscellaneousAdvanceAmount attribute.
702 *
703 * @param financialDocumentMiscellaneousAdvanceAmount The financialDocumentMiscellaneousAdvanceAmount to set.
704 */
705 public void setFinancialDocumentMiscellaneousAdvanceAmount(KualiDecimal financialDocumentMiscellaneousAdvanceAmount) {
706 this.financialDocumentMiscellaneousAdvanceAmount = financialDocumentMiscellaneousAdvanceAmount;
707 }
708
709
710 /**
711 * Gets the referenceFinancialDocumentNumber attribute.
712 *
713 * @return Returns the referenceFinancialDocumentNumber
714 */
715 public String getReferenceFinancialDocumentNumber() {
716 return referenceFinancialDocumentNumber;
717 }
718
719 /**
720 * Sets the referenceFinancialDocumentNumber attribute.
721 *
722 * @param referenceFinancialDocumentNumber The referenceFinancialDocumentNumber to set.
723 */
724 public void setReferenceFinancialDocumentNumber(String referenceFinancialDocumentNumber) {
725 this.referenceFinancialDocumentNumber = referenceFinancialDocumentNumber;
726 }
727
728 /**
729 * This method calculates the total amount of currency in the cash drawer
730 *
731 * @return the total amount of currency
732 */
733 public KualiDecimal getCurrencyTotalAmount() {
734 KualiDecimal result = KualiDecimal.ZERO;
735 if (this.financialDocumentHundredDollarAmount != null) {
736 result = result.add(this.financialDocumentHundredDollarAmount);
737 }
738 if (this.financialDocumentFiftyDollarAmount != null) {
739 result = result.add(this.financialDocumentFiftyDollarAmount);
740 }
741 if (this.financialDocumentTwentyDollarAmount != null) {
742 result = result.add(this.financialDocumentTwentyDollarAmount);
743 }
744 if (this.financialDocumentTenDollarAmount != null) {
745 result = result.add(this.financialDocumentTenDollarAmount);
746 }
747 if (this.financialDocumentFiveDollarAmount != null) {
748 result = result.add(this.financialDocumentFiveDollarAmount);
749 }
750 if (this.financialDocumentTwoDollarAmount != null) {
751 result = result.add(this.financialDocumentTwoDollarAmount);
752 }
753 if (this.financialDocumentOneDollarAmount != null) {
754 result = result.add(this.financialDocumentOneDollarAmount);
755 }
756 if (this.financialDocumentOtherDollarAmount != null) {
757 result = result.add(this.financialDocumentOtherDollarAmount);
758 }
759 return result;
760 }
761
762 /**
763 * This method calculates the total amount of coin in the cash drawer
764 *
765 * @return the total amount of coin
766 */
767 public KualiDecimal getCoinTotalAmount() {
768 KualiDecimal result = KualiDecimal.ZERO;
769 if (this.financialDocumentHundredCentAmount != null) {
770 result = result.add(this.financialDocumentHundredCentAmount);
771 }
772 if (this.financialDocumentFiftyCentAmount != null) {
773 result = result.add(this.financialDocumentFiftyCentAmount);
774 }
775 if (this.financialDocumentTwentyFiveCentAmount != null) {
776 result = result.add(this.financialDocumentTwentyFiveCentAmount);
777 }
778 if (this.financialDocumentTenCentAmount != null) {
779 result = result.add(this.financialDocumentTenCentAmount);
780 }
781 if (this.financialDocumentFiveCentAmount != null) {
782 result = result.add(this.financialDocumentFiveCentAmount);
783 }
784 if (this.financialDocumentOneCentAmount != null) {
785 result = result.add(this.financialDocumentOneCentAmount);
786 }
787 if (this.financialDocumentOtherCentAmount != null) {
788 result = result.add(this.financialDocumentOtherCentAmount);
789 }
790 return result;
791 }
792
793 /**
794 * This calculates the total amount of money currently in the cash drawer
795 *
796 * @return the amount currently in the cash drawer
797 */
798 public KualiDecimal getTotalAmount() {
799 return this.getCurrencyTotalAmount().add(this.getCoinTotalAmount());
800 }
801
802 /**
803 * This method adds currency to the cash drawer
804 *
805 * @param detail the record indicating how much of each denomination of currency to add
806 */
807 public void addCurrency(CurrencyDetail detail) {
808 if (detail.getFinancialDocumentHundredDollarAmount() != null) {
809 if (financialDocumentHundredDollarAmount == null) {
810 financialDocumentHundredDollarAmount = new KualiDecimal(detail.getFinancialDocumentHundredDollarAmount().bigDecimalValue());
811 }
812 else {
813 financialDocumentHundredDollarAmount = financialDocumentHundredDollarAmount.add(detail.getFinancialDocumentHundredDollarAmount());
814 }
815 }
816 if (detail.getFinancialDocumentFiftyDollarAmount() != null) {
817 if (financialDocumentFiftyDollarAmount == null) {
818 financialDocumentFiftyDollarAmount = new KualiDecimal(detail.getFinancialDocumentFiftyDollarAmount().bigDecimalValue());
819 }
820 else {
821 financialDocumentFiftyDollarAmount = financialDocumentFiftyDollarAmount.add(detail.getFinancialDocumentFiftyDollarAmount());
822 }
823 }
824 if (detail.getFinancialDocumentTwentyDollarAmount() != null) {
825 if (financialDocumentTwentyDollarAmount == null) {
826 financialDocumentTwentyDollarAmount = new KualiDecimal(detail.getFinancialDocumentTwentyDollarAmount().bigDecimalValue());
827 }
828 else {
829 financialDocumentTwentyDollarAmount = financialDocumentTwentyDollarAmount.add(detail.getFinancialDocumentTwentyDollarAmount());
830 }
831 }
832 if (detail.getFinancialDocumentTenDollarAmount() != null) {
833 if (financialDocumentTenDollarAmount == null) {
834 financialDocumentTenDollarAmount = new KualiDecimal(detail.getFinancialDocumentTenDollarAmount().bigDecimalValue());
835 }
836 else {
837 financialDocumentTenDollarAmount = financialDocumentTenDollarAmount.add(detail.getFinancialDocumentTenDollarAmount());
838 }
839 }
840 if (detail.getFinancialDocumentFiveDollarAmount() != null) {
841 if (financialDocumentFiveDollarAmount == null) {
842 financialDocumentFiveDollarAmount = new KualiDecimal(detail.getFinancialDocumentFiveDollarAmount().bigDecimalValue());
843 }
844 else {
845 financialDocumentFiveDollarAmount = financialDocumentFiveDollarAmount.add(detail.getFinancialDocumentFiveDollarAmount());
846 }
847 }
848 if (detail.getFinancialDocumentTwoDollarAmount() != null) {
849 if (financialDocumentTwoDollarAmount == null) {
850 financialDocumentTwoDollarAmount = new KualiDecimal(detail.getFinancialDocumentTwoDollarAmount().bigDecimalValue());
851 }
852 else {
853 financialDocumentTwoDollarAmount = financialDocumentTwoDollarAmount.add(detail.getFinancialDocumentTwoDollarAmount());
854 }
855 }
856 if (detail.getFinancialDocumentOneDollarAmount() != null) {
857 if (financialDocumentOneDollarAmount == null) {
858 financialDocumentOneDollarAmount = new KualiDecimal(detail.getFinancialDocumentOneDollarAmount().bigDecimalValue());
859 }
860 else {
861 financialDocumentOneDollarAmount = financialDocumentOneDollarAmount.add(detail.getFinancialDocumentOneDollarAmount());
862 }
863 }
864 if (detail.getFinancialDocumentOtherDollarAmount() != null) {
865 if (financialDocumentOtherDollarAmount == null) {
866 financialDocumentOtherDollarAmount = new KualiDecimal(detail.getFinancialDocumentOtherDollarAmount().bigDecimalValue());
867 }
868 else {
869 financialDocumentOtherDollarAmount = financialDocumentOtherDollarAmount.add(detail.getFinancialDocumentOtherDollarAmount());
870 }
871 }
872 }
873
874 /**
875 * This method puts coin into the cash drawer
876 *
877 * @param detail the record indicating how much coin of each denomiation to add
878 */
879 public void addCoin(CoinDetail detail) {
880 if (detail.getFinancialDocumentHundredCentAmount() != null) {
881 if (getFinancialDocumentHundredCentAmount() == null) {
882 setFinancialDocumentHundredCentAmount(new KualiDecimal(detail.getFinancialDocumentHundredCentAmount().bigDecimalValue()));
883 }
884 else {
885 setFinancialDocumentHundredCentAmount(getFinancialDocumentHundredCentAmount().add(detail.getFinancialDocumentHundredCentAmount()));
886 }
887 }
888 if (detail.getFinancialDocumentFiftyCentAmount() != null) {
889 if (getFinancialDocumentFiftyCentAmount() == null) {
890 setFinancialDocumentFiftyCentAmount(new KualiDecimal(detail.getFinancialDocumentFiftyCentAmount().bigDecimalValue()));
891 }
892 else {
893 setFinancialDocumentFiftyCentAmount(getFinancialDocumentFiftyCentAmount().add(detail.getFinancialDocumentFiftyCentAmount()));
894 }
895 }
896 if (detail.getFinancialDocumentTwentyFiveCentAmount() != null) {
897 if (getFinancialDocumentTwentyFiveCentAmount() == null) {
898 setFinancialDocumentTwentyFiveCentAmount(new KualiDecimal(detail.getFinancialDocumentTwentyFiveCentAmount().bigDecimalValue()));
899 }
900 else {
901 setFinancialDocumentTwentyFiveCentAmount(getFinancialDocumentTwentyFiveCentAmount().add(detail.getFinancialDocumentTwentyFiveCentAmount()));
902 }
903 }
904 if (detail.getFinancialDocumentTenCentAmount() != null) {
905 if (getFinancialDocumentTenCentAmount() == null) {
906 setFinancialDocumentTenCentAmount(new KualiDecimal(detail.getFinancialDocumentTenCentAmount().bigDecimalValue()));
907 }
908 else {
909 setFinancialDocumentTenCentAmount(getFinancialDocumentTenCentAmount().add(detail.getFinancialDocumentTenCentAmount()));
910 }
911 }
912 if (detail.getFinancialDocumentFiveCentAmount() != null) {
913 if (getFinancialDocumentFiveCentAmount() == null) {
914 setFinancialDocumentFiveCentAmount(new KualiDecimal(detail.getFinancialDocumentFiveCentAmount().bigDecimalValue()));
915 }
916 else {
917 setFinancialDocumentFiveCentAmount(getFinancialDocumentFiveCentAmount().add(detail.getFinancialDocumentFiveCentAmount()));
918 }
919 }
920 if (detail.getFinancialDocumentOneCentAmount() != null) {
921 if (getFinancialDocumentOneCentAmount() == null) {
922 setFinancialDocumentOneCentAmount(new KualiDecimal(detail.getFinancialDocumentOneCentAmount().bigDecimalValue()));
923 }
924 else {
925 setFinancialDocumentOneCentAmount(getFinancialDocumentOneCentAmount().add(detail.getFinancialDocumentOneCentAmount()));
926 }
927 }
928 if (detail.getFinancialDocumentOtherCentAmount() != null) {
929 if (getFinancialDocumentOtherCentAmount() == null) {
930 setFinancialDocumentOtherCentAmount(new KualiDecimal(detail.getFinancialDocumentOtherCentAmount().bigDecimalValue()));
931 }
932 else {
933 setFinancialDocumentOtherCentAmount(getFinancialDocumentOtherCentAmount().add(detail.getFinancialDocumentOtherCentAmount()));
934 }
935 }
936 }
937
938 /**
939 * This method removes currency amounts from the cash drawer
940 *
941 * @param detail the record indicating how much currency of each denomination to remove
942 */
943 public void removeCurrency(CurrencyDetail detail) {
944 if (detail.getFinancialDocumentHundredDollarAmount() != null) {
945 if (this.getFinancialDocumentHundredDollarAmount() == null || detail.getFinancialDocumentHundredDollarAmount().isGreaterThan(this.getFinancialDocumentHundredDollarAmount())) {
946 throw new IllegalArgumentException("The requested amount of hundred dollar bills exceeds the amount in the cash drawer");
947 }
948 else {
949 setFinancialDocumentHundredDollarAmount(getFinancialDocumentHundredDollarAmount().subtract(detail.getFinancialDocumentHundredDollarAmount()));
950 }
951 }
952 if (detail.getFinancialDocumentFiftyDollarAmount() != null) {
953 if (this.getFinancialDocumentFiftyDollarAmount() == null || detail.getFinancialDocumentFiftyDollarAmount().isGreaterThan(this.getFinancialDocumentFiftyDollarAmount())) {
954 throw new IllegalArgumentException("The requested amount of fifty dollar bills exceeds the amount in the cash drawer");
955 }
956 else {
957 setFinancialDocumentFiftyDollarAmount(getFinancialDocumentFiftyDollarAmount().subtract(detail.getFinancialDocumentFiftyDollarAmount()));
958 }
959 }
960 if (detail.getFinancialDocumentTwentyDollarAmount() != null) {
961 if (this.getFinancialDocumentTwentyDollarAmount() == null || detail.getFinancialDocumentTwentyDollarAmount().isGreaterThan(this.getFinancialDocumentTwentyDollarAmount())) {
962 throw new IllegalArgumentException("The requested amount of twenty dollar bills exceeds the amount in the cash drawer");
963 }
964 else {
965 setFinancialDocumentTwentyDollarAmount(getFinancialDocumentTwentyDollarAmount().subtract(detail.getFinancialDocumentTwentyDollarAmount()));
966 }
967 }
968 if (detail.getFinancialDocumentTenDollarAmount() != null) {
969 if (this.getFinancialDocumentTenDollarAmount() == null || detail.getFinancialDocumentTenDollarAmount().isGreaterThan(this.getFinancialDocumentTenDollarAmount())) {
970 throw new IllegalArgumentException("The requested amount of ten dollar bills exceeds the amount in the cash drawer");
971 }
972 else {
973 setFinancialDocumentTenDollarAmount(getFinancialDocumentTenDollarAmount().subtract(detail.getFinancialDocumentTenDollarAmount()));
974 }
975 }
976 if (detail.getFinancialDocumentFiveDollarAmount() != null) {
977 if (this.getFinancialDocumentFiveDollarAmount() == null || detail.getFinancialDocumentFiveDollarAmount().isGreaterThan(this.getFinancialDocumentFiveDollarAmount())) {
978 throw new IllegalArgumentException("The requested amount of five dollar bills exceeds the amount in the cash drawer");
979 }
980 else {
981 setFinancialDocumentFiveDollarAmount(getFinancialDocumentFiveDollarAmount().subtract(detail.getFinancialDocumentFiveDollarAmount()));
982 }
983 }
984 if (detail.getFinancialDocumentTwoDollarAmount() != null) {
985 if (this.getFinancialDocumentTwoDollarAmount() == null || detail.getFinancialDocumentTwoDollarAmount().isGreaterThan(this.getFinancialDocumentTwoDollarAmount())) {
986 throw new IllegalArgumentException("The requested amount of two dollar bills exceeds the amount in the cash drawer");
987 }
988 else {
989 setFinancialDocumentTwoDollarAmount(getFinancialDocumentTwoDollarAmount().subtract(detail.getFinancialDocumentTwoDollarAmount()));
990 }
991 }
992 if (detail.getFinancialDocumentOneDollarAmount() != null) {
993 if (this.getFinancialDocumentOneDollarAmount() == null || detail.getFinancialDocumentOneDollarAmount().isGreaterThan(this.getFinancialDocumentOneDollarAmount())) {
994 throw new IllegalArgumentException("The requested amount of one dollar bills exceeds the amount in the cash drawer");
995 }
996 else {
997 setFinancialDocumentOneDollarAmount(getFinancialDocumentOneDollarAmount().subtract(detail.getFinancialDocumentOneDollarAmount()));
998 }
999 }
1000 if (detail.getFinancialDocumentOtherDollarAmount() != null) {
1001 if (this.getFinancialDocumentOtherDollarAmount() == null || detail.getFinancialDocumentOtherDollarAmount().isGreaterThan(this.getFinancialDocumentOtherDollarAmount())) {
1002 throw new IllegalArgumentException("The requested other dollar amount exceeds the amount in the cash drawer");
1003 }
1004 else {
1005 setFinancialDocumentOtherDollarAmount(getFinancialDocumentOtherDollarAmount().subtract(detail.getFinancialDocumentOtherDollarAmount()));
1006 }
1007 }
1008 }
1009
1010 /**
1011 * This method takes coin out of the cash drawer
1012 *
1013 * @param detail the record indicating how much coin of each denomination to remove
1014 */
1015 public void removeCoin(CoinDetail detail) {
1016 if (detail.getFinancialDocumentHundredCentAmount() != null) {
1017 if (this.getFinancialDocumentHundredCentAmount() == null || detail.getFinancialDocumentHundredCentAmount().isGreaterThan(this.getFinancialDocumentHundredCentAmount())) {
1018 throw new IllegalArgumentException("The requested amount of hundred cent pieces exceeds the amount in the cash drawer");
1019 }
1020 else {
1021 setFinancialDocumentHundredCentAmount(getFinancialDocumentHundredCentAmount().subtract(detail.getFinancialDocumentHundredCentAmount()));
1022 }
1023 }
1024 if (detail.getFinancialDocumentFiftyCentAmount() != null) {
1025 if (this.getFinancialDocumentFiftyCentAmount() == null || detail.getFinancialDocumentFiftyCentAmount().isGreaterThan(this.getFinancialDocumentFiftyCentAmount())) {
1026 throw new IllegalArgumentException("The requested amount of fifty cent pieces exceeds the amount in the cash drawer");
1027 }
1028 else {
1029 setFinancialDocumentFiftyCentAmount(getFinancialDocumentFiftyCentAmount().subtract(detail.getFinancialDocumentFiftyCentAmount()));
1030 }
1031 }
1032 if (detail.getFinancialDocumentTwentyFiveCentAmount() != null) {
1033 if (this.getFinancialDocumentTwentyFiveCentAmount() == null || detail.getFinancialDocumentTwentyFiveCentAmount().isGreaterThan(this.getFinancialDocumentTwentyFiveCentAmount())) {
1034 throw new IllegalArgumentException("The requested amount of twenty five cent pieces exceeds the amount in the cash drawer");
1035 }
1036 else {
1037 setFinancialDocumentTwentyFiveCentAmount(getFinancialDocumentTwentyFiveCentAmount().subtract(detail.getFinancialDocumentTwentyFiveCentAmount()));
1038 }
1039 }
1040 if (detail.getFinancialDocumentTenCentAmount() != null) {
1041 if (this.getFinancialDocumentTenCentAmount() == null || detail.getFinancialDocumentTenCentAmount().isGreaterThan(this.getFinancialDocumentTenCentAmount())) {
1042 throw new IllegalArgumentException("The requested amount of ten cent pieces exceeds the amount in the cash drawer");
1043 }
1044 else {
1045 setFinancialDocumentTenCentAmount(getFinancialDocumentTenCentAmount().subtract(detail.getFinancialDocumentTenCentAmount()));
1046 }
1047 }
1048 if (detail.getFinancialDocumentFiveCentAmount() != null) {
1049 if (this.getFinancialDocumentFiveCentAmount() == null || detail.getFinancialDocumentFiveCentAmount().isGreaterThan(this.getFinancialDocumentFiveCentAmount())) {
1050 throw new IllegalArgumentException("The requested amount of five cent pieces exceeds the amount in the cash drawer");
1051 }
1052 else {
1053 setFinancialDocumentFiveCentAmount(getFinancialDocumentFiveCentAmount().subtract(detail.getFinancialDocumentFiveCentAmount()));
1054 }
1055 }
1056 if (detail.getFinancialDocumentOneCentAmount() != null) {
1057 if (this.getFinancialDocumentOneCentAmount() == null || detail.getFinancialDocumentOneCentAmount().isGreaterThan(this.getFinancialDocumentOneCentAmount())) {
1058 throw new IllegalArgumentException("The requested amount of one cent pieces exceeds the amount in the cash drawer");
1059 }
1060 else {
1061 setFinancialDocumentOneCentAmount(getFinancialDocumentOneCentAmount().subtract(detail.getFinancialDocumentOneCentAmount()));
1062 }
1063 }
1064 if (detail.getFinancialDocumentOtherCentAmount() != null) {
1065 if (this.getFinancialDocumentOtherCentAmount() == null || detail.getFinancialDocumentOtherCentAmount().isGreaterThan(this.getFinancialDocumentOtherCentAmount())) {
1066 throw new IllegalArgumentException("The requested other cent amount exceeds the amount in the cash drawer");
1067 }
1068 else {
1069 setFinancialDocumentOtherCentAmount(getFinancialDocumentOtherCentAmount().subtract(detail.getFinancialDocumentOtherCentAmount()));
1070 }
1071 }
1072 }
1073
1074 /**
1075 * @return the campus associated with this cash drawer
1076 */
1077 public Campus getCampus() {
1078 if (campusCode != null && (campus == null || !campus.getCampusCode().equals(campusCode))) {
1079 campus = retrieveCampus();
1080 }
1081 return campus;
1082 }
1083
1084 private Campus retrieveCampus() {
1085 Map<String, Object> criteria = new HashMap<String, Object>();
1086 criteria.put(KNSPropertyConstants.CAMPUS_CODE, campusCode);
1087 return campus = (Campus) SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(Campus.class).getExternalizableBusinessObject(Campus.class, criteria);
1088 }
1089
1090 /**
1091 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
1092 */
1093 protected LinkedHashMap toStringMapper() {
1094 LinkedHashMap m = new LinkedHashMap();
1095 m.put("campusCode", this.campusCode);
1096 return m;
1097 }
1098 }