1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.rule;
17
18 import java.util.List;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.hr.lm.leaveblock.LeaveBlock;
22 import org.kuali.hr.time.calendar.CalendarEntries;
23 import org.kuali.hr.time.service.base.TkServiceLocator;
24 import org.kuali.hr.time.timeblock.TimeBlock;
25 import org.kuali.hr.time.timesheet.TimesheetDocument;
26 import org.kuali.hr.time.util.TKContext;
27 import org.kuali.hr.time.util.TKUser;
28 import org.kuali.hr.time.util.TkConstants;
29 import org.kuali.hr.time.util.TkTimeBlockAggregate;
30 import org.kuali.rice.krad.util.GlobalVariables;
31
32 public class TkRuleControllerServiceImpl implements TkRuleControllerService {
33
34
35 public void applyRules(String action, List<TimeBlock> timeBlocks, List<LeaveBlock> leaveBlocks, CalendarEntries payEntry, TimesheetDocument timesheetDocument, String principalId){
36
37 if(StringUtils.equals(action, TkConstants.ACTIONS.ADD_TIME_BLOCK) || StringUtils.equals(action, TkConstants.ACTIONS.CLOCK_OUT)){
38 TkTimeBlockAggregate timeBlockAggregate = new TkTimeBlockAggregate(timeBlocks, leaveBlocks, payEntry, payEntry.getCalendarObj(), true);
39
40
41
42
43
44 if (GlobalVariables.getUserSession() != null && TKUser.getCurrentTargetRoles().isSynchronous()) {
45 TkServiceLocator.getDepartmentLunchRuleService().applyDepartmentLunchRule(timeBlockAggregate.getFlattenedTimeBlockList());
46 }
47 TkServiceLocator.getShiftDifferentialRuleService().processShiftDifferentialRules(timesheetDocument, timeBlockAggregate);
48 TkServiceLocator.getDailyOvertimeRuleService().processDailyOvertimeRules(timesheetDocument, timeBlockAggregate);
49 TkServiceLocator.getWeeklyOvertimeRuleService().processWeeklyOvertimeRule(timesheetDocument, timeBlockAggregate);
50 }
51 }
52
53
54 }