View Javadoc
1   /**
2    * Copyright 2005-2014 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 edu.sampleu.travel.options.MileageRateKeyValues;
19  import edu.sampleu.travel.options.TravelDestinationKeyValues;
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.rice.krad.bo.DataObjectBase;
22  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
23  import org.kuali.rice.krad.data.provider.annotation.Description;
24  import org.kuali.rice.krad.data.provider.annotation.InheritProperties;
25  import org.kuali.rice.krad.data.provider.annotation.InheritProperty;
26  import org.kuali.rice.krad.data.provider.annotation.KeyValuesFinderClass;
27  import org.kuali.rice.krad.data.provider.annotation.Label;
28  import org.kuali.rice.krad.data.provider.annotation.Relationship;
29  import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType;
30  import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews;
31  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint;
32  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType;
33  import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints;
34  import org.kuali.rice.krad.data.provider.annotation.UifValidCharactersConstraintBeanName;
35  
36  import javax.persistence.CascadeType;
37  import javax.persistence.Column;
38  import javax.persistence.Entity;
39  import javax.persistence.FetchType;
40  import javax.persistence.GeneratedValue;
41  import javax.persistence.Id;
42  import javax.persistence.JoinColumn;
43  import javax.persistence.ManyToOne;
44  import javax.persistence.Table;
45  import javax.persistence.Temporal;
46  import javax.persistence.TemporalType;
47  import java.io.Serializable;
48  import java.math.BigDecimal;
49  import java.util.Date;
50  
51  /**
52   * This class provides the per diem expenses.
53   *
54   * @author Kuali Rice Team (rice.collab@kuali.org)
55   */
56  @Entity
57  @Table(name = "TRVL_PD_EXP_T")
58  @UifAutoCreateViews({UifAutoCreateViewType.INQUIRY, UifAutoCreateViewType.LOOKUP})
59  public class TravelPerDiemExpense extends DataObjectBase implements Serializable {
60  
61      private static final long serialVersionUID = 6269893036439679855L;
62  
63      @Id
64      @Column(name = "PD_EXP_ID", length = 10)
65      @GeneratedValue(generator = "TRVL_PD_EXP_ID_S")
66      @PortableSequenceGenerator(name = "TRVL_PD_EXP_ID_S")
67      @Label("Id")
68      @Description("Unique identifier for per diem expense item")
69      @UifValidCharactersConstraintBeanName("AlphaNumericPatternConstraint")
70      private String travelPerDiemExpenseId;
71  
72      @Column(name="TRVL_AUTH_DOC_ID", length=40)
73      @Label("Travel Authorization Document Id")
74      @UifDisplayHints({
75              @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT),
76              @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)})
77      private String travelAuthorizationDocumentId;
78  
79      @Relationship(foreignKeyFields="travelAuthorizationDocumentId")
80      @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH})
81      @JoinColumn(name = "TRVL_AUTH_DOC_ID", referencedColumnName = "TRVL_AUTH_DOC_ID",  insertable = false, updatable = false)
82      @InheritProperties({
83              @InheritProperty(name="documentNumber",
84                      label=@Label("Travel Authorization Document"),
85                      displayHints=@UifDisplayHints(@UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA)))})
86      private TravelAuthorizationDocument travelAuthorizationDocument;
87  
88      @Column(name="TRVL_DEST_ID", length=40)
89      @Label("Primary Destination")
90      @Description("Primary Destination related to per diem expense")
91      @KeyValuesFinderClass(TravelDestinationKeyValues.class)
92      @UifDisplayHints({
93              @UifDisplayHint(UifDisplayHintType.NONE),
94              @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT),
95              @UifDisplayHint(UifDisplayHintType.NO_INQUIRY)})
96      private String travelDestinationId;
97  
98      @Relationship(foreignKeyFields="travelDestinationId")
99      @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 }