1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.travel.authorization.dataobject;
17
18 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
19 import java.sql.Timestamp;
20 import java.util.LinkedHashMap;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.Id;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.SequenceGenerator;
28 import javax.persistence.Table;
29 import org.kuali.rice.krad.util.KRADPropertyConstants;
30
31
32
33
34 import org.kuali.rice.core.api.util.type.KualiDecimal;
35 import org.kuali.rice.krad.util.ObjectUtils;
36
37 @Entity
38 @Table(name="TRVL_PER_DIEM_EXP_T")
39 public class PerDiemExpense extends PersistableBusinessObjectBase {
40
41 @Id
42 @GeneratedValue(generator = "TEM_PER_DIEM_EXP_ID_SEQ")
43 @SequenceGenerator(name = "TEM_PER_DIEM_EXP_ID_SEQ", sequenceName = "TEM_PER_DIEM_EXP_ID_SEQ", allocationSize = 5)
44 @Column(name = "ID", nullable = false)
45 private Integer id;
46 private String documentNumber;
47 private String countryState;
48 private String county;
49 private String primaryDestination;
50
51 private Boolean breakfast = Boolean.TRUE;
52 private Boolean lunch = Boolean.TRUE;
53 private Boolean dinner = Boolean.TRUE;
54 private Boolean personal = Boolean.FALSE;
55 private Boolean incidentalsWithMealsOnly;
56
57 private KualiDecimal breakfastValue = KualiDecimal.ZERO;
58 private KualiDecimal lunchValue = KualiDecimal.ZERO;
59 private KualiDecimal dinnerValue = KualiDecimal.ZERO;
60 private KualiDecimal incidentalsValue = KualiDecimal.ZERO;
61
62 @Column(name = "per_diem_id")
63 private Integer perDiemId;
64
65 @ManyToOne
66 @JoinColumn(name = "per_diem_id")
67
68
69 private Integer miles = new Integer(0);
70 private Timestamp mileageDate;
71
72 private Integer mileageRateId;
73
74 private String accommodationTypeCode;
75 private String accommodationName;
76 private String accommodationPhoneNum;
77 private String accommodationAddress;
78
79
80 private KualiDecimal lodging = KualiDecimal.ZERO;
81 private boolean prorated = false;
82
83 public Integer getId() {
84 return id;
85 }
86
87 public void setId(Integer id) {
88 this.id = id;
89 }
90
91 @Column(name = "FDOC_NBR", length = 14, nullable = false)
92 public String getDocumentNumber() {
93 return documentNumber;
94 }
95
96 public void setDocumentNumber(String documentNumber) {
97 this.documentNumber = documentNumber;
98 }
99
100 @Column(name = "COUNTRY", length = 100, nullable = false)
101 public String getCountryState() {
102 return countryState;
103 }
104
105 public void setCountryState(String countryState) {
106 this.countryState = countryState;
107 }
108
109 @Column(name = "COUNTY_CD", length = 100, nullable = false)
110 public String getCounty() {
111 return county;
112 }
113
114 public void setCounty(String county) {
115 this.county = county;
116 }
117
118 @Column(name = "PRI_DEST", length = 100, nullable = false)
119 public String getPrimaryDestination() {
120 return primaryDestination;
121 }
122
123 public void setPrimaryDestination(String primaryDestination) {
124 this.primaryDestination = primaryDestination;
125 }
126
127 @Column(name = "BREAKFAST_IND", nullable = false, length = 1)
128 public Boolean getBreakfast() {
129 return breakfast;
130 }
131
132 public void setBreakfast(Boolean breakfast) {
133 this.breakfast = breakfast;
134 }
135
136 @Column(name = "LUNCH_IND", nullable = false, length = 1)
137 public Boolean getLunch() {
138 return lunch;
139 }
140
141 public void setLunch(Boolean lunch) {
142 this.lunch = lunch;
143 }
144
145 @Column(name = "DINNER_IND", nullable = false, length = 1)
146 public Boolean getDinner() {
147 return dinner;
148 }
149
150 public void setDinner(Boolean dinner) {
151 this.dinner = dinner;
152 }
153
154
155
156
157
158
159 public Integer getPerDiemId() {
160 return perDiemId;
161 }
162
163
164
165
166
167
168 public void setPerDiemId(Integer perDiemId) {
169 this.perDiemId = perDiemId;
170 }
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199 @Column(name = "ACCOM_TYP_CD", length = 4)
200 public String getAccommodationTypeCode() {
201 return accommodationTypeCode;
202 }
203
204
205
206
207
208
209 public void setAccommodationTypeCode(String accommodationTypeCode) {
210 this.accommodationTypeCode = accommodationTypeCode;
211 }
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240 @Column(name = "ACCOM_NM")
241 public String getAccommodationName() {
242 return accommodationName;
243 }
244
245
246
247
248
249
250 public void setAccommodationName(String accommodationName) {
251 this.accommodationName = accommodationName;
252 }
253
254
255
256
257
258
259 @Column(name = "ACCOM_PH")
260 public String getAccommodationPhoneNum() {
261 return accommodationPhoneNum;
262 }
263
264
265
266
267
268
269 public void setAccommodationPhoneNum(String accommodationPhoneNum) {
270 this.accommodationPhoneNum = accommodationPhoneNum;
271 }
272
273
274
275
276
277
278 @Column(name = "ACCOM_ADDRESS")
279 public String getAccommodationAddress() {
280 return accommodationAddress;
281 }
282
283
284
285
286
287
288 public void setAccommodationAddress(String accommodationAddress) {
289 this.accommodationAddress = accommodationAddress;
290 }
291
292
293
294
295
296
297 @Column(name = "LODGING", precision = 19, scale = 2)
298 public KualiDecimal getLodging() {
299 if (ObjectUtils.isNotNull(lodging) && this.lodging.isGreaterThan(KualiDecimal.ZERO)) {
300 return lodging;
301 }
302
303 return KualiDecimal.ZERO;
304 }
305
306 public KualiDecimal getLodging(boolean defaultZero) {
307 return defaultZero? getLodging() : lodging;
308 }
309
310
311
312
313
314
315 public void setLodging(KualiDecimal lodging) {
316 this.lodging = lodging;
317 }
318
319 @Column(name = "MILES", nullable = false)
320 public Integer getMiles() {
321 if (ObjectUtils.isNotNull(miles) && miles > 0) {
322 return miles;
323 }
324
325 return 0;
326 }
327
328 public Integer getMiles(boolean defaultZero) {
329 return defaultZero? getMiles() : miles;
330 }
331
332 public void setMiles(Integer miles) {
333 this.miles = miles;
334 }
335
336
337
338
339
340
341 public KualiDecimal getBreakfastValue() {
342 if (ObjectUtils.isNotNull(breakfastValue) && this.breakfastValue.isGreaterThan(KualiDecimal.ZERO)) {
343 return breakfastValue;
344 }
345
346 return KualiDecimal.ZERO;
347 }
348
349 public KualiDecimal getBreakfastValue(boolean defaultZero) {
350 return defaultZero? getBreakfastValue() : breakfastValue;
351 }
352
353
354
355
356
357
358 public void setBreakfastValue(KualiDecimal breakfastValue) {
359 this.breakfastValue = breakfastValue;
360 }
361
362
363
364
365
366
367 public KualiDecimal getLunchValue() {
368 if (ObjectUtils.isNotNull(lunchValue) && this.lunchValue.isGreaterThan(KualiDecimal.ZERO)) {
369 return lunchValue;
370 }
371
372 return KualiDecimal.ZERO;
373 }
374
375 public KualiDecimal getLunchValue(boolean defaultZero) {
376 return defaultZero? getLunchValue() : lunchValue;
377 }
378
379
380
381
382
383
384 public void setLunchValue(KualiDecimal lunchValue) {
385 this.lunchValue = lunchValue;
386 }
387
388
389
390
391
392
393 public KualiDecimal getDinnerValue() {
394 if (ObjectUtils.isNotNull(dinnerValue) && this.dinnerValue.isGreaterThan(KualiDecimal.ZERO)) {
395 return dinnerValue;
396 }
397
398 return KualiDecimal.ZERO;
399 }
400
401 public KualiDecimal getDinnerValue(boolean defaultZero) {
402 return defaultZero? getDinnerValue() : dinnerValue;
403 }
404
405
406
407
408
409
410 public void setDinnerValue(KualiDecimal dinnerValue) {
411 this.dinnerValue = dinnerValue;
412 }
413
414
415
416
417
418
419
420
421
422
423
424 @Column(name = "MILEAGE_RT_ID", precision = 19, scale = 2, nullable = false)
425 public Integer getMileageRateId() {
426 return mileageRateId;
427 }
428
429 public void setMileageRateId(Integer mileageRateId) {
430 this.mileageRateId = mileageRateId;
431 }
432
433 @Column(name = "MILEAGE_TOT", precision = 19, scale = 2, nullable = false)
434 public KualiDecimal getMileageTotal() {
435 KualiDecimal total = KualiDecimal.ZERO;
436 if (!personal) {
437 if (ObjectUtils.isNotNull(this.mileageRateId) && ObjectUtils.isNotNull(this.miles) && this.miles > 0) {
438 this.refreshReferenceObject("mileageRate");
439
440 }
441 }
442
443 return total;
444 }
445
446 public KualiDecimal getDailyTotal() {
447 KualiDecimal total = KualiDecimal.ZERO;
448 if (!personal) {
449 total = total.add(this.getMileageTotal());
450 total = total.add(this.getLodging());
451 total = total.add(getMealsAndIncidentals());
452 }
453
454 return total;
455 }
456
457
458
459
460
461
462 public KualiDecimal getMealsTotal() {
463 KualiDecimal total = KualiDecimal.ZERO;
464 if (!personal) {
465 if (breakfast) {
466 total = total.add(this.getBreakfastValue());
467 }
468 if (lunch) {
469 total = total.add(this.getLunchValue());
470 }
471 if (dinner) {
472 total = total.add(this.getDinnerValue());
473 }
474 }
475 return total;
476 }
477
478
479
480
481
482
483 public KualiDecimal getLodgingTotal() {
484 if (!personal) {
485 return this.getLodging();
486 }
487 return KualiDecimal.ZERO;
488 }
489
490
491
492
493
494
495
496
497 @Column(name = "MLG_DT")
498 public Timestamp getMileageDate() {
499 return mileageDate;
500 }
501
502 public KualiDecimal getMealsAndIncidentals() {
503 KualiDecimal total = KualiDecimal.ZERO;
504 if (!personal) {
505 total = total.add(getMealsTotal());
506 total = total.add(getIncidentalsValue());
507 }
508 return total;
509 }
510
511
512 public static KualiDecimal calculateMealsAndIncidentalsProrated(KualiDecimal total, Integer perDiemPercent) {
513 KualiDecimal percent = new KualiDecimal(perDiemPercent).divide(new KualiDecimal(100));
514 total = total.multiply(percent);
515 return total;
516 }
517
518
519
520
521
522
523 public void setMealsAndIncidentals(KualiDecimal mealsAndIncidentals) {
524 KualiDecimal meal = mealsAndIncidentals.divide(new KualiDecimal(4));
525 setBreakfastValue(meal);
526 setLunchValue(meal);
527 setDinnerValue(meal);
528 setIncidentalsValue(mealsAndIncidentals.subtract(getMealsTotal()));
529 }
530
531
532
533
534
535
536 @Column(name = "PERSONAL", nullable = false, length = 1)
537 public Boolean getPersonal() {
538 return personal;
539 }
540
541
542
543
544
545
546 public void setPersonal(Boolean personal) {
547 this.personal = personal;
548 }
549
550
551
552
553
554
555 public void setMileageDate(final Timestamp mileageDate) {
556 this.mileageDate = mileageDate;
557 }
558
559 protected LinkedHashMap toStringMapper() {
560 LinkedHashMap map = new LinkedHashMap();
561 map.put("id", id);
562 map.put("countryState", this.countryState);
563 map.put("county", this.county);
564 map.put("primaryDestination", this.primaryDestination);
565
566 return map;
567 }
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637 public void setIncidentalsWithMealsOnly(Boolean incidentalsWithMealsOnly) {
638 this.incidentalsWithMealsOnly = incidentalsWithMealsOnly;
639 }
640
641
642
643
644
645
646 public KualiDecimal getIncidentalsValue() {
647
648 if (ObjectUtils.isNotNull(incidentalsValue) && this.incidentalsValue.isGreaterThan(KualiDecimal.ZERO)) {
649 return incidentalsValue;
650 }
651
652
653 return KualiDecimal.ZERO;
654 }
655
656 public KualiDecimal getIncidentalsValue(boolean defaultZero) {
657 return defaultZero? getIncidentalsValue() : incidentalsValue;
658 }
659
660 public void setIncidentalsValue(KualiDecimal incidentalsValue) {
661 this.incidentalsValue = incidentalsValue;
662 }
663
664 public boolean isProrated() {
665
666
667
668
669 return prorated;
670 }
671
672 public void setProrated(boolean prorated) {
673 this.prorated = prorated;
674 }
675 }