source: WorldVistAEHR/trunk/r/PAID-PRS/PRS8EX0.m@ 1003

Last change on this file since 1003 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.5 KB
Line 
1PRS8EX0 ;HISC/MRL,WOIFO/JAH,SAB-DECOMP,EXCEPTIONS (cont'd) ;1/30/2007
2 ;;4.0;PAID;**2,22,56,111**;Sep 21, 1995;Build 2
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5ENCAP ;
6 ; This routine checks if the current day encapsulates other days that
7 ; should be automatically charged to WP or NP by the software. If so,
8 ; appropriate encapsulated days are charged. This routine is only
9 ; called when the employee has a daily tour.
10 ; inputs
11 ; PY - current pay period IEN
12 ; DY - current day number
13 ; TT - type of time posted on current day
14 ; TT(1) - data from ACT^PRS8EX for the type of time in TT
15 ; DFN - employee IEN
16 ;
17 ; day must be in pay period and posted with WP or NP
18 Q:(DY<1)!(DY>14)
19 Q:"^NP^WP^"'[(U_TT_U)
20 ;
21 N SCHDY,SCHEX,SCHPY,CHGDAY
22 ;
23 ; find prior scheduled work day that is not holiday excused
24 D WORKDAY(DFN,PY,DY,-1,.SCHPY,.SCHDY,.SCHEX,.CHGDAY)
25 ;
26 ; If prior work day is in a previous pay period and has same exception
27 ; as the current day then charge the encapsulated days found between.
28 ; Note: If prior work day is in current pay period then no action
29 ; needed since the look forward from that prior day would have
30 ; already taken care of encapsulated days.
31 I SCHEX=TT,$D(CHGDAY),SCHPY'=PY D SET(DFN,PY,TT,$P(TT(1),U,4),.CHGDAY)
32 ;
33 ; find next scheduled work day that is not holiday excused
34 D WORKDAY(DFN,PY,DY,1,.SCHPY,.SCHDY,.SCHEX,.CHGDAY)
35 ;
36 ; If next work day has same exception as current day then charge
37 ; encapsulated days found between.
38 I SCHEX=TT,$D(CHGDAY) D SET(DFN,PY,TT,$P(TT(1),U,4),.CHGDAY)
39 ;
40 Q
41 ;
42WORKDAY(DFN,PY,DY,PRSDIR,SCHPY,SCHDY,SCHEX,CHGDAY) ; find work day
43 ; inputs
44 ; DFN - employee IEN
45 ; PY - current pay period IEN
46 ; DY - current day number
47 ; PRSDIR - direction (-1 to look back or +1 to look forward)
48 ; outputs
49 ; SCHPY - passed by reference, work day pay period or null
50 ; SCHDY - passed by reference, work day day number or null
51 ; SCHEX - passed by reference, work day exception or null
52 ; CHGDAY() - passed by reference, array of days in current pay period
53 ; that could be charged due to encapsulation and were
54 ; encounted during the search for the work day
55 ; format ENCDAY(day number)=null value
56 ;
57 N DONE,EXC,LOOPPY,LOOPDY,PPCNT,TOD
58 ; init outputs
59 S (SCHPY,SCHDY,SCHEX)=""
60 K CHGDAY
61 ;
62 ; loop thru days to find the first scheduled work day that is
63 ; not holiday excused
64 S DONE=0,LOOPPY=PY,LOOPDY=DY,PPCNT=1
65 F D I DONE Q
66 . ; move one day in appropriate direction
67 . S LOOPDY=LOOPDY+PRSDIR
68 . ;
69 . ; check if loop day moved into a different pay period
70 . I LOOPDY<1 S LOOPPY=$O(^PRST(458,LOOPPY),-1),LOOPDY=14,PPCNT=PPCNT+1
71 . I LOOPDY>14 S LOOPPY=$O(^PRST(458,LOOPPY),1),LOOPDY=1,PPCNT=PPCNT+1
72 . ;
73 . ; check for loop ending conditions (related to pay period/time card)
74 . I PPCNT>2 S DONE=1 Q ; only check current and one other pay period
75 . I LOOPPY'>0 S DONE=1 Q ; ran out of pay periods
76 . I '$D(^PRST(458,LOOPPY,"E",DFN,0)) S DONE=1 Q ; no empl. time card
77 . ;
78 . ; determine tour and exception for loop day
79 . S TOD=$P($G(^PRST(458,LOOPPY,"E",DFN,"D",LOOPDY,0)),U,2)
80 . S EXC=$P($G(^PRST(458,LOOPPY,"E",DFN,"D",LOOPDY,2)),U,3)
81 . ;
82 . ; check if work day found
83 . I TOD'=1,EXC'="HX" S SCHPY=LOOPPY,SCHDY=LOOPDY,SCHEX=EXC,DONE=1 Q
84 . ;
85 . ; work day was not found yet
86 . ; add this day to list if it could potentially be charged
87 . Q:LOOPPY'=PY ; not in current pay period
88 . Q:$D(^TMP($J,"PRS8",LOOPDY,2,0)) ; day already charged
89 . I TOD=1,"^CP^NP^"'[(U_EXC_U) S CHGDAY(LOOPDY)="" ; add day off to list
90 . I TOD>1,EXC="HX" S CHGDAY(LOOPDY)="" ; add holiday to list
91 Q
92 ;
93SET(DFN,PY,TT,PC,CHGDAY) ; automatically charge days
94 ;
95 ; inputs
96 ; DFN - employee IEN
97 ; PY - pay period IEN
98 ; TT - type of time to charge
99 ; PC - 4th piece of data from ACT^PRS8EX for TT
100 ; CHGDAY - array of days passed by reference, CHGDAY(day number)=""
101 ;
102 N LOOPDY,PC3,WEEK
103 ;
104 ; loop thru days in list
105 S LOOPDY=0 F S LOOPDY=$O(CHGDAY(LOOPDY)) Q:'LOOPDY D
106 . ;
107 . ; increment WK() count
108 . I +PC S WEEK=$S(LOOPDY>7:2,1:1),$P(WK(WEEK),"^",+PC)=$P(WK(WEEK),"^",+PC)+1
109 . E S PC3=$A(PC)-64,$P(WK(3),"^",+PC3)=$P(WK(3),"^",+PC3)+1
110 . ;
111 . ; track days have been automatically charged in ^TMP
112 . S ^TMP($J,"PRS8",LOOPDY,2,0)=TT
113 . ;
114 . ; update time card if decomp called from pay period certification
115 . I $G(APDT) D
116 . . S $P(^PRST(458,PY,"E",DFN,"D",LOOPDY,2),"^",3)=TT
117 . . S ^PRST(458,PY,"E",DFN,"D",LOOPDY,3)="Leave posted automatically"
118 . . S $P(^PRST(458,PY,"E",DFN,"D",LOOPDY,10),"^",1,4)="T^.5^"_APDT_"^2"
119 Q
Note: See TracBrowser for help on using the repository browser.