001 /**
002 * Copyright 2004-2013 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.hr.time.calendar;
017
018 import java.math.BigDecimal;
019
020 import org.kuali.hr.lm.LMConstants;
021 import org.kuali.hr.lm.leaveblock.LeaveBlock;
022 import org.kuali.hr.time.service.base.TkServiceLocator;
023 import org.kuali.rice.krad.util.ObjectUtils;
024
025 import static org.kuali.hr.time.service.base.TkServiceLocator.*;
026
027 public class LeaveBlockRenderer {
028 private LeaveBlock leaveBlock;
029 private String assignmentClass;
030 //private boolean readOnly;
031
032 public LeaveBlockRenderer(LeaveBlock leaveBlock) {
033 this.leaveBlock = leaveBlock;
034 }
035
036 public LeaveBlock getLeaveBlock() {
037 return leaveBlock;
038 }
039
040 public BigDecimal getHours() {
041 return leaveBlock.getLeaveAmount();
042 }
043
044 public String getEarnCode() {
045 return leaveBlock.getEarnCode();
046 }
047
048 public String getLeaveBlockId() {
049 return leaveBlock.getLmLeaveBlockId();
050 }
051
052 public String getDocumentId() {
053 return leaveBlock.getDocumentId();
054 }
055
056 public String getAssignmentTitle() {
057 return leaveBlock.getAssignmentTitle();
058 }
059
060 public boolean getEditable() {
061 return leaveBlock.isEditable();
062 }
063
064 public boolean getDeletable() {
065 return leaveBlock.isDeletable();
066 }
067
068 public String getAssignmentClass() {
069 return assignmentClass;
070 }
071
072 public void setAssignmentClass(String assignmentClass) {
073 this.assignmentClass = assignmentClass;
074 }
075
076 public String getRequestStatusClass() {
077 return this.leaveBlock.getRequestStatusString().toLowerCase();
078 }
079
080 public String getLeaveBlockDetails() {
081 if (this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE)) {
082 // return "accrual";
083 if(ObjectUtils.isNotNull(leaveBlock.getScheduleTimeOffId()))
084 return TkServiceLocator.getSysSchTimeOffService().getSystemScheduledTimeOff(this.leaveBlock.getScheduleTimeOffId()).getDescr();
085 else
086 return "accrual";
087 }
088 else if(this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.BALANCE_TRANSFER)) {
089 if(this.leaveBlock.getDescription().contains("Forfeited"))
090 return "transfer forfeiture";
091 else if(this.leaveBlock.getDescription().contains("Amount transferred"))
092 return "amount transferred";
093 else if(this.leaveBlock.getDescription().contains("Transferred amount"))
094 return "transferred amount";
095 else
096 return "balance transfer";
097 }
098 else if(this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_PAYOUT)) {
099 if(this.leaveBlock.getDescription().contains("Forfeited"))
100 return "payout forfeiture";
101 else if(this.leaveBlock.getDescription().contains("Amount paid out"))
102 return "amount paid out";
103 else if(this.leaveBlock.getDescription().contains("Payout amount"))
104 return "payout amount";
105 else
106 return "leave payout";
107 }
108 else
109 if(!this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_CALENDAR) &&
110 !this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR))
111 return LMConstants.LEAVE_BLOCK_TYPE_MAP.get(this.leaveBlock.getLeaveBlockType()).toLowerCase();
112 else
113 return getRequestStatusClass();
114
115 }
116
117 public String getDescription() {
118 return leaveBlock.getDescription();
119 }
120
121 }