1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.calendar;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.hr.lm.timeoff.SystemScheduledTimeOff;
20 import org.kuali.hr.time.principal.PrincipalHRAttributes;
21 import org.kuali.hr.time.service.base.TkServiceLocator;
22 import org.kuali.hr.time.timeblock.TimeBlock;
23 import org.kuali.hr.time.timeblock.TimeHourDetail;
24 import org.kuali.hr.time.util.TKContext;
25 import org.kuali.hr.time.util.TkConstants;
26 import org.kuali.hr.time.workflow.TimesheetDocumentHeader;
27
28 import java.util.List;
29
30 public class TimeHourDetailRenderer {
31 private TimeHourDetail timeHourDetail;
32 private boolean overtimeEarnCode;
33
34 public TimeHourDetailRenderer(TimeHourDetail d) {
35 this.timeHourDetail = d;
36 List<String> ovtEarnCodes = TkServiceLocator.getEarnCodeService().getOvertimeEarnCodesStrs(TKContext.getCurrentTimesheetDocument().getAsOfDate());
37 setOvertimeEarnCode(ovtEarnCodes.contains(d.getEarnCode()));
38 }
39
40 public TimeHourDetail getTimeHourDetail() {
41 return timeHourDetail;
42 }
43
44 public String getTkTimeHourDetailId() {
45 return timeHourDetail.getTkTimeHourDetailId();
46 }
47
48 public String getTitle() {
49 return timeHourDetail.getEarnCode();
50 }
51
52 public String getHours() {
53 return timeHourDetail.getHours().toString();
54 }
55
56 public String getAmount() {
57 return timeHourDetail.getAmount().toString();
58 }
59
60 public String getHolidayName() {
61 String holidayDesc = "";
62 TimeBlock timeBlock = TkServiceLocator.getTimeBlockService().getTimeBlock(timeHourDetail.getTkTimeBlockId());
63
64 if ( timeBlock != null ){
65 if(timeBlock.getEarnCode().equals(TkConstants.HOLIDAY_EARN_CODE)) {
66 String documentId = timeBlock.getDocumentId();
67 TimesheetDocumentHeader docHeader = TkServiceLocator.getTimesheetDocumentHeaderService().getDocumentHeader(documentId);
68 PrincipalHRAttributes principalCalendar = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalCalendar(docHeader.getPrincipalId(), new java.sql.Date(timeBlock.getBeginDate().getTime()));
69
70 if(principalCalendar != null && StringUtils.isNotEmpty(principalCalendar.getLeavePlan())) {
71 SystemScheduledTimeOff ssto = TkServiceLocator.getSysSchTimeOffService().getSystemScheduledTimeOffByDate(principalCalendar.getLeavePlan(), timeBlock.getBeginDate());
72 if(ssto != null) {
73 holidayDesc = ssto.getDescr();
74 }
75 }
76 }
77 }
78
79 return holidayDesc;
80 }
81
82 public boolean isOvertimeEarnCode() {
83 return overtimeEarnCode;
84 }
85
86 public void setOvertimeEarnCode(boolean overtimeEarnCode) {
87 this.overtimeEarnCode = overtimeEarnCode;
88 }
89
90 }