source: WorldVistAEHR/trunk/r/ENGINEERING-EN/ENFABAL.m@ 833

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

initial load of WorldVistAEHR

File size: 5.0 KB
RevLine 
[613]1ENFABAL ;WIRMFO/SAB-MAINTAIN FILE 6915.9 FAP BALANCES ;4/23/96
2 ;;7.0;ENGINEERING;**29**;AUG 17, 1883
3 ;This routine should not be modified.
4ADJBAL(STN,FUND,SGL,MTH,NET) ; Adjust Balance Amount in File #6915.9
5 ; called from FAP Documents and Recalculation option
6 ; Input
7 ; STN - station number (3-5 char)
8 ; FUND - fund pointer (to NX FUND)
9 ; SGL - standard general ledger pointer (to NX SGL)
10 ; MTH - month (FileMan date)
11 ; NET - net $ change (can include two decimals)
12 N BAL,ENFDA,ENI,LMTH,LMTHI,NBAL,PMTH,PMTHI
13 Q:$G(STN)=""!($G(FUND)="")!($G(SGL)="")!($G(MTH)="")!($G(NET)="")
14 Q:MTH'?7N ; not FileMan date
15 Q:NET=0 ; no change
16 I $E(MTH,6,7)'="00" S MTH=$E(MTH,1,5)_"00"
17 ; add/find entry
18 S ENFDA(6915.9,"?+1,",.01)=STN
19 S ENFDA(6915.91,"?+2,?+1,",.01)=FUND
20 S ENFDA(6915.911,"?+3,?+2,?+1,",.01)=SGL
21 S ENFDA(6915.9111,"?+4,?+3,?+2,?+1,",.01)=MTH
22 D UPDATE^DIE("","ENFDA","ENI") D MSG^DIALOG()
23 ;
24 L +^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENI(4),0):5
25 ; get current balance
26 S BAL=$$GETBAL(ENI(1),ENI(2),ENI(3),MTH)
27 ; calc/post new balance
28 S NBAL=BAL+NET
29 S $P(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENI(4),0),U,2)=NBAL
30 L -^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,ENI(4),0)
31 ; increase balance in later months (if any)
32 S LMTH=MTH
33 F S LMTH=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",LMTH)) Q:LMTH="" D
34 . S LMTHI=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",LMTH,0))
35 . L +^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,LMTHI,0):5
36 . S BAL=$P(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,LMTHI,0),U,2)
37 . S NBAL=BAL+NET
38 . S $P(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,LMTHI,0),U,2)=NBAL
39 . L -^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,LMTHI,0)
40 Q
41 ;
42GETBAL(IEN1,IEN2,IEN3,MTH) ; Get Balance Amount from File #6915.9
43 ; called from ADJBAL and routine ENFAR5*
44 ; Input
45 ; IEN1 - ien of station
46 ; IEN2 - ien of fund multiple
47 ; IEN3 - ien of sgl multiple
48 ; MTH - month (FileMan date)
49 ; Output
50 ; BAL - balance amount
51 N BAL,IEN4,PMTH,PMTHI
52 S IEN4=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",MTH,0))
53 S BAL=$S(IEN4:$P($G(^ENG(6915.9,IEN1,1,IEN2,1,IEN3,1,IEN4,0)),U,2),1:"")
54 I BAL="" D ; perhaps there is a balance in previous month
55 . S PMTH=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",MTH),-1)
56 . Q:PMTH=""
57 . S PMTHI=$O(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,"B",PMTH,0))
58 . S BAL=$P(^ENG(6915.9,ENI(1),1,ENI(2),1,ENI(3),1,PMTHI,0),U,2)
59 Q BAL
60 ;
61RECALC ; Recalculate Net Activity for Month (optionally update file 6915.9)
62 ; called from option ENFA RECALC BALANCES
63 ; ask for period (month/year)
64 S DIR(0)="D^::E^K:($E(Y,4,5)=""00"")!($E(Y,1,5)>$E(DT,1,5)) X"
65 S DIR("A")="Enter month to recalculate"
66 S X("Y")=$E(DT,1,3),X("M")=$E(DT,4,5)
67 S X=$S(X("M")="01":(X("Y")-1)_"12",1:X("Y")_$E("00",1,2-$L(X("M")-1))_(X("M")-1))_"00"
68 S DIR("B")=$$FMTE^XLFDT(X)
69 K X
70 S DIR("?",1)="Month and year are required and future dates are invalid."
71 S DIR("?")="Enter the month and year to recalculate balances."
72 D ^DIR K DIR G:$D(DIRUT) EXIT
73 S ENDTR=$E(Y,1,5)_"00" ; month to recalculate
74 ;
75 W !!,"You have chosen to recalculate the $ from FAP transactions during"
76 W !,"the month of ",$$FMTE^XLFDT(ENDTR),"."
77 I $E(DT,1,5)=$E(ENDTR,1,5) D
78 . W $C(7),!!,"WARNING - Current month was selected. FAP Document Files will be"
79 . W !,"locked to ensure that no FAP transactions (FA, FB, FC, FD, and FR)"
80 . W !,"can be processed during the recalculation."
81 W ! S DIR(0)="Y",DIR("A")="OK to proceed"
82 D ^DIR K DIR G:'Y!$D(DIRUT) EXIT
83 I $E(DT,1,5)=$E(ENDTR,1,5) D I 'ENLOCK W !,$C(7),"Can't Proceed. Try Later" G EXIT
84 . S ENLOCK=1
85 . L +^ENG(6915.2):2 I '$T W !,"FA Document Log in use." S ENLOCK=0
86 . L +^ENG(6915.3):2 I '$T W !,"FB Document Log in use." S ENLOCK=0
87 . L +^ENG(6915.4):2 I '$T W !,"FC Document Log in use." S ENLOCK=0
88 . L +^ENG(6915.5):2 I '$T W !,"FD Document Log in use." S ENLOCK=0
89 . L +^ENG(6915.6):2 I '$T W !,"FR Document Log in use." S ENLOCK=0
90 ;
91 K ^TMP($J)
92 ; calculating net activity and save in ^TMP($J,"R",
93 W !!,"Calculating net activity from transactions..." D SUM^ENFABAL1
94 ; compare and save problems in ^TMP($J,"P",
95 W !,"Comparing FAP BALANCES file with transactions..." D FVST^ENFABAL1
96 W !,"Comparing transactions with FAP BALANCES file..." D TVSF^ENFABAL2
97 ;
98 I '$D(^TMP($J,"P")) W !!,"No problems were found." G EXIT
99 ;
100 W $C(7),!!,"Problems were found..." D ^ENFABAL2 ; report
101 ;
102 W ! S DIR(0)="Y",DIR("A")="OK to correct file"
103 D ^DIR K DIR G:'Y!$D(DIRUT) EXIT
104 ;
105 S ENSN="" F S ENSN=$O(^TMP($J,"P",ENSN)) Q:ENSN="" D
106 . S ENFUND="" F S ENFUND=$O(^TMP($J,"P",ENSN,ENFUND)) Q:ENFUND="" D
107 . . S ENFUNDI=$O(^ENG(6914.6,"B",ENFUND,0))
108 . . S ENSGL=""
109 . . F S ENSGL=$O(^TMP($J,"P",ENSN,ENFUND,ENSGL)) Q:ENSGL="" D
110 . . . S ENSGLI=$O(^ENG(6914.3,"B",ENSGL,0))
111 . . . S Y=$G(^TMP($J,"P",ENSN,ENFUND,ENSGL))
112 . . . S ENADJ=$P(Y,U,2)-$P(Y,U)
113 . . . D ADJBAL^ENFABAL(ENSN,ENFUNDI,ENSGLI,ENDTR,ENADJ)
114 ;
115EXIT ;
116 I $E(DT,1,5)=$E($G(ENDTR),1,5) D
117 . L -^ENG(6915.2):2
118 . L -^ENG(6915.3):2
119 . L -^ENG(6915.4):2
120 . L -^ENG(6915.5):2
121 . L -^ENG(6915.6):2
122 K ^TMP($J)
123 K ENADJ,ENDTR,ENFUND,ENFUNDI,ENLOCK,ENSGL,ENSGLI,ENSN
124 K DIR,DIRUT,DIROUT,DTOUT,DUOUT,X,Y
125 Q
126 ;ENFABAL
Note: See TracBrowser for help on using the repository browser.