ENFABAL1 ;WIRMFO/SAB-MAINTAIN FILE 6915.9 FAP BALANCES (cont);1.12.98
;;7.0;ENGINEERING;**29,33,48**;AUG 17, 1883
;This routine should not be modified.
Q
;
SUM ; sum FAP transactions for period
; called from RECALC^ENFABAL
; input
; ENDTR - month to recalculate (FileMan date)
; output
; ^TMP($J,"R",station,fund,sgl)=net $ activity
N ENAMT,ENDA,ENDT,ENDTE,ENDTS,ENFAPTY,ENFAY3,ENFILE
N ENFUND,ENFUNDNW,ENI,ENSGL,ENSN,ENX,ENY0
S ENDTS=$E(ENDTR,1,5)_"01" ; start of month
S ENDTE=$$EOM^ENUTL(ENDTS) ; end of month
; load table for converting FA Type to SGL
S ENDA=0 F S ENDA=$O(^ENG(6914.3,ENDA)) Q:'ENDA D
. S ENY0=$G(^ENG(6914.3,ENDA,0))
. I $P(ENY0,U,3)]"" S ENFAPTY($P(ENY0,U,3))=$P(ENY0,U)
; loop thru FAP document file transactions within month
F ENFILE="6915.2","6915.3","6915.4","6915.5","6915.6" D
. S ENDT=ENDTS
. F S ENDT=$O(^ENG(ENFILE,"D",ENDT)) Q:ENDT=""!($P(ENDT,".")>ENDTE) D
. . S ENDA("F?")=0
. . F S ENDA("F?")=$O(^ENG(ENFILE,"D",ENDT,ENDA("F?"))) Q:'ENDA("F?") D
. . . S ENDA("FA")=$$AFA^ENFAR5A(ENFILE,ENDA("F?")) ; associated FA
. . . S ENFAY3=$G(^ENG(6915.2,ENDA("FA"),3)),ENSN=$E($P(ENFAY3,U,5),1,5)
. . . S ENSN=$TR(ENSN," ","") ; remove spaces (if any)
. . . S:ENFILE=6915.2 ENFUND=$P(ENFAY3,U,10)
. . . S:ENFILE'=6915.2 ENFUND=$$FUND^ENFAR5A(ENFILE,ENDA("F?"),ENDA("FA"))
. . . S ENSGL=$S($P(ENFAY3,U,6)]"":$G(ENFAPTY($P(ENFAY3,U,6))),1:"")
. . . Q:ENFUND=""!(ENSGL="")
. . . I ENFILE=6915.2 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),3)),U,27)
. . . I ENFILE=6915.3 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),4)),U,4)
. . . I ENFILE=6915.4 S ENX=$P($G(^ENG(ENFILE,ENDA("F?"),4)),U,6),ENAMT=$S(ENX="":0,1:ENX-$P($G(^ENG(ENFILE,ENDA("F?"),100)),U,4))
. . . I ENFILE=6915.5 S ENAMT="-"_$P($G(^ENG(ENFILE,ENDA("F?"),100)),U,2)
. . . I ENFILE=6915.6 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),100)),U,8)
. . . Q:+ENAMT=0 ; don't include transactions for $0
. . . I ENFILE'=6915.6 D ; process non-FR doc
. . . . S ^TMP($J,"R",ENSN,ENFUND,ENSGL)=$G(^TMP($J,"R",ENSN,ENFUND,ENSGL))+ENAMT
. . . I ENFILE=6915.6 D ; process FR doc
. . . . S ENFUNDNW=$P($G(^ENG(ENFILE,ENDA("F?"),3)),U,9)
. . . . Q:ENFUND=ENFUNDNW ; don't include if fund unchanged by FR
. . . . S ^TMP($J,"R",ENSN,ENFUNDNW,ENSGL)=$G(^TMP($J,"R",ENSN,ENFUNDNW,ENSGL))+ENAMT
. . . . S ^TMP($J,"R",ENSN,ENFUND,ENSGL)=$G(^TMP($J,"R",ENSN,ENFUND,ENSGL))-ENAMT
Q
;
FVST ; compare file 6915.9 vs. transactions
; input
; ENDTR - month to recalculate (FileMan date)
; ^TMP($J,"R",station,fund,sgl)=net $ activity from recalc
; output -
; problems where net activity is not equal in
; ^TMP($J,"P",station,fund,sgl)=net from file^net from recalc
N ENI,ENFUND,ENPM,ENPMI,ENSGL,ENSMI,ENSN,PAMT,RAMT,SAMT
; loop thru station
S ENI(1)=0 F S ENI(1)=$O(^ENG(6915.9,ENI(1))) Q:'ENI(1) D
. S ENSN=$$GET1^DIQ(6915.9,ENI(1),.01)
. ; loop thru fund
. S ENI(2)=0 F S ENI(2)=$O(^ENG(6915.9,ENI(1),1,ENI(2))) Q:'ENI(2) D
. . S ENFUND=$$GET1^DIQ(6915.91,ENI(2)_","_ENI(1),.01)
. . ; loop thru sgl
. . S ENI(3)=0
. . F S ENI(3)=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3))) Q:'ENI(3) D
. . . S ENSGL=$$GET1^DIQ(6915.911,ENI(3)_","_ENI(2)_","_ENI(1),.01)
. . . S ENSMI=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENDTR,0))
. . . S ENPM=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENDTR),-1)
. . . S ENPMI=$S(ENPM:$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENPM,0)),1:"")
. . . S SAMT=$S(ENSMI:$P($G(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENSMI,0)),U,2),1:"")
. . . S PAMT=$S(ENPMI:$P($G(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENPMI,0)),U,2),1:"")
. . . I SAMT="" S SAMT=PAMT ; balance inherited from prior month
. . . S RAMT=$P($G(^TMP($J,"R",ENSN,ENFUND,ENSGL)),U)
. . . I +(SAMT-PAMT)'=+RAMT S ^TMP($J,"P",ENSN,ENFUND,ENSGL)=(+(SAMT-PAMT))_U_(+RAMT)
Q
;
;ENFABAL1
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HENFABAL1 3887 printed Nov 22, 2024@17:03:27 Page 2
ENFABAL1 ;WIRMFO/SAB-MAINTAIN FILE 6915.9 FAP BALANCES (cont);1.12.98
+1 ;;7.0;ENGINEERING;**29,33,48**;AUG 17, 1883
+2 ;This routine should not be modified.
+3 QUIT
+4 ;
SUM ; sum FAP transactions for period
+1 ; called from RECALC^ENFABAL
+2 ; input
+3 ; ENDTR - month to recalculate (FileMan date)
+4 ; output
+5 ; ^TMP($J,"R",station,fund,sgl)=net $ activity
+6 NEW ENAMT,ENDA,ENDT,ENDTE,ENDTS,ENFAPTY,ENFAY3,ENFILE
+7 NEW ENFUND,ENFUNDNW,ENI,ENSGL,ENSN,ENX,ENY0
+8 ; start of month
SET ENDTS=$EXTRACT(ENDTR,1,5)_"01"
+9 ; end of month
SET ENDTE=$$EOM^ENUTL(ENDTS)
+10 ; load table for converting FA Type to SGL
+11 SET ENDA=0
FOR
SET ENDA=$ORDER(^ENG(6914.3,ENDA))
if 'ENDA
QUIT
Begin DoDot:1
+12 SET ENY0=$GET(^ENG(6914.3,ENDA,0))
+13 IF $PIECE(ENY0,U,3)]""
SET ENFAPTY($PIECE(ENY0,U,3))=$PIECE(ENY0,U)
End DoDot:1
+14 ; loop thru FAP document file transactions within month
+15 FOR ENFILE="6915.2","6915.3","6915.4","6915.5","6915.6"
Begin DoDot:1
+16 SET ENDT=ENDTS
+17 FOR
SET ENDT=$ORDER(^ENG(ENFILE,"D",ENDT))
if ENDT=""!($PIECE(ENDT,".")>ENDTE)
QUIT
Begin DoDot:2
+18 SET ENDA("F?")=0
+19 FOR
SET ENDA("F?")=$ORDER(^ENG(ENFILE,"D",ENDT,ENDA("F?")))
if 'ENDA("F?")
QUIT
Begin DoDot:3
+20 ; associated FA
SET ENDA("FA")=$$AFA^ENFAR5A(ENFILE,ENDA("F?"))
+21 SET ENFAY3=$GET(^ENG(6915.2,ENDA("FA"),3))
SET ENSN=$EXTRACT($PIECE(ENFAY3,U,5),1,5)
+22 ; remove spaces (if any)
SET ENSN=$TRANSLATE(ENSN," ","")
+23 if ENFILE=6915.2
SET ENFUND=$PIECE(ENFAY3,U,10)
+24 if ENFILE'=6915.2
SET ENFUND=$$FUND^ENFAR5A(ENFILE,ENDA("F?"),ENDA("FA"))
+25 SET ENSGL=$SELECT($PIECE(ENFAY3,U,6)]"":$GET(ENFAPTY($PIECE(ENFAY3,U,6))),1:"")
+26 if ENFUND=""!(ENSGL="")
QUIT
+27 IF ENFILE=6915.2
SET ENAMT=$PIECE($GET(^ENG(ENFILE,ENDA("F?"),3)),U,27)
+28 IF ENFILE=6915.3
SET ENAMT=$PIECE($GET(^ENG(ENFILE,ENDA("F?"),4)),U,4)
+29 IF ENFILE=6915.4
SET ENX=$PIECE($GET(^ENG(ENFILE,ENDA("F?"),4)),U,6)
SET ENAMT=$SELECT(ENX="":0,1:ENX-$PIECE($GET(^ENG(ENFILE,ENDA("F?"),100)),U,4))
+30 IF ENFILE=6915.5
SET ENAMT="-"_$PIECE($GET(^ENG(ENFILE,ENDA("F?"),100)),U,2)
+31 IF ENFILE=6915.6
SET ENAMT=$PIECE($GET(^ENG(ENFILE,ENDA("F?"),100)),U,8)
+32 ; don't include transactions for $0
if +ENAMT=0
QUIT
+33 ; process non-FR doc
IF ENFILE'=6915.6
Begin DoDot:4
+34 SET ^TMP($JOB,"R",ENSN,ENFUND,ENSGL)=$GET(^TMP($JOB,"R",ENSN,ENFUND,ENSGL))+ENAMT
End DoDot:4
+35 ; process FR doc
IF ENFILE=6915.6
Begin DoDot:4
+36 SET ENFUNDNW=$PIECE($GET(^ENG(ENFILE,ENDA("F?"),3)),U,9)
+37 ; don't include if fund unchanged by FR
if ENFUND=ENFUNDNW
QUIT
+38 SET ^TMP($JOB,"R",ENSN,ENFUNDNW,ENSGL)=$GET(^TMP($JOB,"R",ENSN,ENFUNDNW,ENSGL))+ENAMT
+39 SET ^TMP($JOB,"R",ENSN,ENFUND,ENSGL)=$GET(^TMP($JOB,"R",ENSN,ENFUND,ENSGL))-ENAMT
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+40 QUIT
+41 ;
FVST ; compare file 6915.9 vs. transactions
+1 ; input
+2 ; ENDTR - month to recalculate (FileMan date)
+3 ; ^TMP($J,"R",station,fund,sgl)=net $ activity from recalc
+4 ; output -
+5 ; problems where net activity is not equal in
+6 ; ^TMP($J,"P",station,fund,sgl)=net from file^net from recalc
+7 NEW ENI,ENFUND,ENPM,ENPMI,ENSGL,ENSMI,ENSN,PAMT,RAMT,SAMT
+8 ; loop thru station
+9 SET ENI(1)=0
FOR
SET ENI(1)=$ORDER(^ENG(6915.9,ENI(1)))
if 'ENI(1)
QUIT
Begin DoDot:1
+10 SET ENSN=$$GET1^DIQ(6915.9,ENI(1),.01)
+11 ; loop thru fund
+12 SET ENI(2)=0
FOR
SET ENI(2)=$ORDER(^ENG(6915.9,ENI(1),1,ENI(2)))
if 'ENI(2)
QUIT
Begin DoDot:2
+13 SET ENFUND=$$GET1^DIQ(6915.91,ENI(2)_","_ENI(1),.01)
+14 ; loop thru sgl
+15 SET ENI(3)=0
+16 FOR
SET ENI(3)=$ORDER(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3)))
if 'ENI(3)
QUIT
Begin DoDot:3
+17 SET ENSGL=$$GET1^DIQ(6915.911,ENI(3)_","_ENI(2)_","_ENI(1),.01)
+18 SET ENSMI=$ORDER(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENDTR,0))
+19 SET ENPM=$ORDER(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENDTR),-1)
+20 SET ENPMI=$SELECT(ENPM:$ORDER(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENPM,0)),1:"")
+21 SET SAMT=$SELECT(ENSMI:$PIECE($GET(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENSMI,0)),U,2),1:"")
+22 SET PAMT=$SELECT(ENPMI:$PIECE($GET(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENPMI,0)),U,2),1:"")
+23 ; balance inherited from prior month
IF SAMT=""
SET SAMT=PAMT
+24 SET RAMT=$PIECE($GET(^TMP($JOB,"R",ENSN,ENFUND,ENSGL)),U)
+25 IF +(SAMT-PAMT)'=+RAMT
SET ^TMP($JOB,"P",ENSN,ENFUND,ENSGL)=(+(SAMT-PAMT))_U_(+RAMT)
End DoDot:3
End DoDot:2
End DoDot:1
+26 QUIT
+27 ;
+28 ;ENFABAL1