source: WorldVistAEHR/trunk/r/ACCOUNTS_RECEIVABLE-PRCA-PRY-RC/RCYPAY.m@ 1042

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

initial load of WorldVistAEHR

File size: 7.6 KB
Line 
1RCYPAY ;WISC/LDB-Date Sorted Payment report ;18 Aug 97
2V ;;4.5;Accounts Receivable;**91**;Mar 20, 1995
3 N ADM,AMT,BILL,CAT,CNT,DAT,DATE,DATESTRT,DATEEND,DATEX,DATEY,INT,LN,NOW,OUT,PG,POP,PRIN,RECPT,SUM,TN,TN0,TN1,TN3,TOT,TYP,X,Y,Z,ZTDESC,ZTRTN,ZTSAVE,%ZIS
4 K ^TMP($J,"PAY"),^TMP($J,"CAT")
5 ;
6 ; select date range
7 D DATESEL("PAYMENT POSTED") I '$G(DATEEND) Q
8 S DATEEND=DATEEND+.99
9 ;
10 ; select summary or detail
11 S DIR(0)="S^S:SUMMARY;D:DETAILED",DIR("A")="Summary or Detailed ",DIR("B")="S",DIR("?")="Detailed will include individual bill amounts."
12 D ^DIR Q:$D(DIRUT)
13 K DIR
14 S SUM=Y
15 ;
16CAT ;select category
17 K DIC S Y=0
18 W !,"CATEGORY OF BILL: "_$S('$O(^TMP($J,"CAT",0)):"ALL// ",1:"")
19 R X:DTIME I '$T!(X="^") Q
20 I ((X="")!(X="ALL")),'$O(^TMP($J,"CAT",0)) S (CAT,X)="ALL" S ^TMP($J,"CAT",0)="ALL" G QUE
21 S DIC="^PRCA(430.2,",DIC(0)="QEMZ"
22 D ^DIC S CAT=+Y
23 I X["?" W !!,"Enter 'ALL' for all categories or category name.",! G CAT
24 I CAT'="ALL",(+CAT>0) S ^TMP($J,"CAT",+CAT)="" G CAT
25 I X="" G QUE
26 Q:X="^"
27 G:+CAT<0 CAT
28 ; select device
29QUE W !,"This report requires 132 column display."
30 W ! S %ZIS="Q" D ^%ZIS Q:POP
31 I $D(IO("Q")) D D ^%ZTLOAD K IO("Q"),ZTSK Q
32 . S ZTDESC="Date Sorted Payment Report",ZTRTN="DQ^RCYPAY"
33 . S (ZTSAVE("DATESTRT"),ZTSAVE("DATEEND"),ZTSAVE("SUM"),ZTSAVE("^TMP($J,"))="",ZTSAVE("ZTREQ")="@"
34 W !!,"<*> please wait <*>"
35DQ D PROC D:SUM="D" DPRNT D:SUM="S" SPRNT
36 D ^%ZISC K ^TMP($J,"PAY"),^TMP($J,"CAT") Q
37 ;
38PROC ; report (queue) starts here
39 U IO
40 F TYP=2,34 S DAT=DATESTRT-.01 F S DAT=$O(^PRCA(433,"AT",TYP,DAT)) Q:'DAT!(DAT>DATEEND) D
41 .S TN=0 F S TN=$O(^PRCA(433,"AT",TYP,DAT,TN)) Q:'TN D
42 ..S TN0=$G(^PRCA(433,+TN,0))
43 ..S TN1=$G(^PRCA(433,+TN,1))
44 ..S TN3=$G(^PRCA(433,+TN,3))
45 ..S BILL=$P(TN0,"^",2) Q:'BILL S CAT=$P($G(^PRCA(430,+BILL,0)),"^",2) Q:'CAT
46 ..I $G(^TMP($J,"CAT",0))'="ALL" Q:'$D(^TMP($J,"CAT",CAT))
47 ..S RECPT=$P(TN1,"^",3)
48 ..S DATE=$P(TN1,"^")
49 ..S AMT=$P(TN1,"^",5),PRIN=+TN3,INT=$P(TN3,"^",2),ADM=$P(TN3,"^",3)
50 ..S ^TMP($J,"PAY",CAT,BILL,TN)=DATE_"/"_DAT_"^"_RECPT_"^"_AMT_"^"_PRIN_"^"_INT_"^"_ADM
51TOT S CAT=0 F S CAT=$O(^TMP($J,"PAY",CAT)) Q:'CAT D
52 .S ^TMP($J,"PAY",CAT,"TOT")=0
53 .S BILL=0 F S BILL=$O(^TMP($J,"PAY",CAT,BILL)) Q:'BILL D
54 ..S TN=0 F S TN=$O(^TMP($J,"PAY",CAT,BILL,TN)) Q:'TN D
55 ...F Z=2:1:5 S $P(^TMP($J,"PAY",CAT,"TOT"),"^",Z-1)=$P(^TMP($J,"PAY",CAT,BILL,TN),"^",Z+1)+$P(^TMP($J,"PAY",CAT,"TOT"),"^",Z-1)
56 ...F X=1:1:4 S $P(^TMP($J,"PAY","TOT"),"^",X)=$P($G(^TMP($J,"PAY",CAT,"TOT")),"^",X)+$P($G(^TMP($J,"PAY","TOT")),"^",X)
57 ;
58 ;start print
59 S (OUT,PG)=0
60 S Y=DATESTRT D DD^%DT S DATEX=Y
61 S Y=DATEEND D DD^%DT S DATEY=$P(Y,"@")
62 D NOW^%DTC S Y=% D DD^%DT S NOW=Y
63 I $E(IOST,1,2)="C" W @IOF
64 D HDR D:SUM="S" HDR2 D:SUM="D" HDR1
65 Q
66 ;
67HDR ;header
68 W:$E(IOST,1,2)="C-" @IOF
69 S PG=PG+1
70 W !,"DATE SORTED REPORT"_$S(SUM="D":" Detailed",1:" Summary")
71 W ?45,NOW,?68,"PAGE ",PG
72 W !,?20,"FOR DATES: ",DATEX," - ",DATEY
73 S LN="",$P(LN,"-",IOM)=""
74 ;W !,LN
75 Q
76 ;
77HDR1 ;detailed header
78 W !,"BILL",?13,"POSTED DATE",?25,"PAYMENT DATE",?38,"RECEIPT",?54,"AMOUNT",?69,"PRIN",?83,"INT",?95,"ADM"
79 W !,LN
80 Q
81 ;
82HDR2 ;summary header
83 W !,?26,"AMOUNT",?37,"PRIN",?46,"INT",?57,"ADM"
84 W !,LN
85 Q
86 ;
87DPRNT ;print
88 S ^TMP($J,"PAY","TOT")=0
89 S (CAT,CNT,CNT(2),OUT)=0 F S CAT=$O(^TMP($J,"PAY",CAT)) Q:'CAT!OUT D W !
90 .F X=1:1:4 S $P(^TMP($J,"PAY","TOT"),"^",X)=$P($G(^TMP($J,"PAY","TOT")),"^",X)+$P($G(^TMP($J,"PAY",CAT,"TOT")),"^",X)
91 .W !,"CATEGORY: ",$P($G(^PRCA(430.2,+CAT,0)),"^")
92 .S (CNT,CNT(1),BILL)=0 F S BILL=$O(^TMP($J,"PAY",CAT,BILL)) Q:BILL=""!OUT D
93 ..S:BILL'="TOT" CNT=CNT+1
94 ..I BILL="TOT" D
95 ...W !,"TOTAL BILLS: ",CNT,?52,$J($P(^TMP($J,"PAY",CAT,"TOT"),"^"),9,2)
96 ...W ?65,$J($P(^TMP($J,"PAY",CAT,"TOT"),"^",2),9,2),?78,$J($P(^("TOT"),"^",3),8,2),?90,$J($P(^("TOT"),"^",4),8,2)
97 ...S TOT=^TMP($J,"PAY",CAT,"TOT")
98 ...W !,"TOTAL PAYMENTS:",?52,$J(CNT(1),9),?65,$J(CNT(1),9),?77,$J(CNT(1),9),?89,$J(CNT(1),9)
99 ...W !,"SUBMEAN:"
100 ...W ?52,$S($P(TOT,"^"):$J($P(TOT,"^")/CNT(1),9,2),1:"")
101 ...W ?65,$S($P(TOT,"^",2):$J($P(TOT,"^",2)/CNT(1),9,2),1:"")
102 ...W ?77,$S($P(TOT,"^",3):$J($P(TOT,"^",3)/CNT(1),9,2),1:"")
103 ...W ?89,$S($P(TOT,"^",4):$J($P(TOT,"^",4)/CNT(1),9,2),1:"")
104 ..S TN=0 F S TN=$O(^TMP($J,"PAY",CAT,BILL,TN)) Q:'TN!OUT D
105 ...S CNT(1)=CNT(1)+1,CNT(2)=CNT(2)+1
106 ...S TN0=^TMP($J,"PAY",CAT,BILL,TN)
107 ...W !,$P($G(^PRCA(430,+BILL,0)),"^")
108 ...W ?13 S Y=$P($P(TN0,"^"),"/",2) X ^DD("DD") W Y
109 ...Q:OUT S Y=$P($P(TN0,"^"),"/") X ^DD("DD") W ?26,Y
110 ...W ?38,$P(TN0,"^",2),?52,$J($P(TN0,"^",3),9,2),?65,$J($P(TN0,"^",4),9,2),?78,$J($P(TN0,"^",5),8,2),?90,$J($P(TN0,"^",6),8,2)
111 ..Q:OUT I $Y+10>IOSL D
112 ...N DIR,DIRUT
113 ...I $E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR S:$D(DIRUT) OUT=1
114 ...Q:OUT W @IOF D HDR,HDR1
115 S TOT=^TMP($J,"PAY","TOT")
116 Q:OUT W !,"TOTAL:",?52,$J($P(TOT,"^"),9,2)
117 W ?65,$J($P(TOT,"^",2),9,2),?77,$J($P(TOT,"^",3),9,2),?89,$J($P(TOT,"^",4),9,2)
118 W !,"COUNT",?52,$J(CNT(2),9),?65,$J(CNT(2),9),?77,$J(CNT(2),9),?89,$J(CNT(2),9)
119 W !,"MEAN"
120 W ?52,$S($P(TOT,"^"):$J($P(TOT,"^")/CNT(2),9,2),1:"")
121 W ?65,$S($P(TOT,"^",2):$J($P(TOT,"^",2)/CNT(2),9,2),1:"")
122 W ?77,$S($P(TOT,"^",3):$J($P(TOT,"^",3)/CNT(2),9,2),1:"")
123 W ?89,$S($P(TOT,"^",4):$J($P(TOT,"^",4)/CNT(2),9,2),1:"")
124 W:$O(^TMP($J,"PAY",0))="" !?30,"NONE IN THIS DATE RANGE"
125 I $E(IOST,1,2)="C-" R !,"PRESS RETURN TO CONTINUE",X:DTIME
126 D ^%ZISC
127 K ^TMP($J,"PAY")
128 Q
129 ;
130 ;
131 ;
132DATESEL(DESCR) ; select starting and ending dates in days
133 ; returns datestrt and dateend
134 N %,%DT,%H,%I,DEFAULT,X,Y
135 K DATEEND,DATESTRT
136START S Y=$E(DT,1,5)_"01" D DD^%DT S DEFAULT=Y
137 S %DT("A")="Start with "_$S(DESCR'="":DESCR_" ",1:"")_"Date: ",%DT("B")=DEFAULT,%DT="AEP",%DT(0)=-DT D ^%DT I Y<0 Q
138 I $E(Y,6,7)="00" S Y=$E(Y,1,5)_"01"
139 S DATESTRT=Y
140 S Y=DT D DD^%DT S DEFAULT=Y
141 S %DT("A")=" End with "_$S(DESCR'="":DESCR_" ",1:"")_"Date: ",%DT("B")=DEFAULT,%DT="AEP",%DT(0)=-DT D ^%DT I Y<0 Q
142 I $E(Y,6,7)="00" S Y=$E(Y,1,5)_"01"
143 I Y<DATESTRT W !,"END DATE MUST BE GREATER THAN OR EQUAL TO THE START DATE.",! G START
144 S DATEEND=Y,Y=DATESTRT D DD^%DT
145 W !?5,"*** Selected date range from ",Y," to " S Y=DATEEND D DD^%DT W Y," ***"
146 Q
147 ;
148 ;
149SPRNT ;Print Summary
150 S ^TMP($J,"PAY","TOT")=0
151 S (CAT,CNT(2))=0 F S CAT=$O(^TMP($J,"PAY",CAT)) Q:'CAT!(OUT) D
152 .I $Y+7>IOSL D
153 ..I $E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR S:$D(DIRUT) OUT=1
154 ..Q:OUT W @IOF D HDR,HDR2
155 .Q:OUT
156 .W !!,"CATEGORY: ",$P(^PRCA(430.2,+CAT,0),"^")
157 .W !,"TOTAL BILLS: "
158 .S (BILL,CNT)=0 F S BILL=$O(^TMP($J,"PAY",CAT,BILL)) Q:'BILL S CNT=CNT+1
159 .W CNT
160 .S (CNT(1),BILL,TN)=0 F S BILL=$O(^TMP($J,"PAY",CAT,BILL)) Q:'BILL D
161 ..S TN=0 F S TN=$O(^TMP($J,"PAY",CAT,BILL,TN)) Q:'TN S CNT(1)=CNT(1)+1,CNT(2)=CNT(2)+1
162 .S TOT=^TMP($J,"PAY",CAT,"TOT")
163 .W ?22,$J($P(TOT,"^"),9,2),?33,$J($P(TOT,"^",2),9,2),?43,$J($P(TOT,"^",3),8,2),?54,$J($P(TOT,"^",4),8,2)
164 .F X=1:1:4 S $P(^TMP($J,"PAY","TOT"),"^",X)=$P(TOT,"^",X)+$P($G(^TMP($J,"PAY","TOT")),"^",X)
165 .W !,"TOTAL PAYMENTS",?22,$J(CNT(1),9),?33,$J(CNT(1),9),?41,$J(CNT(1),9),?53,$J(CNT(1),9)
166 .W !,"SUBMEAN",?22,$S($P(TOT,"^"):$J($P(TOT,"^")/CNT(1),9,2),1:"")
167 .W ?33,$S($P(TOT,"^",2):$J($P(TOT,"^",2)/CNT(1),9,2),1:"")
168 .W ?42,$S($P(TOT,"^",3):$J($P(TOT,"^",3)/CNT(1),9,2),1:"")
169 .W ?53,$S($P(TOT,"^",4):$J($P(TOT,"^",4)/CNT(1),9,2),1:"")
170 S TOT=^TMP($J,"PAY","TOT")
171 Q:OUT W !!,"TOTAL",?22,$J($P(TOT,"^"),9,2),?33,$J($P(TOT,"^",2),9,2)
172 W ?42,$J($P(TOT,"^",3),9,2),?53,$J($P(TOT,"^",4),9,2)
173 W !,"COUNT",?22,$J(CNT(2),9),?33,$J(CNT(2),9),?42,$J(CNT(2),9),?53,$J(CNT(2),9)
174 W !,"MEAN",?22,$S($P(TOT,"^"):$J($P(TOT,"^")/CNT(2),9,2),1:"")
175 W ?33,$S($P(TOT,"^",2):$J($P(TOT,"^",2)/CNT(2),9,2),1:"")
176 W ?42,$S($P(TOT,"^",3):$J($P(TOT,"^",3)/CNT(2),9,2),1:"")
177 W ?53,$S($P(TOT,"^",4):$J($P(TOT,"^",4)/CNT(2),9,2),1:"")
178 W:$O(^TMP($J,"PAY",0))="" !?30,"NONE IN THIS DATE RANGE"
179 I $E(IOST,1,2)="C-" R !,"PRESS RETURN TO CONTINUE",X:DTIME
180 Q
Note: See TracBrowser for help on using the repository browser.