View Javadoc

1   /**
2    * Copyright 2004-2013 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 org.kuali.hr.lm.leavepayout.web;
17  
18  import java.math.BigDecimal;
19  import java.sql.Date;
20  
21  import javax.servlet.http.HttpServletRequest;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.kuali.hr.lm.LMConstants;
25  import org.kuali.hr.lm.accrual.AccrualCategory;
26  import org.kuali.hr.lm.leavepayout.LeavePayout;
27  import org.kuali.hr.time.earncode.EarnCode;
28  import org.kuali.hr.time.service.base.TkServiceLocator;
29  import org.kuali.rice.kns.util.ActionFormUtilMap;
30  import org.kuali.rice.kns.util.WebUtils;
31  import org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase;
32  
33  public class LeavePayoutForm extends KualiTransactionalDocumentFormBase {
34  
35  	/**
36  	 * 
37  	 */
38  	private static final long serialVersionUID = 1L;
39  	private LeavePayout leavePayout;
40  	private String leavePayoutId;
41  	private String accrualCategoryRule;
42  	private String principalId;
43  	private String earnCode;
44  	private String fromAccrualCategory;
45  	private BigDecimal payoutAmount;
46  	private BigDecimal forfeitedAmount;
47  	private Date effectiveDate;
48  	private String leaveCalendarDocumentId;
49  	private String type;
50  	private boolean onLeaveApproval;
51  	private boolean timesheet;
52  	
53  	public Date getEffectiveDate() {
54  		return effectiveDate;
55  	}
56  
57  	public void setEffectiveDate(Date effectiveDate) {
58  		this.effectiveDate = effectiveDate;
59  	}
60  	
61  	public String getPrincipalId() {
62  		return principalId;
63  	}
64  
65  	public void setPrincipalId(String principalId) {
66  		this.principalId = principalId;
67  	}
68  
69  	public String getEarnCode() {
70  		return earnCode;
71  	}
72  
73  	public void setEarnCode(String earnCode) {
74  		this.earnCode = earnCode;
75  	}
76  
77  	public String getFromAccrualCategory() {
78  		return fromAccrualCategory;
79  	}
80  
81  	public void setFromAccrualCategory(String fromAccrualCategory) {
82  		this.fromAccrualCategory = fromAccrualCategory;
83  	}
84  
85  	public BigDecimal getPayoutAmount() {
86  		return payoutAmount;
87  	}
88  
89  	public void setPayoutAmount(BigDecimal payoutAmount) {
90  		this.payoutAmount = payoutAmount;
91  	}
92  
93  	public BigDecimal getForfeitedAmount() {
94  		return forfeitedAmount;
95  	}
96  
97  	public void setForfeitedAmount(BigDecimal forfeitedAmount) {
98  		this.forfeitedAmount = forfeitedAmount;
99  	}
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 		// TODO Auto-generated method stub
143 		System.out.println("*******************************************");
144 		System.out.println("* Adding required non editable properties *");
145 		System.out.println("*******************************************");
146 		super.addRequiredNonEditableProperties();
147 	}
148 
149 	public LeavePayout getLeavePayout() {
150 		return leavePayout;
151 	}
152 
153 	public void setLeavePayout(LeavePayout leavePayout) {
154 		this.leavePayout = leavePayout;
155 	}
156 
157 	public String getLeaveCalendarDocumentId() {
158 		return leaveCalendarDocumentId;
159 	}
160 
161 	public void setLeaveCalendarDocumentId(String leaveCalendarDocId) {
162 		this.leaveCalendarDocumentId = leaveCalendarDocId;
163 	}
164 
165 	public String getType() {
166 		return type;
167 	}
168 
169 	public void setType(String type) {
170 		this.type = type;
171 	}
172 
173 	public boolean isOnLeaveApproval() {
174 		if(StringUtils.equals(type, LMConstants.MAX_BAL_ACTION_FREQ.LEAVE_APPROVE))
175 			return true;
176 		else
177 			return false;
178 		//Will return false if MAX_BAL_ACTION_FREQ is YEAR_END, but for purposes of the leave calendar, YEAR_END is not
179 		//transferable.
180 	}
181 
182 	public void setOnLeaveApproval(boolean onLeaveApproval) {
183 		this.onLeaveApproval = onLeaveApproval;
184 	}
185 
186 	public void isTimesheet(boolean b) {
187 		timesheet = true;
188 	}
189 
190 
191 }