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