source: WorldVistAEHR/trunk/r/ENGINEERING-EN/ENFABAL1.m@ 1123

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

initial load of WorldVistAEHR

File size: 3.7 KB
Line 
1ENFABAL1 ;WIRMFO/SAB-MAINTAIN FILE 6915.9 FAP BALANCES (cont);1.12.98
2 ;;7.0;ENGINEERING;**29,33,48**;AUG 17, 1883
3 ;This routine should not be modified.
4 Q
5 ;
6SUM ; sum FAP transactions for period
7 ; called from RECALC^ENFABAL
8 ; input
9 ; ENDTR - month to recalculate (FileMan date)
10 ; output
11 ; ^TMP($J,"R",station,fund,sgl)=net $ activity
12 N ENAMT,ENDA,ENDT,ENDTE,ENDTS,ENFAPTY,ENFAY3,ENFILE
13 N ENFUND,ENFUNDNW,ENI,ENSGL,ENSN,ENX,ENY0
14 S ENDTS=$E(ENDTR,1,5)_"01" ; start of month
15 S ENDTE=$$EOM^ENUTL(ENDTS) ; end of month
16 ; load table for converting FA Type to SGL
17 S ENDA=0 F S ENDA=$O(^ENG(6914.3,ENDA)) Q:'ENDA D
18 . S ENY0=$G(^ENG(6914.3,ENDA,0))
19 . I $P(ENY0,U,3)]"" S ENFAPTY($P(ENY0,U,3))=$P(ENY0,U)
20 ; loop thru FAP document file transactions within month
21 F ENFILE="6915.2","6915.3","6915.4","6915.5","6915.6" D
22 . S ENDT=ENDTS
23 . F S ENDT=$O(^ENG(ENFILE,"D",ENDT)) Q:ENDT=""!($P(ENDT,".")>ENDTE) D
24 . . S ENDA("F?")=0
25 . . F S ENDA("F?")=$O(^ENG(ENFILE,"D",ENDT,ENDA("F?"))) Q:'ENDA("F?") D
26 . . . S ENDA("FA")=$$AFA^ENFAR5A(ENFILE,ENDA("F?")) ; associated FA
27 . . . S ENFAY3=$G(^ENG(6915.2,ENDA("FA"),3)),ENSN=$E($P(ENFAY3,U,5),1,5)
28 . . . S ENSN=$TR(ENSN," ","") ; remove spaces (if any)
29 . . . S:ENFILE=6915.2 ENFUND=$P(ENFAY3,U,10)
30 . . . S:ENFILE'=6915.2 ENFUND=$$FUND^ENFAR5A(ENFILE,ENDA("F?"),ENDA("FA"))
31 . . . S ENSGL=$S($P(ENFAY3,U,6)]"":$G(ENFAPTY($P(ENFAY3,U,6))),1:"")
32 . . . Q:ENFUND=""!(ENSGL="")
33 . . . I ENFILE=6915.2 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),3)),U,27)
34 . . . I ENFILE=6915.3 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),4)),U,4)
35 . . . 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))
36 . . . I ENFILE=6915.5 S ENAMT="-"_$P($G(^ENG(ENFILE,ENDA("F?"),100)),U,2)
37 . . . I ENFILE=6915.6 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),100)),U,8)
38 . . . Q:+ENAMT=0 ; don't include transactions for $0
39 . . . I ENFILE'=6915.6 D ; process non-FR doc
40 . . . . S ^TMP($J,"R",ENSN,ENFUND,ENSGL)=$G(^TMP($J,"R",ENSN,ENFUND,ENSGL))+ENAMT
41 . . . I ENFILE=6915.6 D ; process FR doc
42 . . . . S ENFUNDNW=$P($G(^ENG(ENFILE,ENDA("F?"),3)),U,9)
43 . . . . Q:ENFUND=ENFUNDNW ; don't include if fund unchanged by FR
44 . . . . S ^TMP($J,"R",ENSN,ENFUNDNW,ENSGL)=$G(^TMP($J,"R",ENSN,ENFUNDNW,ENSGL))+ENAMT
45 . . . . S ^TMP($J,"R",ENSN,ENFUND,ENSGL)=$G(^TMP($J,"R",ENSN,ENFUND,ENSGL))-ENAMT
46 Q
47 ;
48FVST ; compare file 6915.9 vs. transactions
49 ; input
50 ; ENDTR - month to recalculate (FileMan date)
51 ; ^TMP($J,"R",station,fund,sgl)=net $ activity from recalc
52 ; output -
53 ; problems where net activity is not equal in
54 ; ^TMP($J,"P",station,fund,sgl)=net from file^net from recalc
55 N ENI,ENFUND,ENPM,ENPMI,ENSGL,ENSMI,ENSN,PAMT,RAMT,SAMT
56 ; loop thru station
57 S ENI(1)=0 F S ENI(1)=$O(^ENG(6915.9,ENI(1))) Q:'ENI(1) D
58 . S ENSN=$$GET1^DIQ(6915.9,ENI(1),.01)
59 . ; loop thru fund
60 . S ENI(2)=0 F S ENI(2)=$O(^ENG(6915.9,ENI(1),1,ENI(2))) Q:'ENI(2) D
61 . . S ENFUND=$$GET1^DIQ(6915.91,ENI(2)_","_ENI(1),.01)
62 . . ; loop thru sgl
63 . . S ENI(3)=0
64 . . F S ENI(3)=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3))) Q:'ENI(3) D
65 . . . S ENSGL=$$GET1^DIQ(6915.911,ENI(3)_","_ENI(2)_","_ENI(1),.01)
66 . . . S ENSMI=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENDTR,0))
67 . . . S ENPM=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENDTR),-1)
68 . . . S ENPMI=$S(ENPM:$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",ENPM,0)),1:"")
69 . . . S SAMT=$S(ENSMI:$P($G(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENSMI,0)),U,2),1:"")
70 . . . S PAMT=$S(ENPMI:$P($G(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENPMI,0)),U,2),1:"")
71 . . . I SAMT="" S SAMT=PAMT ; balance inherited from prior month
72 . . . S RAMT=$P($G(^TMP($J,"R",ENSN,ENFUND,ENSGL)),U)
73 . . . I +(SAMT-PAMT)'=+RAMT S ^TMP($J,"P",ENSN,ENFUND,ENSGL)=(+(SAMT-PAMT))_U_(+RAMT)
74 Q
75 ;
76 ;ENFABAL1
Note: See TracBrowser for help on using the repository browser.