View Javadoc
1   /**
2    * Copyright 2004-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 org.kuali.kpme.tklm.leave.summary;
17  
18  import java.io.Serializable;
19  import java.math.BigDecimal;
20  import java.util.SortedMap;
21  
22  import org.kuali.kpme.tklm.api.leave.summary.LeaveSummaryRowContract;
23  
24  public class LeaveSummaryRow implements Serializable, Comparable<LeaveSummaryRow>, LeaveSummaryRowContract {
25  
26  	private static final long serialVersionUID = 7236801989688508388L;
27  	private String accrualCategory;
28      //adding this to have a very simple means of getting the Accrual Category object
29      private String accrualCategoryId;
30      private String accrualCategoryRuleId;
31      private String infractingLeaveBlockId;
32  	private BigDecimal carryOver;
33  	private BigDecimal ytdAccruedBalance;
34  	private BigDecimal ytdApprovedUsage;
35  	private BigDecimal leaveBalance;
36  	private BigDecimal pendingLeaveAccrual;
37  	private BigDecimal pendingLeaveRequests;
38  	private BigDecimal pendingLeaveBalance;
39  	private BigDecimal pendingAvailableUsage;
40  	private BigDecimal usageLimit;
41  	private BigDecimal fmlaUsage;
42  
43  	private boolean transferable;
44  	private boolean payoutable;
45  	private BigDecimal maxCarryOver;
46      private SortedMap<String, BigDecimal> priorYearsTotalAccrued;
47      private SortedMap<String, BigDecimal> priorYearsUsage;
48  
49  	public String getAccrualCategory() {
50  		return accrualCategory;
51  	}
52  	public void setAccrualCategory(String accrualCategory) {
53  		this.accrualCategory = accrualCategory;
54  	}
55      public String getAccrualCategoryId() {
56          return accrualCategoryId;
57      }
58      public void setAccrualCategoryId(String accrualCategoryId) {
59          this.accrualCategoryId = accrualCategoryId;
60      }
61      public String getAccrualCategoryRuleId() {
62          return accrualCategoryRuleId;
63      }
64  
65      public void setAccrualCategoryRuleId(String accrualCategoryRuleId) {
66          this.accrualCategoryRuleId = accrualCategoryRuleId;
67      }
68  	public BigDecimal getCarryOver() {
69  		return carryOver;
70  	}
71  	public void setCarryOver(BigDecimal carryOver) {
72  		this.carryOver = carryOver;
73  	}
74  	public BigDecimal getYtdAccruedBalance() {
75  		return ytdAccruedBalance;
76  	}
77  	public void setYtdAccruedBalance(BigDecimal ytdAccruedBalance) {
78  		this.ytdAccruedBalance = ytdAccruedBalance;
79  	}
80  	public BigDecimal getYtdApprovedUsage() {
81  		return ytdApprovedUsage;
82  	}
83  	public void setYtdApprovedUsage(BigDecimal ytdApprovedUsage) {
84  		this.ytdApprovedUsage = ytdApprovedUsage;
85  	}
86  	public BigDecimal getLeaveBalance() {
87  		return leaveBalance;
88  	}
89  	public void setLeaveBalance(BigDecimal leaveBalance) {
90  		this.leaveBalance = leaveBalance;
91  	}
92  	public BigDecimal getPendingLeaveAccrual() {
93  		return pendingLeaveAccrual;
94  	}
95  	public void setPendingLeaveAccrual(BigDecimal pendingLeaveAccrual) {
96  		this.pendingLeaveAccrual = pendingLeaveAccrual;
97  	}
98  	public BigDecimal getPendingLeaveRequests() {
99  		return pendingLeaveRequests;
100 	}
101 	public void setPendingLeaveRequests(BigDecimal pendingLeaveRequests) {
102 		this.pendingLeaveRequests = pendingLeaveRequests;
103 	}
104 	public BigDecimal getPendingLeaveBalance() {
105 		return pendingLeaveBalance;
106 	}
107 	public void setPendingLeaveBalance(BigDecimal pendingLeaveBalance) {
108 		this.pendingLeaveBalance = pendingLeaveBalance;
109 	}
110 	public BigDecimal getPendingAvailableUsage() {
111 		return pendingAvailableUsage;
112 	}
113 	public void setPendingAvailableUsage(BigDecimal pendingAvailableUsage) {
114 		this.pendingAvailableUsage = pendingAvailableUsage;
115 	}
116 	public BigDecimal getUsageLimit() {
117 		return usageLimit;
118 	}
119 	public void setUsageLimit(BigDecimal usageLimit) {
120 		this.usageLimit = usageLimit;
121 	}
122 	public BigDecimal getFmlaUsage() {
123 		return fmlaUsage;
124 	}
125 	public void setFmlaUsage(BigDecimal fmlaUsage) {
126 		this.fmlaUsage = fmlaUsage;
127 	}
128     public BigDecimal getAccruedBalance() {
129         BigDecimal carryOver = getCarryOver() == null ? BigDecimal.ZERO : getCarryOver();
130         BigDecimal ytdAccruedBalance = getYtdAccruedBalance() == null ? BigDecimal.ZERO : getYtdAccruedBalance();
131         BigDecimal ytdApproved = getYtdApprovedUsage() == null ? BigDecimal.ZERO : getYtdApprovedUsage();
132         return carryOver.add(ytdAccruedBalance).subtract(ytdApproved);
133     }
134 	public boolean isTransferable() {
135 		//Leave summary row has all the necessary information to answer the question
136 		//"Is my accrued balance eligible for transfer?". Should implement this method
137 		//to check for rule presence, max balance flag = Y, action at max bal = T
138 		//essentially move logic from BalanceTransferService.getAccrualCategoryRuleIdsForEligibleTransfers.
139 		//having this implemented might be less costly to call on.
140 		return transferable;
141 	}
142 	public void setTransferable(boolean transferable) {
143 		this.transferable = transferable;
144 	}
145 	public boolean isPayoutable() {
146 		return payoutable;
147 	}
148 	public void setPayoutable(boolean payoutable) {
149 		this.payoutable = payoutable;
150 	}
151 
152 
153     public SortedMap<String, BigDecimal> getPriorYearsUsage() {
154         return priorYearsUsage;
155     }
156 
157     public void setPriorYearsUsage(SortedMap<String, BigDecimal> priorYearsUsage) {
158         this.priorYearsUsage = priorYearsUsage;
159     }
160 
161     public SortedMap<String, BigDecimal> getPriorYearsTotalAccrued() {
162         return priorYearsTotalAccrued;
163     }
164 
165     public void setPriorYearsTotalAccrued(SortedMap<String, BigDecimal> priorYearsTotalAccrued) {
166         this.priorYearsTotalAccrued = priorYearsTotalAccrued;
167     }
168     
169 	public BigDecimal getMaxCarryOver() {
170 		return maxCarryOver;
171 	}
172 	
173 	public void setMaxCarryOver(BigDecimal maxCarryOver) {
174 		this.maxCarryOver = maxCarryOver;
175 	}
176 	
177 	public String getInfractingLeaveBlockId() {
178 		return infractingLeaveBlockId;
179 	}
180 	
181 	public void setInfractingLeaveBlockId(String infractingLeaveBlockId) {
182 		this.infractingLeaveBlockId = infractingLeaveBlockId;
183 	}
184 	@Override
185 	public int compareTo(LeaveSummaryRow row) {
186 		return this.accrualCategory.compareToIgnoreCase(row.accrualCategory);
187 	}
188 }