Change Time Code Hour Type Duration Rule

Class Name

com.workbrain.app.ta.quickrules.ChangeTcodeHtypeDurationRule

Capping eligible work details

The Change Time Code Hour Type Duration Rule can cap eligible work details based on a defined threshold. These thresholds are available:

  • Cap after a duration. Eligible work details are capped at a defined duration per day.
  • Cap based on each work detail's length. Eligible work details are capped after a specific length of time.
  • Cap after a specific time. Eligible work details are capped after a specific time.
  • Cap during a time period. Eligible work details are capped between a start and end time.
  • Cap all the eligible work details between the employee's scheduled start and end times.
  • Cap all the eligible work details that are not between the employee's scheduled start and end times.

A work detail is eligible if the related time code or hour type matches the time codes and hour types that are defined in the rule's parameters. For example, you can configure the rule to cap only work details with the WRK time code and the OT1 hour type. You can define additional eligibility criteria using the rule's Expression String parameter. For example, you can configure the rule to cap work details with specific labor metrics, such as a certain job or project.

When a work detail is capped, the time code of the portion over the threshold is changed to the time code that is defined in the rule's Change To Time Code parameter. If you configure the rule to use a time code that increments a balance, such as the vacation days balance, the rule can be configured to reward employees who work certain conditions. For example, you could set the rule to cap all work details with the WRK time code after 9 hours a day and change the work details over the threshold to a time code that increments the employee's vacation balance. That way, when employees work more than 9 hours a day, they earn vacation time as a reward for working extra hours.

Similarly, you can configure the rule to change the hour type of the portion of work details that are over the threshold. By changing the hour type to OT1, for example, you can assign overtime to employees under certain conditions.

The portion of the capped work detail that is changed depends on how the rule's threshold was defined. For example, if the rule caps after a specific time, such as 17:00, the time codes or hour types of any eligible work details that occur after 17:00 are changed.

Persisting the scheduled activity time code

When the employee records work time, the timesheet uses the default worked time code that is defined in the WRK_TCODE_NAME registry parameter (which is rarely changed from WRK). If the employee is scheduled to work another time code, the activity's time code is ignored and WRK is used.

You can configure the Change Time Code Hour Type Duration Rule to use the scheduled activity time code instead of WRK. For example, if the employee is scheduled to the Training activity (associated with the TRN time code) from 8:00 to 12:00, the rule can flip WRK to TRN for any time recorded within this scheduled activity.

Parameters

Parameter Description
Time Codes Specify a comma-separated list of time codes that mark the work details as eligible (if the Time Codes Inclusive parameter is selected) or ineligible (if the Time Codes Inclusive parameter is not selected). Eligible work details count toward the threshold when the rule determines which work details to cap.

If this parameter is left blank, all time codes are selected.

Time Codes Inclusive Select the check box to indicate that the time codes listed in the Time Codes parameter mark work details as eligible. Work details with these time codes count toward the threshold. Work details with any other time code do not count toward the threshold.

Clear the check box to indicate that the time codes listed in the Time Codes parameter mark work details as ineligible. Work details with these time codes do not count toward the threshold. Work details with any other time code do count toward the threshold.

Hour Types Specify a comma-separated list of hour types that mark the work details as eligible (if the Hour Types Inclusive parameter is selected) or ineligible (if the Hour Types Inclusive parameter is not selected). Eligible work details count toward the threshold when the rule determines which work details to cap.

If this parameter is left blank, all hour types are selected. Any work detail with an eligible time code counts toward the rule's threshold regardless of the hour type.

Hour Types Inclusive Select the check box to indicate that the time codes listed in the Hour Types parameter mark work details as eligible. Work details with these hour types count toward the threshold. Work details with any other hour type do not count toward the threshold.

Clear the check box to indicate that the hour types listed in the Hour Types parameter mark work details as ineligible. Work details with these hour types do not count toward the threshold. Work details with any other hour type do count toward the threshold.

Cap Duration Specify the duration threshold, in minutes, after which eligible work details are capped. The duration is not consecutive; eligible work details are added up for each day. For example, if the Cap Duration parameter is set to 480 and an employee works 540 minutes of eligible work details in one day, the last 60 minutes are capped.
Note: This parameter is not valid when using the rule to flip recorded work time to scheduled activity.
Cap Time This parameter defines the time threshold after which eligible work details are capped. Cap Time does not apply to work premiums. This parameter accepts several types of values:
  • Specify a time, in the format HH:mm, that defines the time threshold after which eligible work details are capped. For example, specify 17:00 to cap all eligible work details after 17:00. If this type of value is defined, Cap Duration is ignored.
  • Specify a time range, in the format HH:mm~HH:mm, that defines the time range that is capped. For example, 15:00~17:00 caps eligible work details that occur between 15:00 and 17:00. If the second value is before the first, the second value is assumed as a time in the next day. If this type of value is defined, Cap Duration is ignored.
  • Specify INSIDE_SCHEDULE to configure the rule to cap all eligible work details that occur within the employee's schedule. The rule considers all multiple shifts. When this value is used, Cap Duration is ignored.
  • Specify OUTSIDE_SCHEDULE to configure the rule to cap all eligible work details that occur outside the employee's schedule. The rule considers all multiple shifts. When this value is used, Cap Duration is ignored.
  • Specify CAPDURATION_FOR_EACH_DETAIL followed by a comma and an operator to configure the rule to cap individual eligible work details, compared to the Cap Duration value. CAPDURATION_FOR_EACH_DETAIL uses one of these operators to define how eligible work detail lengths are compared to the Cap Duration value: <=, >=, <, >, =.

    For example, if Cap Time is set to CAPDURATION_FOR_EACH_DETAIL,=, the rule changes work details that are equal in length to the Cap Duration value.

Note: This parameter is not valid when using the rule to flip recorded work time to scheduled activity.
Cap Time Start Date Applies when an explicit time or range is specified in the Cap Time parameter. This parameter defines the date of that time or the date that the range starts. Select one of these options:
  • Previous Date: The start time that is specified in the Cap Time parameter is associated with the day before the calculation date.
  • Current Date: The start time that is specified in the Cap Time parameter is associated with the calculation date. This is the default.
  • Next Date: The start time that is specified in the Cap Time parameter is associated with the day after the calculation date.

To associate the specified cap times with more than one date, you must configure the rule more than once.

Note: This parameter is not valid when using the rule to flip recorded work time to scheduled activity.
Change To Time Code Specify the time code to which over threshold, eligible work details are changed. This parameter is required when using the rule to cap eligible work details.
Note: This parameter is not valid when using the rule to flip recorded work time to scheduled activity.
Use Scheduled Activity Time Code Select the check box to use the time code associated with the activity against which the employee is scheduled instead of an explicitly defined time code. If the employee is not scheduled for any specific activity on the date being calculated, the default worked time code in the WRK_TCODE_NAME registry parameter is used.
Note: This parameter does not include any grace period logic. Only time that falls directly within the employee's schedule activity (if any) is eligible for flipping.

Selecting this check box disables the Cap Duration, Cap Time, Cap Time Start Date, and Change to Time Code parameters.

Change to Hour Type Specify the hour type to which over threshold, eligible work details are changed. If this parameter is left blank, the hour types are not changed.
Use Current Rate Select the check box to use the current rate in the work details instead of the employee base rate. For example, if a manager updates the employee rate on the timesheet before this rule is applied, selecting this option will avoid the rate getting changed back to the employee base rate when the rule triggers.

By default, this option is cleared and the employee base rate is always used.

Premium Detail Specify 'P' if the time code is a premium time code, or 'D' if the time code is a regular work detail time code.
Expression String Specify any validating expression that defines additional criteria to make work details eligible. For example, specify wrkdJobName=JANITOR so that only work details marked with the JANITOR job are eligible to be capped.

Example: Capped after a duration

In this example, the rule caps eligible work details after 480 minutes and changes the time codes of over threshold, eligible work details to an unpaid time code that increments a vacation balance.

Parameters:

Parameter Value
Time Codes WRK
Cap Duration 480
Change To Time Code WRK-EXT
Change to Hour Type UNPAID

The employee had these work details before the rule was applied:

Start Time End Time Hours Time Code Hour Type
09:00 13:00 4 WRK REG
13:00 15:00 2 BRK UNPAID
15:00 20:00 5 WRK REG

The rule creates these work details:

Start Time End Time Hours Time Code Hour Type
09:00 13:00 4 WRK REG
13:00 15:00 2 BRK UNPAID
15:00 19:00 4 WRK REG
19:00 20:00 1 WRK-EXT UNPAID

Example: Capped inside the schedule

In this example, the rule caps eligible work details that occur within the employee's schedule and changes the time codes, but not the hour types.

Parameters:

Parameter Value
Time Codes WRK
Cap Time INSIDE_SCHEDULE
Change To Time Code WRK-EXT

The employee's schedule runs from 09:00 to 17:00 and 21:00 to 23:00.

The employee had these work details before the rule was applied:

Start Time End Time Hours Time Code Hour Type
09:00 20:00 11 WRK REG
21:00 23:00 2 WRK REG

The rule creates these work details:

Start Time End Time Hours Time Code Hour Type
09:00 17:00 8 WRK-EXT REG
17:00 20:00 3 WRK REG
21:00 23:00 2 WRK-EXT REG

Example: Capped after midnight

In this example, the rule caps eligible work details that occur on or after midnight of a shift that started on the previous day. For the hours on or after midnight, the hour type is changed from REG to OT1.

Parameter Value
Time Codes WRK
Time Codes Inclusive Selected
Hour Types REG
Hour Types Inclusive Selected
Cap Time 00:00~06:00
Cap Time Start Date Next Date
Change To Time Code WRK
Change to Hour Type OT1

The employee had these work details before the rule was applied:

Start Time Start Date End Time End Date Time Code Hour Type
15:00 5/26/2015 04:00 5/27/2015 WRK REG

The rule creates these work details:

Start Time Start Date End Time End Date Time Code Hour Type
15:00 5/26/2015 00:00 5/27/2015 WRK REG
00:00 5/27/2015 04:00 5/27/2015 WRK OT1

Example: Persist activity time code

In this example, the rule changes the default worked time code (WRK) to the time codes associated with the activities to which the employee is scheduled.

Parameters:

Parameter Value
Change to Time Code Blank (disabled)
Use Scheduled Activity Time Code Selected

The employee is scheduled from 08:00 to 10:00 to the Recall activity and from 10:00 to 12:00 to the Training activity. The Recall activity is associated with the RECALL time code and the Training activity is associated with the TRN time code.

The employee records a clock ON at 08:00 and a clock OFF at 12:00.

The employee had this work detail before the rule was applied:

Start Time End Time Hours Time Code Hour Type
08:00 12:00 4 WRK REG

The rule creates these work details:

Start Time End Time Hours Time Code Hour Type
08:00 10:00 2 RECALL REG
10:00 12:00 2 TRN REG