PRCPRISW ;WISC/RFJ-inventory sales (print whse) ;24 May 93
;;5.1;IFCAP;;Oct 20, 2000
;Per VHA Directive 10-93-142, this routine should not be modified.
Q
;
;
PRINT ; print whse report
N %,%H,%I,DA,DATA,DATE,DATEEDT,DATESDT,DISTRNM,DISTRPT,ITEMDA,ITEMDATA,NOW,NSN,PAGE,PRCPDATA,PRCPFLAG,SCREEN,TOTALQ,TOTALQI,TOTALV,TOTALVI,TYPE,X,Y
K ^TMP($J,"PRCPRISR"),^TMP($J,"PRCPRISR TOT")
S DATE=DATESTRT-.01 F S DATE=$O(^PRCP(445.2,"AX",PRCP("I"),DATE)) Q:'DATE!(DATE>DATEEND) F TYPE="R","C","E" S DA=0 F S DA=$O(^PRCP(445.2,"AX",PRCP("I"),DATE,TYPE,DA)) Q:'DA D
. S DATA=$G(^PRCP(445.2,DA,0)) I DATA="" Q
. S ITEMDA=$P(DATA,"^",5),NSN=$$NSN^PRCPUX1(ITEMDA) S:NSN="" NSN=" "
. I $E(NSN,1,$L(PRCPSTRT))'=PRCPSTRT,$E(NSN,1,$L(PRCPEND))'=PRCPEND I NSN']PRCPSTRT!(PRCPEND']NSN) Q
. S DISTRPT=+$P(DATA,"^",18)
. I 'DISTRPT,'$G(DISTRALL) Q
. I $G(DISTRALL),$D(^TMP($J,"PRCPURS3","NO",DISTRPT)) Q
. I '$G(DISTRALL),'$D(^TMP($J,"PRCPURS3","YES",DISTRPT)) Q
. S DISTRNM=$$INVNAME^PRCPUX1(DISTRPT) S:DISTRNM="" DISTRNM=" "
. S $P(DATA,"^",7)=-$P(DATA,"^",7)
. I '$P(DATA,"^",23) S $P(DATA,"^",23)=$J($P(DATA,"^",7)*$P(DATA,"^",9),0,2)
. I $P(DATA,"^",23)<0 S $P(DATA,"^",23)=-$P(DATA,"^",23)
. S ^TMP($J,"PRCPRISR",NSN,ITEMDA,$E(DISTRNM,1,24),DATE,DA)=$P(DATA,"^",7)_"^"_$S('$P(DATA,"^",7):0,1:$J($P(DATA,"^",23)/$P(DATA,"^",7),0,3))_"^"_$P(DATA,"^",23)
; print report
S Y=DATESTRT D DD^%DT S DATESDT=Y,Y=DATEEND D DD^%DT S DATEEDT=Y
D NOW^%DTC S Y=% D DD^%DT S NOW=Y,PAGE=1,SCREEN=$$SCRPAUSE^PRCPUREP U IO D H
S NSN="" F S NSN=$O(^TMP($J,"PRCPRISR",NSN)) Q:NSN=""!($G(PRCPFLAG)) S ITEMDA=0 F S ITEMDA=$O(^TMP($J,"PRCPRISR",NSN,ITEMDA)) Q:'ITEMDA!($G(PRCPFLAG)) D
. I $G(ZTQUEUED),$$S^%ZTLOAD S PRCPFLAG=1 W !?10,"<<< TASKMANAGER JOB TERMINATED BY USER >>>" Q
. I $Y>(IOSL-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
. S ITEMDATA=$G(^PRCP(445,PRCP("I"),1,ITEMDA,0))
. W:'PRCPSUMM !,$TR(NSN,"-"),?15,$E($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,23),?39,"[",ITEMDA,"]"
. S (TOTALQI,TOTALVI)=0
. S DISTRPT="" F S DISTRPT=$O(^TMP($J,"PRCPRISR",NSN,ITEMDA,DISTRPT)) Q:DISTRPT=""!($G(PRCPFLAG)) D
. . W:'PRCPSUMM !?15,$S(DISTRPT=" ":"<<NONE>>",1:DISTRPT)
. . S (TOTALQ,TOTALV)=0
. . S DATE=0 F S DATE=$O(^TMP($J,"PRCPRISR",NSN,ITEMDA,DISTRPT,DATE)) Q:'DATE!($G(PRCPFLAG)) S DA=0 F S DA=$O(^TMP($J,"PRCPRISR",NSN,ITEMDA,DISTRPT,DATE,DA)) Q:'DA!($G(PRCPFLAG)) S PRCPDATA=^(DA) D
. . . W:'PRCPSUMM ?40,$E(DATE,4,5),"/",$E(DATE,6,7),"/",$E(DATE,2,3),$J($P(PRCPDATA,"^"),10),$J($P(PRCPDATA,"^",2),10,3),$J($P(PRCPDATA,"^",3),12,2),!
. . . S TOTALQ=TOTALQ+$P(PRCPDATA,"^"),TOTALV=TOTALV+$P(PRCPDATA,"^",3)
. . . I $Y>(IOSL-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H W !
. . I $G(PRCPFLAG) Q
. . S TOTALQI=TOTALQI+TOTALQ,TOTALVI=TOTALVI+TOTALV
. . S ^TMP($J,"PRCPRISR TOT",DISTRPT)=$G(^TMP($J,"PRCPRISR TOT",DISTRPT))+TOTALV
. . I 'PRCPSUMM W:$X>20 ! W ?27,"TOTALS BY DISTR. PT: ",$J(TOTALQ,10),$J(TOTALV,22,2)
. I $G(PRCPFLAG) Q
. W:'PRCPSUMM !?32,"TOTALS BY ITEM: ",$J(TOTALQI,10),$J(TOTALVI,22,2)
I $G(PRCPFLAG) Q
I $Y>(IOSL-8) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
W !!,"TOTAL SALES TO DISTRIBUTION POINTS:"
S TOTALV=0,DISTRPT="" F S DISTRPT=$O(^TMP($J,"PRCPRISR TOT",DISTRPT)) Q:DISTRPT=""!($G(PRCPFLAG)) S %=$G(^(DISTRPT)) D
. W !?10,DISTRPT,?40,$J(%,20,2)
. S TOTALV=TOTALV+%
. I $Y>(IOSL-4) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
I $G(PRCPFLAG) Q
W !?10,"TOTAL",?40,$J(TOTALV,20,2)
D END^PRCPUREP
Q
;
H S %=NOW_" PAGE "_PAGE,PAGE=PAGE+1 I PAGE'=2!(SCREEN) W @IOF
W $C(13),"INVENTORY SALES FOR: ",$E(PRCP("IN"),1,20),?(80-$L(%)),%
W !?5,"INVENTORY SALES DATE RANGE: ",DATESDT," TO ",DATEEDT
S %="",$P(%,"-",81)=""
I PRCPSUMM W !?1,"*** ONLY SUMMARY OF SALES PRINTED ***",!,% Q
W !,"NSN",?15,"DESCRIPTION",?37,"DATE ISSUED",$J("QUANTITY",10),$J("SELL COST",10),$J("TOTAL VALUE",12),!,%
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRCPRISW 3921 printed Dec 13, 2024@02:15:03 Page 2
PRCPRISW ;WISC/RFJ-inventory sales (print whse) ;24 May 93
+1 ;;5.1;IFCAP;;Oct 20, 2000
+2 ;Per VHA Directive 10-93-142, this routine should not be modified.
+3 QUIT
+4 ;
+5 ;
PRINT ; print whse report
+1 NEW %,%H,%I,DA,DATA,DATE,DATEEDT,DATESDT,DISTRNM,DISTRPT,ITEMDA,ITEMDATA,NOW,NSN,PAGE,PRCPDATA,PRCPFLAG,SCREEN,TOTALQ,TOTALQI,TOTALV,TOTALVI,TYPE,X,Y
+2 KILL ^TMP($JOB,"PRCPRISR"),^TMP($JOB,"PRCPRISR TOT")
+3 SET DATE=DATESTRT-.01
FOR
SET DATE=$ORDER(^PRCP(445.2,"AX",PRCP("I"),DATE))
if 'DATE!(DATE>DATEEND)
QUIT
FOR TYPE="R","C","E"
SET DA=0
FOR
SET DA=$ORDER(^PRCP(445.2,"AX",PRCP("I"),DATE,TYPE,DA))
if 'DA
QUIT
Begin DoDot:1
+4 SET DATA=$GET(^PRCP(445.2,DA,0))
IF DATA=""
QUIT
+5 SET ITEMDA=$PIECE(DATA,"^",5)
SET NSN=$$NSN^PRCPUX1(ITEMDA)
if NSN=""
SET NSN=" "
+6 IF $EXTRACT(NSN,1,$LENGTH(PRCPSTRT))'=PRCPSTRT
IF $EXTRACT(NSN,1,$LENGTH(PRCPEND))'=PRCPEND
IF NSN']PRCPSTRT!(PRCPEND']NSN)
QUIT
+7 SET DISTRPT=+$PIECE(DATA,"^",18)
+8 IF 'DISTRPT
IF '$GET(DISTRALL)
QUIT
+9 IF $GET(DISTRALL)
IF $DATA(^TMP($JOB,"PRCPURS3","NO",DISTRPT))
QUIT
+10 IF '$GET(DISTRALL)
IF '$DATA(^TMP($JOB,"PRCPURS3","YES",DISTRPT))
QUIT
+11 SET DISTRNM=$$INVNAME^PRCPUX1(DISTRPT)
if DISTRNM=""
SET DISTRNM=" "
+12 SET $PIECE(DATA,"^",7)=-$PIECE(DATA,"^",7)
+13 IF '$PIECE(DATA,"^",23)
SET $PIECE(DATA,"^",23)=$JUSTIFY($PIECE(DATA,"^",7)*$PIECE(DATA,"^",9),0,2)
+14 IF $PIECE(DATA,"^",23)<0
SET $PIECE(DATA,"^",23)=-$PIECE(DATA,"^",23)
+15 SET ^TMP($JOB,"PRCPRISR",NSN,ITEMDA,$EXTRACT(DISTRNM,1,24),DATE,DA)=$PIECE(DATA,"^",7)_"^"_$SELECT('$PIECE(DATA,"^",7):0,1:$JUSTIFY($PIECE(DATA,"^",23)/$PIECE(DATA,"^",7),0,3))_"^"_$PIECE(DATA,"^",23)
End DoDot:1
+16 ; print report
+17 SET Y=DATESTRT
DO DD^%DT
SET DATESDT=Y
SET Y=DATEEND
DO DD^%DT
SET DATEEDT=Y
+18 DO NOW^%DTC
SET Y=%
DO DD^%DT
SET NOW=Y
SET PAGE=1
SET SCREEN=$$SCRPAUSE^PRCPUREP
USE IO
DO H
+19 SET NSN=""
FOR
SET NSN=$ORDER(^TMP($JOB,"PRCPRISR",NSN))
if NSN=""!($GET(PRCPFLAG))
QUIT
SET ITEMDA=0
FOR
SET ITEMDA=$ORDER(^TMP($JOB,"PRCPRISR",NSN,ITEMDA))
if 'ITEMDA!($GET(PRCPFLAG))
QUIT
Begin DoDot:1
+20 IF $GET(ZTQUEUED)
IF $$S^%ZTLOAD
SET PRCPFLAG=1
WRITE !?10,"<<< TASKMANAGER JOB TERMINATED BY USER >>>"
QUIT
+21 IF $Y>(IOSL-6)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
+22 SET ITEMDATA=$GET(^PRCP(445,PRCP("I"),1,ITEMDA,0))
+23 if 'PRCPSUMM
WRITE !,$TRANSLATE(NSN,"-"),?15,$EXTRACT($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,23),?39,"[",ITEMDA,"]"
+24 SET (TOTALQI,TOTALVI)=0
+25 SET DISTRPT=""
FOR
SET DISTRPT=$ORDER(^TMP($JOB,"PRCPRISR",NSN,ITEMDA,DISTRPT))
if DISTRPT=""!($GET(PRCPFLAG))
QUIT
Begin DoDot:2
+26 if 'PRCPSUMM
WRITE !?15,$SELECT(DISTRPT=" ":"<<NONE>>",1:DISTRPT)
+27 SET (TOTALQ,TOTALV)=0
+28 SET DATE=0
FOR
SET DATE=$ORDER(^TMP($JOB,"PRCPRISR",NSN,ITEMDA,DISTRPT,DATE))
if 'DATE!($GET(PRCPFLAG))
QUIT
SET DA=0
FOR
SET DA=$ORDER(^TMP($JOB,"PRCPRISR",NSN,ITEMDA,DISTRPT,DATE,DA))
if 'DA!($GET(PRCPFLAG))
QUIT
SET PRCPDATA=^(DA)
Begin DoDot:3
+29 if 'PRCPSUMM
WRITE ?40,$EXTRACT(DATE,4,5),"/",$EXTRACT(DATE,6,7),"/",$EXTRACT(DATE,2,3),$JUSTIFY($PIECE(PRCPDATA,"^"),10),$JUSTIFY($PIECE(PRCPDATA,"^",2),10,3),$JUSTIFY($PIECE(PRCPDATA,"^",3),12,2),!
+30 SET TOTALQ=TOTALQ+$PIECE(PRCPDATA,"^")
SET TOTALV=TOTALV+$PIECE(PRCPDATA,"^",3)
+31 IF $Y>(IOSL-6)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
WRITE !
End DoDot:3
+32 IF $GET(PRCPFLAG)
QUIT
+33 SET TOTALQI=TOTALQI+TOTALQ
SET TOTALVI=TOTALVI+TOTALV
+34 SET ^TMP($JOB,"PRCPRISR TOT",DISTRPT)=$GET(^TMP($JOB,"PRCPRISR TOT",DISTRPT))+TOTALV
+35 IF 'PRCPSUMM
if $X>20
WRITE !
WRITE ?27,"TOTALS BY DISTR. PT: ",$JUSTIFY(TOTALQ,10),$JUSTIFY(TOTALV,22,2)
End DoDot:2
+36 IF $GET(PRCPFLAG)
QUIT
+37 if 'PRCPSUMM
WRITE !?32,"TOTALS BY ITEM: ",$JUSTIFY(TOTALQI,10),$JUSTIFY(TOTALVI,22,2)
End DoDot:1
+38 IF $GET(PRCPFLAG)
QUIT
+39 IF $Y>(IOSL-8)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
+40 WRITE !!,"TOTAL SALES TO DISTRIBUTION POINTS:"
+41 SET TOTALV=0
SET DISTRPT=""
FOR
SET DISTRPT=$ORDER(^TMP($JOB,"PRCPRISR TOT",DISTRPT))
if DISTRPT=""!($GET(PRCPFLAG))
QUIT
SET %=$GET(^(DISTRPT))
Begin DoDot:1
+42 WRITE !?10,DISTRPT,?40,$JUSTIFY(%,20,2)
+43 SET TOTALV=TOTALV+%
+44 IF $Y>(IOSL-4)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
End DoDot:1
+45 IF $GET(PRCPFLAG)
QUIT
+46 WRITE !?10,"TOTAL",?40,$JUSTIFY(TOTALV,20,2)
+47 DO END^PRCPUREP
+48 QUIT
+49 ;
H SET %=NOW_" PAGE "_PAGE
SET PAGE=PAGE+1
IF PAGE'=2!(SCREEN)
WRITE @IOF
+1 WRITE $CHAR(13),"INVENTORY SALES FOR: ",$EXTRACT(PRCP("IN"),1,20),?(80-$LENGTH(%)),%
+2 WRITE !?5,"INVENTORY SALES DATE RANGE: ",DATESDT," TO ",DATEEDT
+3 SET %=""
SET $PIECE(%,"-",81)=""
+4 IF PRCPSUMM
WRITE !?1,"*** ONLY SUMMARY OF SALES PRINTED ***",!,%
QUIT
+5 WRITE !,"NSN",?15,"DESCRIPTION",?37,"DATE ISSUED",$JUSTIFY("QUANTITY",10),$JUSTIFY("SELL COST",10),$JUSTIFY("TOTAL VALUE",12),!,%
+6 QUIT