source: WorldVistAEHR/trunk/r/ENGINEERING-EN/ENFAR5A.m@ 1361

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

initial load of WorldVistAEHR

File size: 4.0 KB
Line 
1ENFAR5A ;WIRMFO/SAB-FIXED ASSET RPT, VOUCHER SUMMARY (CONT); 8/1/96
2 ;;7.0;ENGINEERING;**29,33**;Aug 17, 1993
3GETDATA ; collect/sort data
4 ; load table for converting FA Type to SGL
5 K ENFAPTY S ENDA=0 F S ENDA=$O(^ENG(6914.3,ENDA)) Q:'ENDA D
6 . S ENY0=$G(^ENG(6914.3,ENDA,0))
7 . I $P(ENY0,U,3)]"" S ENFAPTY($P(ENY0,U,3))=$P(ENY0,U)
8 ; loop thru FAP document file transactions within selected date range
9 K ^TMP($J) F ENFILE="6915.2","6915.3","6915.4","6915.5","6915.6" D
10 . S ENDT=ENDTS
11 . F S ENDT=$O(^ENG(ENFILE,"D",ENDT)) Q:ENDT=""!($P(ENDT,".")>ENDTE) D
12 . . S ENDA("F?")=0
13 . . F S ENDA("F?")=$O(^ENG(ENFILE,"D",ENDT,ENDA("F?"))) Q:'ENDA("F?") D
14 . . . S ENDA("FA")=$$AFA(ENFILE,ENDA("F?")) ; associated FA
15 . . . S ENFAY3=$G(^ENG(6915.2,ENDA("FA"),3))
16 . . . S ENX=$TR($E($P(ENFAY3,U,5),1,5)," ","")
17 . . . Q:ENSNR'=ENX ; not station
18 . . . S:ENFILE=6915.2 ENFUND=$P(ENFAY3,U,10)
19 . . . S:ENFILE'=6915.2 ENFUND=$$FUND(ENFILE,ENDA("F?"),ENDA("FA"))
20 . . . S ENSGL=$S($P(ENFAY3,U,6)]"":$G(ENFAPTY($P(ENFAY3,U,6))),1:"")
21 . . . Q:ENFUND=""!(ENSGL="")
22 . . . I ENFILE=6915.2 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),3)),U,27)
23 . . . I ENFILE=6915.3 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),4)),U,4)
24 . . . 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))
25 . . . I ENFILE=6915.5 S ENAMT="-"_$P($G(^ENG(ENFILE,ENDA("F?"),100)),U,2)
26 . . . I ENFILE=6915.6 S ENAMT=$P($G(^ENG(ENFILE,ENDA("F?"),100)),U,8)
27 . . . Q:+ENAMT=0 ; don't include transactions for $0
28 . . . I ENFILE'=6915.6 D ; process non-FR doc
29 . . . . S ^TMP($J,ENFUND,ENSGL,ENDT,ENFILE_";"_ENDA("F?"))=ENAMT
30 . . . I ENFILE=6915.6 D ; process FR doc
31 . . . . S ENFUNDNW=$P($G(^ENG(ENFILE,ENDA("F?"),3)),U,9)
32 . . . . Q:ENFUND=ENFUNDNW ; don't include if fund unchanged by FR
33 . . . . S ^TMP($J,ENFUNDNW,ENSGL,ENDT,ENFILE_";"_ENDA("F?"))=ENAMT
34 . . . . S ^TMP($J,ENFUND,ENSGL,ENDT,ENFILE_";"_ENDA("F?"))="-"_ENAMT
35 K ENFAPTY
36 Q
37AFA(ENFILE,ENIEN) ; Associated FA Document Extrinsic Function
38 ; Input Variables
39 ; ENFILE - FAP document file of the input document
40 ; ENIEN - IEN of the input document in ENFILE
41 ; Returns
42 ; IEN of the FA document which is associated with the input document
43 ; 0 if no associated FA document could be found
44 N ENDA,ENDTC,ENY0
45 Q:ENFILE="6915.2" ENIEN ; FA document associated with itself
46 S ENY0=$G(^ENG(ENFILE,ENIEN,0))
47 S ENDA=$P(ENY0,U) ; equip id
48 S ENDTC("F?")=$P(ENY0,U,2) ; date/time of non-FA document
49 S ENDA("LFA")=0,ENDTC("LFA")="" ; initialize latest FA ien and date/time
50 ; loop thru FA's for equip to determine latest FA before the input doc
51 S ENDA("FA")=0
52 F S ENDA("FA")=$O(^ENG(6915.2,"B",ENDA,ENDA("FA"))) Q:'ENDA("FA") D
53 . S ENDTC("FA")=$P($G(^ENG(6915.2,ENDA("FA"),0)),U,2)
54 . I ENDTC("FA")<ENDTC("F?"),ENDTC("FA")>ENDTC("LFA") S ENDA("LFA")=ENDA("FA"),ENDTC("LFA")=ENDTC("FA")
55 Q ENDA("LFA")
56 ;
57FUND(ENFILE,ENIEN,ENFAIEN) ; Determine FUND at time of non-FA transaction
58 ; Input Variables
59 ; ENFILE - FAP document file for the input document
60 ; ENIEN - IEN of the input document in ENFILE
61 ; ENFAIEN - IEN of the assoicated FA document
62 ; Returns
63 ; Fund of equipment just before input document was processed
64 N ENDA,ENDTC,ENFUND,ENY0
65 S ENFUND=$P($G(^ENG(6915.2,ENFAIEN,3)),U,10) ; initial fund from FA
66 S ENDTC("FA")=$P($G(^ENG(6915.2,ENFAIEN,0)),U,2) ; date/time of FA
67 S ENY0=$G(^ENG(ENFILE,ENIEN,0))
68 S ENDA=$P(ENY0,U) ; equip id
69 S ENDTC("F?")=$P(ENY0,U,2) ; date/time of input doc
70 ; Retrieve fund values from any FR's between FA and input document
71 ; by looping thru FR's for equip id
72 S ENDA("FR")=0
73 F S ENDA("FR")=$O(^ENG(6915.6,"B",ENDA,ENDA("FR"))) Q:'ENDA("FR") D
74 . S ENDTC("FR")=$P($G(^ENG(6915.6,ENDA("FR"),0)),U,2)
75 . I ENDTC("FR")>ENDTC("FA"),ENDTC("FR")<ENDTC("F?") S ENFUND(ENDTC("FR"))=$P($G(^ENG(6915.6,ENDA("FR"),3)),U,9)
76 ; update initial fund from FA with any subsequent values from FR docs
77 S ENDTC="" F S ENDTC=$O(ENFUND(ENDTC)) Q:ENDTC="" I ENFUND(ENDTC)]"" S ENFUND=ENFUND(ENDTC)
78 Q ENFUND
79 ;ENFAR5A
Note: See TracBrowser for help on using the repository browser.