View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.sampleu.travel.dataobject;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.krad.bo.DataObjectBase;
20  import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
21  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
22  import org.kuali.rice.krad.data.provider.annotation.Description;
23  import org.kuali.rice.krad.data.provider.annotation.InheritProperties;
24  import org.kuali.rice.krad.data.provider.annotation.InheritProperty;
25  import org.kuali.rice.krad.data.provider.annotation.Label;
26  import org.kuali.rice.krad.data.provider.annotation.Relationship;
27  import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType;
28  import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews;
29  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint;
30  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType;
31  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints;
32  import org.kuali.rice.krad.data.provider.annotation.UifValidCharactersConstraintBeanName;
33  
34  import javax.persistence.CascadeType;
35  import javax.persistence.Column;
36  import javax.persistence.Convert;
37  import javax.persistence.Entity;
38  import javax.persistence.FetchType;
39  import javax.persistence.GeneratedValue;
40  import javax.persistence.Id;
41  import javax.persistence.JoinColumn;
42  import javax.persistence.ManyToOne;
43  import javax.persistence.Table;
44  import javax.persistence.Temporal;
45  import javax.persistence.TemporalType;
46  import java.io.Serializable;
47  import java.math.BigDecimal;
48  import java.util.Date;
49  
50  /**
51   * This class provides the expense items.
52   *
53   * @author Kuali Rice Team (rice.collab@kuali.org)
54   */
55  @Entity
56  @Table(name = "TRVL_EXP_ITM_T")
57  @UifAutoCreateViews({UifAutoCreateViewType.INQUIRY, UifAutoCreateViewType.LOOKUP})
58  public class TravelExpenseItem extends DataObjectBase implements Serializable {
59  
60      private static final long serialVersionUID = -4092206384418712220L;
61  
62      @Id
63      @Column(name = "EXP_ITM_ID", length = 10)
64      @GeneratedValue(generator = "TRVL_EXP_ITM_ID_S")
65      @PortableSequenceGenerator(name = "TRVL_EXP_ITM_ID_S")
66      @Label("Id")
67      @Description("Unique identifier for item")
68      @UifValidCharactersConstraintBeanName("AlphaNumericPatternConstraint")
69      private String travelExpenseItemId;
70  
71      @Column(name="TRVL_AUTH_DOC_ID", length=40)
72      @Label("Travel Authorization Document Id")
73      @UifDisplayHints({
74              @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT),
75              @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)})
76      private String travelAuthorizationDocumentId;
77  
78      @Relationship(foreignKeyFields="travelAuthorizationDocumentId")
79      @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
80      @JoinColumn(name = "TRVL_AUTH_DOC_ID", referencedColumnName = "TRVL_AUTH_DOC_ID", insertable = false, updatable = false)
81      @InheritProperties({
82              @InheritProperty(name="documentNumber",
83                      label=@Label("Travel Authorization Document"),
84                      displayHints=@UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA)))})
85      private TravelAuthorizationDocument travelAuthorizationDocument;
86  
87      @Column(name = "TRVL_CO_NM")
88      private String travelCompanyName;
89  
90      @Column(name = "EXP_TYP_CD", length = 10)
91      @Label("Expense Type")
92      @Description("Type of expense")
93      private String travelExpenseTypeCd;
94  
95      @Column(name = "EXP_DESC", length = 10)
96      @Label("Expense Description")
97      @Description("Description of expense")
98      private String expenseDesc;
99  
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 }