001    /**
002     * Copyright 2004-2013 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 org.kuali.hr.lm.leavepayout.web;
017    
018    import java.math.BigDecimal;
019    import java.sql.Date;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    import org.apache.commons.lang.StringUtils;
024    import org.kuali.hr.lm.LMConstants;
025    import org.kuali.hr.lm.accrual.AccrualCategory;
026    import org.kuali.hr.lm.leavepayout.LeavePayout;
027    import org.kuali.hr.time.earncode.EarnCode;
028    import org.kuali.hr.time.service.base.TkServiceLocator;
029    import org.kuali.rice.kns.util.ActionFormUtilMap;
030    import org.kuali.rice.kns.util.WebUtils;
031    import org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase;
032    
033    public class LeavePayoutForm extends KualiTransactionalDocumentFormBase {
034    
035            /**
036             * 
037             */
038            private static final long serialVersionUID = 1L;
039            private LeavePayout leavePayout;
040            private String leavePayoutId;
041            private String accrualCategoryRule;
042            private String principalId;
043            private String earnCode;
044            private String fromAccrualCategory;
045            private BigDecimal payoutAmount;
046            private BigDecimal forfeitedAmount;
047            private Date effectiveDate;
048            private String leaveCalendarDocumentId;
049            private String type;
050            private boolean onLeaveApproval;
051            private boolean timesheet;
052            
053            public Date getEffectiveDate() {
054                    return effectiveDate;
055            }
056    
057            public void setEffectiveDate(Date effectiveDate) {
058                    this.effectiveDate = effectiveDate;
059            }
060            
061            public String getPrincipalId() {
062                    return principalId;
063            }
064    
065            public void setPrincipalId(String principalId) {
066                    this.principalId = principalId;
067            }
068    
069            public String getEarnCode() {
070                    return earnCode;
071            }
072    
073            public void setEarnCode(String earnCode) {
074                    this.earnCode = earnCode;
075            }
076    
077            public String getFromAccrualCategory() {
078                    return fromAccrualCategory;
079            }
080    
081            public void setFromAccrualCategory(String fromAccrualCategory) {
082                    this.fromAccrualCategory = fromAccrualCategory;
083            }
084    
085            public BigDecimal getPayoutAmount() {
086                    return payoutAmount;
087            }
088    
089            public void setPayoutAmount(BigDecimal payoutAmount) {
090                    this.payoutAmount = payoutAmount;
091            }
092    
093            public BigDecimal getForfeitedAmount() {
094                    return forfeitedAmount;
095            }
096    
097            public void setForfeitedAmount(BigDecimal forfeitedAmount) {
098                    this.forfeitedAmount = forfeitedAmount;
099            }
100            
101            public String getLeavePayoutId() {
102                    return leavePayoutId;
103            }
104    
105            public void setLeavePayoutId(String leavePayoutId) {
106                    this.leavePayoutId = leavePayoutId;
107            }
108            
109            public String getAccrualCategoryRule() {
110                    return accrualCategoryRule;
111            }
112    
113            public void setAccrualCategoryRule(String accrualCategoryRule) {
114                    this.accrualCategoryRule = accrualCategoryRule;
115            }
116    
117            public EarnCode getPayoutEarnCodeObj() {
118                    return TkServiceLocator.getEarnCodeService().getEarnCode(earnCode, effectiveDate);
119            }
120    
121            public AccrualCategory getDebitedAccrualCategory() {
122                    return TkServiceLocator.getAccrualCategoryService().getAccrualCategory(fromAccrualCategory, effectiveDate);
123            }
124            
125        @Override
126        public String getBackLocation() {
127            return "LeaveCalendarSubmit.do?methodToCall=approveLeaveCalendar";
128        }
129    
130        @Override
131        public void populate(HttpServletRequest request) {
132            super.populate(request);
133            ((ActionFormUtilMap) getActionFormUtilMap()).setCacheValueFinderResults(false);
134    
135            if (this.getMethodToCall() == null || StringUtils.isEmpty(this.getMethodToCall())) {
136                setMethodToCall(WebUtils.parseMethodToCall(this, request));
137            }
138        }   
139            
140            @Override
141            public void addRequiredNonEditableProperties() {
142                    super.addRequiredNonEditableProperties();
143            }
144    
145            public LeavePayout getLeavePayout() {
146                    return leavePayout;
147            }
148    
149            public void setLeavePayout(LeavePayout leavePayout) {
150                    this.leavePayout = leavePayout;
151            }
152    
153            public String getLeaveCalendarDocumentId() {
154                    return leaveCalendarDocumentId;
155            }
156    
157            public void setLeaveCalendarDocumentId(String leaveCalendarDocId) {
158                    this.leaveCalendarDocumentId = leaveCalendarDocId;
159            }
160    
161            public String getType() {
162                    return type;
163            }
164    
165            public void setType(String type) {
166                    this.type = type;
167            }
168    
169            public boolean isOnLeaveApproval() {
170                    if(StringUtils.equals(type, LMConstants.MAX_BAL_ACTION_FREQ.LEAVE_APPROVE))
171                            return true;
172                    else
173                            return false;
174                    //Will return false if MAX_BAL_ACTION_FREQ is YEAR_END, but for purposes of the leave calendar, YEAR_END is not
175                    //transferable.
176            }
177    
178            public void setOnLeaveApproval(boolean onLeaveApproval) {
179                    this.onLeaveApproval = onLeaveApproval;
180            }
181    
182            public void isTimesheet(boolean b) {
183                    timesheet = true;
184            }
185    
186    
187    }