Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

/* +======================================================================+

| Copyright (c) 2009 Oracle Corporation |


| Redwood Shores, California, USA |
| All rights reserved. |
+======================================================================+
*
* Formula Name : WFM_TCR_HOLIDAY_THRESHOLD_PREMIUM_AP
*
* Formula Type: Time Calculation rule
*
* Description: Evaluates whether time entered is on public holiday defined
* in the assigned schedule. The category of public holidays
* and specific time attribute entries are inputs to the
* delivered formula. This formula uses an array to process
* time card data.
*
* Detail: Compares the reported time to a specific category of public
* holidays that is attached to the worker's assigned schedule.
* If the reported time is on a qualifying holiday, then the
* worker receives a holiday premium pay time type. If the
* worker should also receive a premium for hours worked above
* some defined threshold value, the worker should also be
* assigned a threshold premium rule.
*
*
* Change History
* --------------
*
* Who Version Date Description
*----------------- -------- ------------
-----------------------------------------
* David Cohanoff 115.0213 2015-FEB-10 Created.
*
*
***************************************************************************/
DEFAULT FOR HWM_CTXARY_RECORD_POSITIONS is EMPTY_TEXT_NUMBER
DEFAULT FOR HWM_CTXARY_HWM_MEASURE_DAY is EMPTY_NUMBER_NUMBER
DEFAULT FOR measure is EMPTY_NUMBER_NUMBER
DEFAULT FOR StartTime is EMPTY_DATE_NUMBER
DEFAULT FOR StopTime is EMPTY_DATE_NUMBER

INPUTS ARE
HWM_CTXARY_RECORD_POSITIONS,
HWM_CTXARY_HWM_MEASURE_DAY,
measure ,
StartTime,
StopTime

ffs_id = GET_CONTEXT(HWM_FFS_ID, 0)
rule_id = GET_CONTEXT(HWM_RULE_ID, 0)
ffName = 'WFM_TCR_HOLIDAY_THRESHOLD_AP'
rLog = add_rlog (ffs_id, rule_id, '>>> Enter - ' || ffName || ' - v105.0222 -r10
' )

NullDate = '01-JAN-1900'(DATE)
NullText = '--NULL--'
RecPositoinEoPeriod = 'END_PERIOD'
RecPositoinEoDay = 'END_DAY'
RecPositoinDetail = 'DETAIL'

/* Fixed Values from Rule header */


hSumLvl= Get_Hdr_Text(rule_id, 'RUN_SUMMATION_LEVEL', 'TIMECARD')
hExecType = Get_Hdr_Text(rule_id,'RULE_EXEC_TYPE', 'CREATE')

hCreateYn = 'N'
if (upper(hExecType) = 'CREATE' ) then (
hCreateYn = 'Y'
)

rLog = add_rlog (ffs_id , rule_id ,'Rule Header:' ||


' , ffs_id =' || TO_CHAR( ffs_id ) ||
' , rule_id =' || TO_CHAR( rule_id ) ||
' , hSumLvl=' || hSumLvl ||
' , hExecType=' || hExecType ||
' , hCreateYn=' || hCreateYn )

ctx_personId = GET_CONTEXT(HWM_RESOURCE_ID, 0)
ctx_subResource = GET_CONTEXT(HWM_SUBRESOURCE_ID, 0)
ctx_start_date = GET_CONTEXT(HWM_CTX_SEARCH_START_DATE, NullDate)
ctx_end_date = GET_CONTEXT(HWM_CTX_SEARCH_END_DATE, NullDate)
measure_period = GET_CONTEXT(HWM_MEASURE_PERIOD, 0)
periodStartDate = GET_CONTEXT(HWM_CTX_PERIOD_START_DATE, NullDate)
periodEndDate = GET_CONTEXT(HWM_CTX_PERIOD_END_DATE, NullDate)

rLog = add_rlog (ffs_id , rule_id , 'UTIL_ ...context : ' ||


' , ctx_personId =' || TO_CHAR( ctx_personId ) ||
' , ctx_subResource =' || TO_CHAR( ctx_subResource ) ||
' , measure_period=' || TO_CHAR( measure_period ) ||
' , periodStartDate=' || TO_CHAR( periodStartDate ) ||
' , periodEndDate=' || TO_CHAR( periodEndDate ) ||
' , ctx_start_date =' || TO_CHAR( ctx_start_date ) ||
' , ctx_end_date =' || TO_CHAR( ctx_end_date ) )

/* Fixed Values from Rule Input parameters */


pCategoryId = get_rvalue_number (rule_id ,'WORKED_TIME_CONDITION', 0)
pOvrdPubCat = get_rvalue_text (rule_id ,'OVRD_PUB_HOLIDAY_CATEGORY', 'PH')
/* pMaxHrs = get_rvalue_number (rule_id ,'DEFINED_LIMIT', 0) */

rLog = add_rlog (ffs_id , rule_id , 'Rule Parameters: ' ||


' , pCategoryId =' || TO_CHAR( pCategoryId ) ||
' , pOvrdPubCat=' || pOvrdPubCat )

wMaAry = HWM_CTXARY_RECORD_POSITIONS.count
rLog = add_rlog (ffs_id, rule_id, 'Start bulk process - wMaAry=' ||
TO_CHAR( wMaAry ) )

dbiHolidayCnt = 0
dbiHolidays = EMPTY_DATE_NUMBER
if ( periodStartDate = NullDate) then
(
rLog = add_rlog (ffs_id , rule_id , 'Time card Start date not found. Exit
holiday search')
) else
(
CALL_FORMULA ('WFM_UTIL_GET_WRKR_HOLIDAY_SCHEDULE'
, ffs_id > 'ffs_id'
, rule_id > 'rule_id'
, pOvrdPubCat > 'pOvrdPubCat'
, periodStartDate > 'start_date_override'
, periodEndDate > 'end_date_override'
, dbiHolidayCnt < 'OUT_HOLIDAY_COUNT' DEFAULT 0
, dbiHolidays < 'OUT_HOLIDAY_DATES' DEFAULT EMPTY_DATE_NUMBER

rLog = add_rlog (ffs_id , rule_id , 'Result from UTIL_GET_DBI call:


dbiHolidayCnt =' || TO_CHAR( dbiHolidayCnt ) )
if (dbiHolidayCnt > 0 ) then (
hIdx = 0
WHILE hIdx < dbiHolidayCnt LOOP (
hIdx = hIdx + 1
hDate = trunc(dbiHolidays[hIdx] )
l_status = add_rlog (ffs_id , rule_id , 'Loop Holiday hIdx='
|| TO_CHAR( hIdx ) ||
' ,hDate =' || TO_CHAR( hDate) )

)
)
)

out_measure_ary_under = EMPTY_NUMBER_NUMBER
out_measure_ary_over = EMPTY_NUMBER_NUMBER

zzzwkTotalHrsDay = 0
zzzzwkTotalHrsTc = 0
nidx = 0
WHILE (nidx < wMaAry ) LOOP
(
aiMeasure = 0
aiRecPosition = NullText

nidx = nidx + 1
if (MEASURE.exists(nidx) ) then (
aiMeasure = MEASURE[nidx]
)

if (HWM_CTXARY_HWM_MEASURE_DAY.exists(nidx) ) then (
aiMeasureDay = HWM_CTXARY_HWM_MEASURE_DAY[nidx]
)

aiRecPosition = HWM_CTXARY_RECORD_POSITIONS[nidx]

if (STARTTIME.exists(nidx) ) then (
l_StartTime = STARTTIME[nidx]
)

if (STOPTIME.exists(nidx) ) then (
l_StopTime = STOPTIME[nidx]
)
if (aiMeasure <= 0 and aiRecPosition = 'DETAIL') then (
calsMsHrs = get_measure_from_time(l_StartTime,l_StopTime)
rLog = add_rlog (ffs_id, rule_id, ' use Calculated
calsMsHrs=' || TO_CHAR( calsMsHrs ) ||
' measure=' ||
TO_CHAR( aiMeasure ) )
aiMeasure = calsMsHrs
)

ocMeasure_under = -9999
ocMeasure_over = -9999
isHoliday = 'N'
if (aiMeasure > 0 and aiRecPosition = 'DETAIL') then
(
/* -- Check if Holiday */
if (dbiHolidayCnt > 0 ) then (
hIdx = 0
WHILE hIdx < dbiHolidayCnt LOOP (
hIdx = hIdx + 1
hDate = trunc(dbiHolidays[hIdx] )
diff = DAYS_BETWEEN(trunc(l_StartTime),
hDate )
if (diff = 0 ) then (
rlog = add_rlog (ffs_id , rule_id ,
'Holiday Work date=' || TO_CHAR( l_StartTime ) )
isHoliday = 'Y'
exit
)
)
)

/* -- SetRate */
ocMeasure_under = aiMeasure
if (isHoliday = 'Y') then (
ocMeasure_over = aiMeasure
if ( hCreateYn = 'N' ) then (
ocMeasure_under = 0
)
)

rLog = add_rlog (ffs_id, rule_id, 'timcard entry: ' ||


TO_CHAR( nidx ) ||
' , measure=' ||
TO_CHAR( aiMeasure ) ||
' , StartTime=' ||
TO_CHAR(l_StartTime) ||
' , StopTime=' ||
TO_CHAR(l_StopTime) ||
' , hCreateYn=' || hCreateYn
||
' , isHoliday=' || isHoliday
||
' , rec_pos=' || aiRecPosition
||
' , ocMeasure_under =' ||
TO_CHAR( ocMeasure_under ) ||
' , ocMeasure_over =' ||
TO_CHAR( ocMeasure_over ) )

if (ocMeasure_under <> -9999 ) Then (


out_measure_ary_under[nidx] = ocMeasure_under
)
if (ocMeasure_over <> -9999 ) Then (
out_measure_ary_over[nidx] = ocMeasure_over
)

/**************************************
d
**************************************/
if (nidx > 1000 ) Then (
if (nidx > 1000 ) Then (
/* endless loop? Stop process if more than max_loop
records found */
ex = raise_error (ffs_id, rule_id, 'Formula ' || ffName ||
' terminated due to possible end-less loop.' )
)

rLog = add_rlog (ffs_id, rule_id, '<< Exit - ' || ffName )

RETURN out_measure_ary_under, out_measure_ary_over

0 50 2015-04-04 08:51:59.967
SEED_DATA_FROM_APPLICATION -1 SEED_DATA_FROM_APPLICATION 2015-04-04
08:51:59.926 C1C252B5C2C215B3E040F00A17202ADB

You might also like