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 org.apache.commons.lang.StringUtils; 019import org.kuali.rice.krad.bo.DataObjectBase; 020import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter; 021import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 022import org.kuali.rice.krad.data.provider.annotation.Description; 023import org.kuali.rice.krad.data.provider.annotation.InheritProperties; 024import org.kuali.rice.krad.data.provider.annotation.InheritProperty; 025import org.kuali.rice.krad.data.provider.annotation.Label; 026import org.kuali.rice.krad.data.provider.annotation.Relationship; 027import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType; 028import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews; 029import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint; 030import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType; 031import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints; 032import org.kuali.rice.krad.data.provider.annotation.UifValidCharactersConstraintBeanName; 033 034import javax.persistence.CascadeType; 035import javax.persistence.Column; 036import javax.persistence.Convert; 037import javax.persistence.Entity; 038import javax.persistence.FetchType; 039import javax.persistence.GeneratedValue; 040import javax.persistence.Id; 041import javax.persistence.JoinColumn; 042import javax.persistence.ManyToOne; 043import javax.persistence.Table; 044import javax.persistence.Temporal; 045import javax.persistence.TemporalType; 046import java.io.Serializable; 047import java.math.BigDecimal; 048import java.util.Date; 049 050/** 051 * This class provides the expense items. 052 * 053 * @author Kuali Rice Team (rice.collab@kuali.org) 054 */ 055@Entity 056@Table(name = "TRVL_EXP_ITM_T") 057@UifAutoCreateViews({UifAutoCreateViewType.INQUIRY, UifAutoCreateViewType.LOOKUP}) 058public class TravelExpenseItem extends DataObjectBase implements Serializable { 059 060 private static final long serialVersionUID = -4092206384418712220L; 061 062 @Id 063 @Column(name = "EXP_ITM_ID", length = 10) 064 @GeneratedValue(generator = "TRVL_EXP_ITM_ID_S") 065 @PortableSequenceGenerator(name = "TRVL_EXP_ITM_ID_S") 066 @Label("Id") 067 @Description("Unique identifier for item") 068 @UifValidCharactersConstraintBeanName("AlphaNumericPatternConstraint") 069 private String travelExpenseItemId; 070 071 @Column(name="TRVL_AUTH_DOC_ID", length=40) 072 @Label("Travel Authorization Document Id") 073 @UifDisplayHints({ 074 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT), 075 @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)}) 076 private String travelAuthorizationDocumentId; 077 078 @Relationship(foreignKeyFields="travelAuthorizationDocumentId") 079 @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH}) 080 @JoinColumn(name = "TRVL_AUTH_DOC_ID", referencedColumnName = "TRVL_AUTH_DOC_ID", insertable = false, updatable = false) 081 @InheritProperties({ 082 @InheritProperty(name="documentNumber", 083 label=@Label("Travel Authorization Document"), 084 displayHints=@UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA)))}) 085 private TravelAuthorizationDocument travelAuthorizationDocument; 086 087 @Column(name = "TRVL_CO_NM") 088 private String travelCompanyName; 089 090 @Column(name = "EXP_TYP_CD", length = 10) 091 @Label("Expense Type") 092 @Description("Type of expense") 093 private String travelExpenseTypeCd; 094 095 @Column(name = "EXP_DESC", length = 10) 096 @Label("Expense Description") 097 @Description("Description of expense") 098 private String expenseDesc; 099 100 @Temporal(TemporalType.TIMESTAMP) 101 @Column(name = "EXP_DT") 102 @Label("Expense Date") 103 @Description("Date of expense") 104 private Date expenseDate; 105 106 @Column(name = "EXP_AMT", length = 10) 107 @Label("Expense Amount") 108 @Description("Amount of expense") 109 private BigDecimal expenseAmount; 110 111 @Column(name = "EXP_REIMB", nullable = false, length = 1) 112 @Convert(converter = BooleanYNConverter.class) 113 @Label("Reimbursable") 114 @Description("Whether expense is reimbursed to traveler") 115 private boolean reimbursable; 116 117 @Column(name = "EXP_TXBL", nullable = false, length = 1) 118 @Convert(converter = BooleanYNConverter.class) 119 @Label("Taxable") 120 @Description("Whether expense is taxed") 121 private boolean taxable; 122 123 public String getTravelExpenseItemId() { 124 return travelExpenseItemId; 125 } 126 127 public void setTravelExpenseItemId(String travelExpenseItemId) { 128 this.travelExpenseItemId = travelExpenseItemId; 129 } 130 131 public String getTravelAuthorizationDocumentId() { 132 if (StringUtils.isBlank(travelAuthorizationDocumentId) 133 && this.travelAuthorizationDocument != null) { 134 return this.travelAuthorizationDocument.getDocumentNumber(); 135 } 136 137 return travelAuthorizationDocumentId; 138 } 139 140 public void setTravelAuthorizationDocumentId(String travelAuthorizationDocumentId) { 141 this.travelAuthorizationDocumentId = travelAuthorizationDocumentId; 142 } 143 144 public TravelAuthorizationDocument getTravelAuthorizationDocument() { 145 return travelAuthorizationDocument; 146 } 147 148 public void setTravelAuthorizationDocument(TravelAuthorizationDocument travelAuthorizationDocument) { 149 this.travelAuthorizationDocument = travelAuthorizationDocument; 150 } 151 152 public String getTravelCompanyName() { 153 return travelCompanyName; 154 } 155 156 public void setTravelCompanyName(String travelCompanyName) { 157 this.travelCompanyName = travelCompanyName; 158 } 159 160 public String getTravelExpenseTypeCd() { 161 return travelExpenseTypeCd; 162 } 163 164 public void setTravelExpenseTypeCd(String travelExpenseTypeCd) { 165 this.travelExpenseTypeCd = travelExpenseTypeCd; 166 } 167 168 public String getExpenseDesc() { 169 return expenseDesc; 170 } 171 172 public void setExpenseDesc(String expenseDesc) { 173 this.expenseDesc = expenseDesc; 174 } 175 176 public Date getExpenseDate() { 177 return expenseDate; 178 } 179 180 public void setExpenseDate(Date expenseDate) { 181 this.expenseDate = expenseDate; 182 } 183 184 public BigDecimal getExpenseAmount() { 185 return expenseAmount; 186 } 187 188 public void setExpenseAmount(BigDecimal expenseAmount) { 189 this.expenseAmount = expenseAmount; 190 } 191 192 public boolean isReimbursable() { 193 return reimbursable; 194 } 195 196 public void setReimbursable(boolean reimbursable) { 197 this.reimbursable = reimbursable; 198 } 199 200 public boolean isTaxable() { 201 return taxable; 202 } 203 204 public void setTaxable(boolean taxable) { 205 this.taxable = taxable; 206 } 207}