Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PRCPRISS

PRCPRISS.m

Go to the documentation of this file.
  1. PRCPRISS ;WISC/RFJ-inventory sales (secondary) ;24 May 93
  1. V ;;5.1;IFCAP;**1,41**;Oct 20, 2000
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. Q
  1. ;
  1. ;
  1. ; inventory sales report
  1. SECOND N ANS,DATEEND,DATESTRT,DISTRALL,PRCPEND,PRCPSTRT,PRCPSUMM,X
  1. K X S X(1)="The Inventory Sales Report will display all sales from the Secondary inventory point. This report is sorted by description, the recipient and the date issued." D DISPLAY^PRCPUX2(40,79,.X)
  1. ;
  1. K X S X(1)="Select the RECIPIENTS to display" D DISPLAY^PRCPUX2(2,40,.X)
  1. D DISTRSEL^PRCPURS3(PRCP("I"))
  1. I '$G(DISTRALL),$O(^TMP($J,"PRCPURS3","YES",0))']"" W !,"*** NO RECIPIENTS SELECTED !" D Q Q
  1. ;
  1. K X S X(1)="Select the range of ISSUE DATES to display" W !! D DISPLAY^PRCPUX2(2,40,.X)
  1. D DATESEL^PRCPURS2("Issue") I '$G(DATEEND) D Q Q
  1. ;
  1. S PRCPSUMM=$$SUMMARY^PRCPURS0 I PRCPSUMM<0 D Q Q
  1. ;
  1. W ! S %ZIS="Q" D ^%ZIS G:POP Q I $D(IO("Q")) D D ^%ZTLOAD K IO("Q"),ZTSK D Q Q
  1. . S ZTDESC="Secondary Inventory Sales Report",ZTRTN="DQ^PRCPRISS"
  1. . S ZTSAVE("PRCP*")="",ZTSAVE("DATE*")="",ZTSAVE("DISTRALL")="",ZTSAVE("^TMP($J,""PRCPURS3"",")="",ZTSAVE("ZTREQ")="@"
  1. W !!,"<*> please wait <*>"
  1. ;
  1. ; queue starts here
  1. DQ N %,%H,%I,DA,DATA,DATE,DATEEDT,DATESDT,DESCR,DISTRNM,DISTRPT,ITEMDA,ITEMDATA,NOW,PAGE,PRCPDATA,PRCPFLAG,SCREEN,TOTALQ,TOTALQI,TOTALV,TOTALVI,X,Y
  1. K ^TMP($J,"PRCPRISP"),^TMP($J,"PRCPRISP TOT")
  1. S DATE=DATESTRT-.01 F S DATE=$O(^PRCP(445.2,"AX",PRCP("I"),DATE)) Q:'DATE!(DATE>DATEEND) S DA=0 F S DA=$O(^PRCP(445.2,"AX",PRCP("I"),DATE,"U",DA)) Q:'DA D
  1. . S DATA=$G(^PRCP(445.2,DA,0)) I DATA="" Q
  1. . S ITEMDA=$P(DATA,"^",5),DESCR=$$DESCR^PRCPUX1(PRCP("I"),ITEMDA) S:DESCR="" DESCR=" "
  1. . S DISTRPT=$P($G(^PRCP(445.2,DA,2)),"^",2)
  1. . I DISTRPT']"",'$G(DISTRALL) Q
  1. . I $G(DISTRALL),$D(^TMP($J,"PRCPURS3","NO",DISTRPT)) Q
  1. . I '$G(DISTRALL),'$D(^TMP($J,"PRCPURS3","YES",DISTRPT)) Q
  1. . S $P(DATA,"^",7)=-$P(DATA,"^",7),$P(DATA,"^",23)=-$P(DATA,"^",23)
  1. . I '$P(DATA,"^",23) S $P(DATA,"^",23)=$J($P(DATA,"^",7)*$P(DATA,"^",8),0,2)
  1. . S ^TMP($J,"PRCPRISP",$E(DESCR,1,10),ITEMDA,$E(DISTRPT,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)
  1. ;
  1. ; print report
  1. S Y=DATESTRT D DD^%DT S DATESDT=Y,Y=DATEEND D DD^%DT S DATEEDT=Y
  1. D NOW^%DTC S Y=% D DD^%DT S NOW=Y
  1. S PAGE=1,SCREEN=$$SCRPAUSE^PRCPUREP U IO D H
  1. S DESCR="" F S DESCR=$O(^TMP($J,"PRCPRISP",DESCR)) Q:DESCR=""!($G(PRCPFLAG)) S ITEMDA=0 F S ITEMDA=$O(^TMP($J,"PRCPRISP",DESCR,ITEMDA)) Q:'ITEMDA!($G(PRCPFLAG)) D
  1. . I $G(ZTQUEUED),$$S^%ZTLOAD S PRCPFLAG=1 W !?10,"<<< TASKMANAGER JOB TERMINATED BY USER >>>" Q
  1. . I $Y>(IOSL-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
  1. . S ITEMDATA=$G(^PRCP(445,PRCP("I"),1,ITEMDA,0))
  1. . W:'PRCPSUMM !,$E($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,38),?39,"[",ITEMDA,"]"
  1. . S (TOTALQI,TOTALVI)=0
  1. . S DISTRPT="" F S DISTRPT=$O(^TMP($J,"PRCPRISP",DESCR,ITEMDA,DISTRPT)) Q:DISTRPT=""!($G(PRCPFLAG)) D
  1. . . W:'PRCPSUMM !?15,$S(DISTRPT=" ":"<<NONE>>",1:DISTRPT)
  1. . . S (TOTALQ,TOTALV)=0
  1. . . S DATE=0 F S DATE=$O(^TMP($J,"PRCPRISP",DESCR,ITEMDA,DISTRPT,DATE)) Q:'DATE!($G(PRCPFLAG)) S DA=0 F S DA=$O(^TMP($J,"PRCPRISP",DESCR,ITEMDA,DISTRPT,DATE,DA)) Q:'DA!($G(PRCPFLAG)) S PRCPDATA=^(DA) D
  1. . . . 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),!
  1. . . . S TOTALQ=TOTALQ+$P(PRCPDATA,"^"),TOTALV=TOTALV+$P(PRCPDATA,"^",3)
  1. . . . I $Y>(IOSL-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H W !
  1. . . I $G(PRCPFLAG) Q
  1. . . S TOTALQI=TOTALQI+TOTALQ,TOTALVI=TOTALVI+TOTALV
  1. . . S ^TMP($J,"PRCPRISP TOT",DISTRPT)=$G(^TMP($J,"PRCPRISP TOT",DISTRPT))+TOTALV
  1. . . I 'PRCPSUMM W:$X>20 ! W ?27,"TOTALS BY RECIPIENT: ",$J(TOTALQ,10),$J(TOTALV,22,2)
  1. . I $G(PRCPFLAG) Q
  1. . W:'PRCPSUMM !?32,"TOTALS BY ITEM: ",$J(TOTALQI,10),$J(TOTALVI,22,2)
  1. I $G(PRCPFLAG) D Q Q
  1. I $Y>(IOSL-8) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
  1. W !!,"TOTAL SALES TO RECIPIENTS:"
  1. S TOTALV=0,DISTRPT="" F S DISTRPT=$O(^TMP($J,"PRCPRISP TOT",DISTRPT)) Q:DISTRPT=""!($G(PRCPFLAG)) S %=$G(^(DISTRPT)) D
  1. . W !?10,DISTRPT,?40,$J(%,20,2)
  1. . S TOTALV=TOTALV+%
  1. . I $Y>(IOSL-4) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
  1. I $G(PRCPFLAG) D Q Q
  1. W !?10,"TOTAL",?40,$J(TOTALV,20,2)
  1. D END^PRCPUREP
  1. Q D ^%ZISC K ^TMP($J,"PRCPURS3"),^TMP($J,"PRCPRISP"),^TMP($J,"PRCPRISP TOT")
  1. Q
  1. ;
  1. H S %=NOW_" PAGE "_PAGE,PAGE=PAGE+1 I PAGE'=2!(SCREEN) W @IOF
  1. W $C(13),"INVENTORY SALES FOR: ",$E(PRCP("IN"),1,20),?(80-$L(%)),%
  1. W !?5,"INVENTORY SALES DATE RANGE: ",DATESDT," TO ",DATEEDT
  1. S %="",$P(%,"-",81)=""
  1. I PRCPSUMM W !?1,"*** ONLY SUMMARY OF SALES PRINTED ***",!,% Q
  1. W !,"DESCRIPTION",?37,"DATE ISSUED",$J("QUANTITY",10),$J("SELL COST",10),$J("TOTAL VALUE",12),!,%
  1. Q
  1. ;
  1. TOWHOM(INVPT) ; identify a recipient
  1. ;
  1. ;
  1. N DIC,DIR,PRCPA,PRCPB,PRCPC,PRCPD,PRCPI
  1. TOWHOM1 S DIR(0)="FOU^3:50"
  1. S DIR("A")="RECIPIENT"
  1. D ^DIR K DIR
  1. I $G(DUOUT)!$G(DTOUT)!(Y']"") G TOWHOMQ
  1. S PRCPI=0,PRCPB=X
  1. I $O(^PRCP(445.2,"D",INVPT,X,"")) S PRCPD(1)=X,PRCPI=1
  1. S PRCPA=X
  1. F PRCPC=PRCPI:1 S PRCPA=$O(^PRCP(445.2,"D",INVPT,PRCPA)) Q:$E(PRCPA,1,$L(PRCPB))'=PRCPB!(PRCPA']"") S PRCPD(PRCPC+1)=PRCPA
  1. I '$O(PRCPD("")) W !,"THERE ARE NO RECIPIENTS OF THAT NAME IN THIS INVENTORY POINT" G TOWHOM1
  1. F PRCPI=1:1:PRCPC S DIR("A",PRCPI)=$E(" ",$L(PRCPI+1),4)_PRCPI_" "_PRCPD(PRCPI)
  1. S DIR("A")="WHICH RECIPIENT"
  1. S DIR(0)="L^1:"_PRCPI
  1. D ^DIR K DIR
  1. TOWHOMQ Q ($S($G(DUOUT):"^",$G(DTOUT):"^",Y<1:0,Y="^":0,1:$G(PRCPD(+Y))))