001/** 002 * Copyright 2005-2016 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 */ 016package edu.sampleu.travel.dataobject; 017 018import edu.sampleu.travel.options.MileageRateKeyValues; 019import edu.sampleu.travel.options.TravelDestinationKeyValues; 020import org.apache.commons.lang.StringUtils; 021import org.kuali.rice.krad.bo.DataObjectBase; 022import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 023import org.kuali.rice.krad.data.provider.annotation.Description; 024import org.kuali.rice.krad.data.provider.annotation.InheritProperties; 025import org.kuali.rice.krad.data.provider.annotation.InheritProperty; 026import org.kuali.rice.krad.data.provider.annotation.KeyValuesFinderClass; 027import org.kuali.rice.krad.data.provider.annotation.Label; 028import org.kuali.rice.krad.data.provider.annotation.Relationship; 029import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType; 030import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews; 031import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint; 032import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType; 033import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints; 034import org.kuali.rice.krad.data.provider.annotation.UifValidCharactersConstraintBeanName; 035 036import javax.persistence.CascadeType; 037import javax.persistence.Column; 038import javax.persistence.Entity; 039import javax.persistence.FetchType; 040import javax.persistence.GeneratedValue; 041import javax.persistence.Id; 042import javax.persistence.JoinColumn; 043import javax.persistence.ManyToOne; 044import javax.persistence.Table; 045import javax.persistence.Temporal; 046import javax.persistence.TemporalType; 047import java.io.Serializable; 048import java.math.BigDecimal; 049import java.util.Date; 050 051/** 052 * This class provides the per diem expenses. 053 * 054 * @author Kuali Rice Team (rice.collab@kuali.org) 055 */ 056@Entity 057@Table(name = "TRVL_PD_EXP_T") 058@UifAutoCreateViews({UifAutoCreateViewType.INQUIRY, UifAutoCreateViewType.LOOKUP}) 059public class TravelPerDiemExpense extends DataObjectBase implements Serializable { 060 061 private static final long serialVersionUID = 6269893036439679855L; 062 063 @Id 064 @Column(name = "PD_EXP_ID", length = 10) 065 @GeneratedValue(generator = "TRVL_PD_EXP_ID_S") 066 @PortableSequenceGenerator(name = "TRVL_PD_EXP_ID_S") 067 @Label("Id") 068 @Description("Unique identifier for per diem expense item") 069 @UifValidCharactersConstraintBeanName("AlphaNumericPatternConstraint") 070 private String travelPerDiemExpenseId; 071 072 @Column(name="TRVL_AUTH_DOC_ID", length=40) 073 @Label("Travel Authorization Document Id") 074 @UifDisplayHints({ 075 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT), 076 @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)}) 077 private String travelAuthorizationDocumentId; 078 079 @Relationship(foreignKeyFields="travelAuthorizationDocumentId") 080 @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH}) 081 @JoinColumn(name = "TRVL_AUTH_DOC_ID", referencedColumnName = "TRVL_AUTH_DOC_ID", insertable = false, updatable = false) 082 @InheritProperties({ 083 @InheritProperty(name="documentNumber", 084 label=@Label("Travel Authorization Document"), 085 displayHints=@UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA)))}) 086 private TravelAuthorizationDocument travelAuthorizationDocument; 087 088 @Column(name="TRVL_DEST_ID", length=40) 089 @Label("Primary Destination") 090 @Description("Primary Destination related to per diem expense") 091 @KeyValuesFinderClass(TravelDestinationKeyValues.class) 092 @UifDisplayHints({ 093 @UifDisplayHint(UifDisplayHintType.NONE), 094 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT), 095 @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)}) 096 private String travelDestinationId; 097 098 @Relationship(foreignKeyFields="travelDestinationId") 099 @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH}) 100 @JoinColumn(name="TRVL_DEST_ID", insertable=false, updatable=false) 101 @InheritProperties({ 102 @InheritProperty(name="travelDestinationId", 103 label=@Label("Primary Destination"), 104 displayHints=@UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA)))}) 105 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA) 106 private TravelDestination travelDestination; 107 108 @Temporal(TemporalType.TIMESTAMP) 109 @Column(name = "PD_DT") 110 @Label("Date of Use") 111 private Date perDiemDate; 112 113 @Column(name = "BKFST_VAL") 114 @Label("Breakfast Value") 115 private BigDecimal breakfastValue; 116 117 @Column(name = "LNCH_VAL") 118 @Label("Lunch Value") 119 private BigDecimal lunchValue; 120 121 @Column(name = "DNNR_VAL") 122 @Label("Dinner Value") 123 private BigDecimal dinnerValue; 124 125 @Column(name = "INCD_VAL") 126 @Label("Amount estimated for incidentals") 127 private BigDecimal incidentalsValue; 128 129 @Column(name="MLG_RT_ID", length=40) 130 @Label("Mileage Rate") 131 @Description("Mileage Rate Code Used") 132 @KeyValuesFinderClass(MileageRateKeyValues.class) 133 @UifDisplayHints({ 134 @UifDisplayHint(UifDisplayHintType.NONE), 135 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT), 136 @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)}) 137 private String mileageRateId; 138 139 @Relationship(foreignKeyFields="mileageRateId") 140 @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH}) 141 @JoinColumn(name="MLG_RT_ID", insertable=false, updatable=false) 142 @InheritProperties({ 143 @InheritProperty(name="mileageRateCd", 144 label=@Label("Mileage rate"), 145 displayHints=@UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA)))}) 146 private TravelMileageRate mileageRate; 147 148 @Column(name = "MLG_EST") 149 @Label("Number of estimated miles") 150 private BigDecimal estimatedMileage; 151 152 public String getTravelPerDiemExpenseId() { 153 return travelPerDiemExpenseId; 154 } 155 156 public void setTravelPerDiemExpenseId(String travelPerDiemExpenseId) { 157 this.travelPerDiemExpenseId = travelPerDiemExpenseId; 158 } 159 160 public String getTravelAuthorizationDocumentId() { 161 if (StringUtils.isBlank(travelAuthorizationDocumentId) 162 && this.travelAuthorizationDocument != null) { 163 return this.travelAuthorizationDocument.getDocumentNumber(); 164 } 165 166 return travelAuthorizationDocumentId; 167 } 168 169 public void setTravelAuthorizationDocumentId(String travelAuthorizationDocumentId) { 170 this.travelAuthorizationDocumentId = travelAuthorizationDocumentId; 171 } 172 173 public TravelAuthorizationDocument getTravelAuthorizationDocument() { 174 return travelAuthorizationDocument; 175 } 176 177 public void setTravelAuthorizationDocument(TravelAuthorizationDocument travelAuthorizationDocument) { 178 this.travelAuthorizationDocument = travelAuthorizationDocument; 179 } 180 181 public Date getPerDiemDate() { 182 return perDiemDate; 183 } 184 185 public void setPerDiemDate(Date perDiemDate) { 186 this.perDiemDate = perDiemDate; 187 } 188 189 public BigDecimal getBreakfastValue() { 190 return breakfastValue; 191 } 192 193 public void setBreakfastValue(BigDecimal breakfastValue) { 194 this.breakfastValue = breakfastValue; 195 } 196 197 public BigDecimal getLunchValue() { 198 return lunchValue; 199 } 200 201 public void setLunchValue(BigDecimal lunchValue) { 202 this.lunchValue = lunchValue; 203 } 204 205 public BigDecimal getDinnerValue() { 206 return dinnerValue; 207 } 208 209 public void setDinnerValue(BigDecimal dinnerValue) { 210 this.dinnerValue = dinnerValue; 211 } 212 213 public BigDecimal getIncidentalsValue() { 214 return incidentalsValue; 215 } 216 217 public void setIncidentalsValue(BigDecimal incidentalsValue) { 218 this.incidentalsValue = incidentalsValue; 219 } 220 221 public String getTravelDestinationId() { 222 return travelDestinationId; 223 } 224 225 public void setTravelDestinationId(String travelDestinationId) { 226 this.travelDestinationId = travelDestinationId; 227 } 228 229 public TravelDestination getTravelDestination() { 230 return travelDestination; 231 } 232 233 public void setTravelDestination(TravelDestination travelDestination) { 234 this.travelDestination = travelDestination; 235 } 236 237 public String getMileageRateId() { 238 return mileageRateId; 239 } 240 241 public void setMileageRateId(String mileageRateId) { 242 this.mileageRateId = mileageRateId; 243 } 244 245 public TravelMileageRate getMileageRate() { 246 return mileageRate; 247 } 248 249 public void setMileageRate(TravelMileageRate mileageRate) { 250 this.mileageRate = mileageRate; 251 } 252 253 public BigDecimal getEstimatedMileage() { 254 return estimatedMileage; 255 } 256 257 public void setEstimatedMileage(BigDecimal estimatedMileage) { 258 this.estimatedMileage = estimatedMileage; 259 } 260}