001 /** 002 * Copyright 2004-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 org.kuali.kpme.tklm.leave.payout; 017 018 import static org.junit.Assert.assertEquals; 019 import static org.junit.Assert.assertNull; 020 import static org.junit.Assert.assertTrue; 021 022 import java.math.BigDecimal; 023 024 import org.joda.time.LocalDate; 025 import org.junit.After; 026 import org.junit.Before; 027 import org.junit.Test; 028 import org.kuali.kpme.core.IntegrationTest; 029 import org.kuali.kpme.core.calendar.entry.CalendarEntry; 030 import org.kuali.kpme.core.util.TKUtils; 031 import org.kuali.kpme.tklm.TKLMIntegrationTestCase; 032 import org.kuali.kpme.tklm.leave.block.LeaveBlock; 033 import org.kuali.kpme.tklm.leave.calendar.LeaveCalendarDocument; 034 import org.kuali.kpme.tklm.leave.service.LmServiceLocator; 035 import org.kuali.kpme.tklm.leave.summary.LeaveSummary; 036 import org.kuali.kpme.tklm.leave.summary.LeaveSummaryRow; 037 import org.kuali.kpme.tklm.time.timesheet.TimesheetDocument; 038 import org.kuali.rice.krad.util.ObjectUtils; 039 040 @IntegrationTest 041 public class LeavePayoutServiceTest extends TKLMIntegrationTestCase { 042 043 /** 044 * Leave Calendar Document Test data 045 */ 046 private final String USER_ID = "testUser1"; 047 048 private LeaveCalendarDocument janLCD; 049 private CalendarEntry janEntry; 050 private LeaveCalendarDocument decLCD; 051 private CalendarEntry decEntry; 052 053 private LocalDate janStart; 054 private LocalDate decStart; 055 056 private final String JAN_ID = "5001"; 057 private final String DEC_ID = "5000"; 058 059 /** 060 * Timesheet Document Test Data; 061 */ 062 063 private final String TS_USER_ID = "testUser2"; 064 065 private TimesheetDocument endJanTSD; 066 private CalendarEntry endJanTSDEntry; 067 private TimesheetDocument midJanTSD; 068 private CalendarEntry midJanTSDEntry; 069 private TimesheetDocument endDecTSD; 070 private CalendarEntry endDecTSDEntry; 071 private TimesheetDocument midDecTSD; 072 private CalendarEntry midDecTSDEntry; 073 074 private final String TSD_MID_DEC_PERIOD_ID = "5000"; 075 private final String TSD_END_DEC_PERIOD_ID = "5001"; 076 private final String TSD_MID_JAN_PERIOD_ID = "5002"; 077 private final String TSD_END_JAN_PERIOD_ID = "5003"; 078 079 /** 080 * Common data 081 */ 082 083 private final String OD_XFER = "5000"; 084 private final String YE_XFER = "5001"; 085 private final String LA_XFER = "5002"; 086 private final String OD_XFER_MAC = "5003"; 087 private final String YE_XFER_MAC = "5004"; 088 private final String LA_XFER_MAC = "5005"; 089 private final String OD_LOSE = "5006"; 090 private final String YE_LOSE = "5007"; 091 private final String LA_LOSE = "5008"; 092 private final String OD_LOSE_MAC = "5009"; 093 private final String YE_LOSE_MAC = "5010"; 094 private final String LA_LOSE_MAC = "5011"; 095 private final String YE_XFER_EO = "5012"; 096 private final LocalDate LM_FROM = TKUtils.formatDateString("11/01/2012"); 097 private final LocalDate LM_TO = TKUtils.formatDateString("02/01/2013"); 098 private final LocalDate TK_FROM = TKUtils.formatDateString("11/01/2011"); 099 private final LocalDate TK_TO = TKUtils.formatDateString("02/01/2012"); 100 101 @Before 102 public void setUp() throws Exception { 103 super.setUp(); 104 LmServiceLocator.getAccrualService().runAccrual(USER_ID,LM_FROM.toDateTimeAtStartOfDay(),LM_TO.toDateTimeAtStartOfDay(),true,USER_ID); 105 janLCD = LmServiceLocator.getLeaveCalendarService().getLeaveCalendarDocument(JAN_ID); 106 janEntry = janLCD.getCalendarEntry(); 107 janStart = janEntry.getBeginPeriodFullDateTime().toLocalDate(); 108 decLCD = LmServiceLocator.getLeaveCalendarService().getLeaveCalendarDocument(DEC_ID); 109 decEntry = decLCD.getCalendarEntry(); 110 decStart = decEntry.getBeginPeriodFullDateTime().toLocalDate(); 111 } 112 113 @After 114 public void tearDown() throws Exception { 115 super.tearDown(); 116 } 117 118 /***************************** 119 * Use-case specific testing * 120 ****************************/ 121 122 // 123 // ACTION_AT_MAX_BALANCE = TRANSFER 124 // 125 126 @Test 127 public void testInitializePayoutNullAccrualRule() throws Exception { 128 LeavePayout lp = new LeavePayout(); 129 130 LocalDate effectiveDate = decStart.plusDays(3); 131 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, null, BigDecimal.ZERO, effectiveDate); 132 assertNull(lp); 133 } 134 135 @Test 136 public void testInitializePayoutNullLeaveSummary() throws Exception { 137 LeavePayout lp = new LeavePayout(); 138 139 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, OD_XFER, null, LocalDate.now()); 140 assertNull(lp); 141 } 142 143 @Test 144 public void testInitializePayoutNullAccrualRuleNullLeaveSummary() { 145 LeavePayout lp = new LeavePayout(); 146 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, null, null, LocalDate.now()); 147 assertNull(lp); 148 } 149 150 @Test 151 public void testInitializePayoutOnDemand() throws Exception { 152 LeavePayout lp = new LeavePayout(); 153 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, decEntry); 154 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(OD_XFER); 155 LocalDate effectiveDate = decStart.plusDays(3); 156 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, OD_XFER, aRow.getAccruedBalance(), effectiveDate); 157 assertEquals("payoutOnDemand payout amount", (new BigDecimal(1)).longValue(), lp.getPayoutAmount().longValue()); 158 assertEquals("payoutOnDemand forfeited amount",(new BigDecimal(0)).longValue(), lp.getForfeitedAmount().longValue()); 159 ////assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(0.5)).longValue(), lp.getAmountPayoutred().longValue()); 160 } 161 162 @Test 163 public void testInitializePayoutOnDemandWithForfeiture() throws Exception { 164 LeavePayout lp = new LeavePayout(); 165 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 166 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(OD_XFER); 167 LocalDate effectiveDate = janStart.plusDays(3); 168 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, OD_XFER, aRow.getAccruedBalance(), effectiveDate); 169 assertEquals("payoutOnDemand payout amount", (new BigDecimal(10)).longValue(), lp.getPayoutAmount().longValue()); 170 assertEquals("payoutOnDemand forfeited amount", (new BigDecimal(7)).longValue(), lp.getForfeitedAmount().longValue()); 171 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(5)).longValue(), lp.getAmountPayoutred().longValue()); 172 } 173 174 @Test 175 public void testInitializePayoutOnYearEnd() throws Exception { 176 LeavePayout lp = new LeavePayout(); 177 LmServiceLocator.getLeaveBlockService().deleteLeaveBlocksForDocumentId(DEC_ID); 178 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 179 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(YE_XFER); 180 LocalDate effectiveDate = janStart.plusDays(3); 181 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_XFER, aRow.getAccruedBalance(), effectiveDate); 182 assertEquals("payoutOnDemand payout amount", (new BigDecimal(1)).longValue(), lp.getPayoutAmount().longValue()); 183 assertEquals("payoutOnDemand forfeited amount",(new BigDecimal(0)).longValue(), lp.getForfeitedAmount().longValue()); 184 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(0.5)).longValue(), lp.getAmountPayoutred().longValue()); 185 } 186 187 @Test 188 public void testInitializePayoutOnYearEndWithForfeiture() throws Exception { 189 LeavePayout lp = new LeavePayout(); 190 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 191 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(YE_XFER); 192 LocalDate effectiveDate = janStart.plusDays(3); 193 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_XFER, aRow.getAccruedBalance(), effectiveDate); 194 assertEquals("payoutOnDemand payout amount", (new BigDecimal(10)).longValue(), lp.getPayoutAmount().longValue()); 195 assertEquals("payoutOnDemand forfeited amount", (new BigDecimal(7)).longValue(), lp.getForfeitedAmount().longValue()); 196 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(5)).longValue(), lp.getAmountPayoutred().longValue()); 197 } 198 199 @Test 200 public void testInitializePayoutOnLeaveApprove() throws Exception { 201 LeavePayout lp = new LeavePayout(); 202 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, decEntry); 203 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(LA_XFER); 204 LocalDate effectiveDate = decStart.plusDays(3); 205 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, LA_XFER, aRow.getAccruedBalance(), effectiveDate); 206 assertEquals("payoutOnDemand payout amount", (new BigDecimal(1)).longValue(), lp.getPayoutAmount().longValue()); 207 assertEquals("payoutOnDemand forfeited amount",(new BigDecimal(0)).longValue(), lp.getForfeitedAmount().longValue()); 208 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(0.5)).longValue(), lp.getAmountPayoutred().longValue()); 209 } 210 211 @Test 212 public void testInitializePayoutOnLeaveApproveWithForfeiture() throws Exception { 213 LeavePayout lp = new LeavePayout(); 214 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 215 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(LA_XFER); 216 LocalDate effectiveDate = janStart.plusDays(3); 217 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, LA_XFER, aRow.getAccruedBalance(), effectiveDate); 218 assertEquals("payoutOnDemand payout amount", (new BigDecimal(10)).longValue(), lp.getPayoutAmount().longValue()); 219 assertEquals("payoutOnDemand forfeited amount", (new BigDecimal(7)).longValue(), lp.getForfeitedAmount().longValue()); 220 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(5)).longValue(), lp.getAmountPayoutred().longValue()); 221 } 222 223 @Test 224 public void testInitializePayoutOnDemandMaxCarryOver() throws Exception { 225 //N/A - Max Carry Over on Year End payouts. 226 LeavePayout lp = new LeavePayout(); 227 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, decEntry); 228 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(OD_XFER_MAC); 229 LocalDate effectiveDate = decStart.plusDays(3); 230 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, OD_XFER_MAC, aRow.getAccruedBalance(), effectiveDate); 231 assertEquals("payoutOnDemand payout amount", (new BigDecimal(1)).longValue(), lp.getPayoutAmount().longValue()); 232 assertEquals("payoutOnDemand forfeited amount",(new BigDecimal(0)).longValue(), lp.getForfeitedAmount().longValue()); 233 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(0.5)).longValue(), lp.getAmountPayoutred().longValue()); 234 } 235 236 @Test 237 public void testInitializePayoutOnYearEndMaxCarryOver() throws Exception { 238 /** 239 * decEntry is not the last calendar entry in the leave plan. Want to check amounts for this action & action frequency 240 * without exceeding the payout limit. 241 * 242 * max payout amount = 10 243 * leave balance = 16 244 * max balance = 15 245 * max carry over = 10 246 * 247 * all excess should be payoutrable. 1 unit of time for excess over max balance, 5 units of time for 248 * excess over max carry over. 249 * 250 */ 251 LeavePayout lp = new LeavePayout(); 252 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, decEntry); 253 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(YE_XFER_MAC); 254 LocalDate effectiveDate = decStart.plusDays(3); 255 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_XFER_MAC, aRow.getAccruedBalance(), effectiveDate); 256 assertEquals("payoutOnDemand payout amount", (new BigDecimal(6)).longValue(), lp.getPayoutAmount().longValue()); 257 assertEquals("payoutOnDemand forfeited amount", (new BigDecimal(0)).longValue(), lp.getForfeitedAmount().longValue()); 258 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(3)).longValue(), lp.getAmountPayoutred().longValue()); 259 } 260 261 /* @Test 262 public void testInitializePayoutUnderMaxBalanceOnYearEndMaxCarryOver() throws Exception { 263 //Create a leave block that will bring the available balance for january down to 14. 264 //this balance would be under the max available balance (15), but over the max annual carry over amount. 265 //i.o.w., this payout would not due to max balance limit, but max annual carry over. 266 //could also simply change the accrual amount. 267 LeaveBlock usage = new LeaveBlock(); 268 usage.setAccrualCategory(YE_XFER_MAC); 269 usage.setLeaveLocalDate(LocalDate effectiveDate = janStart.plusDays(5);); 270 usage.setLeaveAmount(new BigDecimal(-18)); 271 usage.setPrincipalId(USER_ID); 272 usage.setAccrualGenerated(false); 273 usage.setRequestStatus(HrConstants.REQUEST_STATUS.APPROVED); 274 usage.setDocumentId(janLCD.getDocumentId()); 275 usage.setLmLeaveBlockId("99999"); 276 usage.setEarnCode("EC5"); 277 usage.setBlockId(0L); 278 usage.setLeaveBlockType(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_CALENDAR); 279 List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>(); 280 leaveBlocks.add(usage); 281 LmServiceLocator.getLeaveBlockService().saveLeaveBlocks(leaveBlocks); 282 283 LeavePayout lp = new LeavePayout(); 284 janLCD = LmServiceLocator.getLeaveCalendarService().getLeaveCalendarDocument(JAN_ID); 285 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janLCD.getCalendarEntry()); 286 LocalDate effectiveDate = LocalDate effectiveDate = janStart.plusDays(3); 287 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_XFER_MAC, aRow.getAccruedBalance(), effectiveDate); 288 assertEquals("payoutOnDemand payout amount", (new BigDecimal(4)).longValue(), lp.getPayoutAmount().longValue()); 289 assertEquals("payoutOnDemand forfeited amount", (new BigDecimal(0)).longValue(), lp.getForfeitedAmount().longValue()); 290 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(2)).longValue(), lp.getAmountPayoutred().longValue()); 291 }*/ 292 293 @Test 294 public void testInitializePayoutOnYearEndMaxCarryOverWithForfeiture() throws Exception { 295 //max bal limit reached and max annual carry over triggererd. 296 LeavePayout lp = new LeavePayout(); 297 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 298 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(YE_XFER_MAC); 299 LocalDate effectiveDate = janStart.plusDays(3); 300 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_XFER_MAC, aRow.getAccruedBalance(), effectiveDate); 301 assertEquals("payoutOnDemand payout amount", (new BigDecimal(10)).longValue(), lp.getPayoutAmount().longValue()); 302 assertEquals("payoutOnDemand forfeited amount", (new BigDecimal(12)).longValue(), lp.getForfeitedAmount().longValue()); 303 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(5)).longValue(), lp.getAmountPayoutred().longValue()); 304 } 305 306 @Test 307 public void testInitializePayoutOnLeaveApproveMaxCarryOver() throws Exception { 308 LeavePayout lp = new LeavePayout(); 309 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, decEntry); 310 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(LA_XFER_MAC); 311 LocalDate effectiveDate = decStart.plusDays(3); 312 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, LA_XFER_MAC, aRow.getAccruedBalance(), effectiveDate); 313 assertEquals("payoutOnDemand payout amount", (new BigDecimal(1)).longValue(), lp.getPayoutAmount().longValue()); 314 assertEquals("payoutOnDemand forfeited amount",(new BigDecimal(0)).longValue(), lp.getForfeitedAmount().longValue()); 315 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(0.5)).longValue(), lp.getAmountPayoutred().longValue()); 316 } 317 318 @Test 319 public void testInitializePayoutWithOverrides() throws Exception { 320 LeavePayout lp = new LeavePayout(); 321 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 322 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(YE_XFER_EO); 323 LocalDate effectiveDate = janStart.plusDays(3); 324 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_XFER_EO, aRow.getAccruedBalance(), effectiveDate); 325 assertEquals("payoutOnDemand payout amount", (new BigDecimal(7)).longValue(), lp.getPayoutAmount().longValue()); 326 assertEquals("payoutOnDemand forfeited amount",(new BigDecimal(20)).longValue(), lp.getForfeitedAmount().longValue()); 327 // max balance payout conversion factor is undefined for YE_XFER_EO 328 //assertEquals("payoutOnDemand amount payoutred", (new BigDecimal(7)).longValue(), lp.getAmountPayoutred().longValue()); 329 } 330 /** 331 * End Use-case testing 332 */ 333 334 @Test 335 public void testPayoutNullLeavePayout() { 336 LeavePayout LeavePayout = null; 337 try { 338 LeavePayout = LmServiceLocator.getLeavePayoutService().payout(LeavePayout); 339 } catch (RuntimeException re) { 340 assertTrue(re.getMessage().contains("did not supply a valid LeavePayout object")); 341 } 342 } 343 344 @Test 345 public void testPayoutWithZeroPayoutAmount() throws Exception { 346 LeavePayout lp = new LeavePayout(); 347 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 348 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(YE_LOSE); 349 LocalDate effectiveDate = janStart.plusDays(3); 350 //lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_LOSE, aRow.getAccruedBalance(), effectiveDate); 351 lp.setPayoutAmount(BigDecimal.ZERO); 352 lp = LmServiceLocator.getLeavePayoutService().payout(lp); 353 LeaveBlock forfeitedLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getForfeitedLeaveBlockId()); 354 LeaveBlock payoutLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getPayoutLeaveBlockId()); 355 LeaveBlock payoutFromLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getPayoutFromLeaveBlockId()); 356 assertTrue("forfeited leave block should not exist", ObjectUtils.isNull(forfeitedLeaveBlock)); 357 assertTrue("accrued leave block should not exist",ObjectUtils.isNull(payoutLeaveBlock)); 358 assertTrue("debited leave block should not exist",ObjectUtils.isNull(payoutFromLeaveBlock)); 359 } 360 361 @Test 362 public void testPayoutWithZeroForfeiture() throws Exception { 363 LeavePayout lp = new LeavePayout(); 364 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, decEntry); 365 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(OD_XFER); 366 LocalDate effectiveDate = decStart.plusDays(3); 367 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, OD_XFER, aRow.getAccruedBalance(), effectiveDate); 368 lp = LmServiceLocator.getLeavePayoutService().payout(lp); 369 LeaveBlock forfeitedLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getForfeitedLeaveBlockId()); 370 LeaveBlock payoutLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getPayoutLeaveBlockId()); 371 LeaveBlock payoutFromLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getPayoutFromLeaveBlockId()); 372 assertEquals("accrued leave block leave amount incorrect", (new BigDecimal(1)).longValue(), payoutLeaveBlock.getLeaveAmount().longValue()); 373 assertTrue("forfeited leave block should not exist",ObjectUtils.isNull(forfeitedLeaveBlock)); 374 assertEquals("payouted leave block leave amount incorrect", (new BigDecimal(-1)).longValue(), payoutFromLeaveBlock.getLeaveAmount().longValue()); 375 } 376 377 @Test 378 public void testPayoutWithThreeLeaveBlocks() throws Exception { 379 LeavePayout lp = new LeavePayout(); 380 LeaveSummary summary = LmServiceLocator.getLeaveSummaryService().getLeaveSummary(USER_ID, janEntry); 381 LeaveSummaryRow aRow = summary.getLeaveSummaryRowForAccrualCategory(YE_XFER); 382 LocalDate effectiveDate = janStart.plusDays(3); 383 lp = LmServiceLocator.getLeavePayoutService().initializePayout(USER_ID, YE_XFER, aRow.getAccruedBalance(), effectiveDate); 384 lp = LmServiceLocator.getLeavePayoutService().payout(lp); 385 LeaveBlock forfeitedLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getForfeitedLeaveBlockId()); 386 LeaveBlock payoutLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getPayoutLeaveBlockId()); 387 LeaveBlock payoutFromLeaveBlock = LmServiceLocator.getLeaveBlockService().getLeaveBlock(lp.getPayoutFromLeaveBlockId()); 388 assertEquals("forfeited leave block leave amount incorrect", (new BigDecimal(-7)).longValue(), forfeitedLeaveBlock.getLeaveAmount().longValue()); 389 assertEquals((new BigDecimal(10)).longValue(), payoutLeaveBlock.getLeaveAmount().longValue()); 390 assertEquals((new BigDecimal(-10)).longValue(), payoutFromLeaveBlock.getLeaveAmount().longValue()); 391 } 392 393 //TODO: write tests for adjusted max balance cases - i.e. FTE < 1, employee override's w/ type MAX_BALANCE 394 395 @Test 396 public void testSubmitToWorkflow() { 397 assertNull(null); 398 } 399 400 }