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

ACRFPO.m

Go to the documentation of this file.
ACRFPO ;IHS/OIRM/DSD/THL,AEF - PURCHASE ORDER PROCESSING;  [ 09/23/2005   9:44 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**19**;NOV 05, 2001
 ;;ROUTINE USED TO MANAGE VARIOUS ASPECTS OF PURCHASE ORDER PROCESSING
EN ;EP
 K ACRQUIT,ACRUCHK,ACRTXDA
 F  D EN1 Q:$D(ACRQUIT)!$D(ACROUT)
EXIT D EXIT^ACRFPO2
 K ^TMP("ACRDATA",$J),ACRONE,^TMP("ACRDATX",$J)
 Q
EN1 D:'$D(ACRPO) ASSONE^ACRFPO2
 I $D(ACRQUIT)!$D(ACRONE) K ACRONE Q
 I $D(ACRPO) S ACRSCRL=10
 E  D VENDOR^ACRFPO2
 Q:$D(ACRQUIT)!$D(ACROUT)
 K ACRDUZ
 D:ACRSCRL'=6&'$D(ACRPO) AGENT^ACRFPO2
 Q:$D(ACRQUIT)!$D(ACROUT)
 I $D(ACRDUZ) D  Q
 .S (ACRRTN,ZTRTN)="EN11^ACRFPO"
 .D ^ACRFZIS
 .K ACRREV,ACRDUZ
 .S ACRQUIT=""
EN11 ;EP;
 I $D(ACRDUZ)#2 D
 .S ACRREV=""
 .S ACRSCRL=(IOSL\2)-5
 D HEAD^ACRFPO2
 I $D(ACRPO)!$D(ACRPOA) D LOOKUP Q:$D(ACRQUIT)!$D(ACROUT)
 D DISPLAY
 D SELECT^ACRFPO2:'$D(ACRREV)
 D PAUSE:$D(ACRREV)
 I $D(ACRQUIT)!$D(ACROUT),'$D(ACRPO) K ACRQUIT
 I $D(ACRREV) S ACRQUIT=""
 K ACRREV,ACRDUZ
 Q
LOOKUP ;EP;
 K ^TMP("ACRDATA",$J),^TMP("ACRDATX",$J),ACRREQST
 S ACRXREF=$S($D(ACRPO):"PA",1:"PO")
 I $D(ACRPO) S ACRPODA=$S('$D(ACRDUZ):DUZ,1:ACRDUZ)
 E  I $D(^ACRPO("D",DUZ))!$D(^ACRPO("DD",DUZ)) S ACRPODA=$S($D(^ACRPO("D",DUZ)):$O(^(DUZ,0)),1:$O(^ACRPO("DD",DUZ,0)))
 E  I $D(ACRPOA) D  Q
 .W !!,"YOU DO NOT HAVE PURCHASING SUPERVISORY AUTHORITY."
 .W !,"And you are not an alternate to the Purchasing Supervisor."
 .W !,"Contact your ARMS manager for assistance."
 .D PAUSE^ACRFWARN
 .S ACRQUIT=""
 K ACRDATA
 N ACRREFZ,ACRAPV
 S (ACRDOCDA,ACRJ)=0
 F  S ACRDOCDA=$O(^ACRDOC(ACRXREF,ACRPODA,"A",ACRDOCDA)) Q:'ACRDOCDA  D
 .S ACRDOC=^ACRDOC(ACRDOCDA,0)
 .S ACRREFZ=$P(ACRDOC,U,13)
 .S ACRREFZ=$P($G(^AUTTDOCR(+ACRREFZ,0)),U)
 .S ACRAPV=$G(^ACROBL(ACRDOCDA,"APV"))
 .I $E(ACRAPV)="A",$P(ACRAPV,U,8)="","^103^349^326^210^"[(U_ACRREFZ_U)!(ACRREFZ=116&($P(ACRDOC,U,4)=35)),$D(^ACRSS("J",ACRDOCDA)) D LIST I 1
 I ACRJ K ACRDATA D
 .S (ACRJ,ACRRDATE)=0
 .F  S ACRRDATE=$O(^TMP("ACRDATX",$J,ACRRDATE)) Q:'ACRRDATE  D
 ..S ACRRDAT2=0
 ..F  S ACRRDAT2=$O(^TMP("ACRDATX",$J,ACRRDATE,ACRRDAT2)) Q:'ACRRDAT2  D
 ...S ACRJ=ACRJ+1
 ...S ^TMP("ACRDATA",$J,ACRJ)=^TMP("ACRDATX",$J,ACRRDATE,ACRRDAT2)
 K ACRQUIT,ACRUCHK
 Q
DISPLAY ;EP;
 U IO
 S (ACRMAX,ACRJ)=0
 S:$D(ACRPOA) ACRPADA2=""
 F  S ACRJ=$O(^TMP("ACRDATA",$J,ACRJ)) Q:'ACRJ!$D(ACRQUIT)!$D(ACROUT)  D
 .D LIST1
 .I $D(ACRQUIT)!$D(ACROUT)!(ACRJ#ACRSCRL=0&(ACRMAX<(ACRJ+ACRSCRL))) S ACRQUIT="" Q
 .I ACRJ#ACRSCRL=0 D
 ..D PAUSE
 ..D:'$D(ACRQUIT) HEAD^ACRFPO2
 K ACRQUIT
 Q
LIST ;CREATE PURCHASE ORDER LIST ARRAY
 I $D(ACRTRANS),$G(ACRZDA)=ACRDOCDA Q
 Q:'$D(^ACRSS("J",ACRDOCDA))&'$P(^ACRDOC(ACRDOCDA,0),U,15)
 D OBJ^ACRFPO2
 Q:$G(ACROBJ)=""
 S ACRJ=ACRJ+1
 S ACRDATA=^ACRDOC(ACRDOCDA,0)
 S ACRVDA=$P(^ACRDOC(ACRDOCDA,"PO"),U,5)
 S ACRPRIOR=$P(^ACRDOC(ACRDOCDA,"DT"),U,4)
 S ACRRDATE=$S($P(^ACRDOC(ACRDOCDA,"REQ"),U,11)]"":$P(^("REQ"),U,11),1:$E(DT,1,3)_"0000")
 S ACRDOC=$P(ACRDATA,U,2)
 S ACRDOC1=$P(ACRDATA,U)
 S ACRTXTYP=$P(ACRDATA,U,4)
 S ACRREF1=$P(^AUTTDOCR($P(^ACRTXTYP(ACRTXTYP,0),U,2),0),U)
 I $G(ACRSCRL)=6 D
 .I ACRVDA,$D(^AUTTVNDR(ACRVDA,0)) S ACRVDA=$P(^(0),U)
 .E  S ACRVDA="NOT STATED"
 S ACRPADA=$G(^ACRDOC(ACRDOCDA,"PA"))
 S ACRPADAT=$P(ACRPADA,U,2)
 S ACRPADA=+ACRPADA
 S ACRPA=""
 I ACRPADA,$D(ACRPOA)  D
 .;S ACRPA=$G(^VA(200,ACRPADA,0))  ;ACR*2.1*19.02 IM16848
 .;S ACRPA=$E($E($P($P(ACRPA,U),",",2))_" "_$P(ACRPA,","),1,11)  ;ACR*2.1*19.02 IM16848
 .S ACRPA=$$NAME2^ACRFUTL1(ACR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 ..W ?65,$P(Y,U,9),$J($FN($P(Y,U,10),"P,",0),10)
 .Q:ACRSCRL>6
 .W !?7,$P(X,U,11)
 .I $D(Y) D
 ..W ?40,"|"
 ..W ?48,$P(Y,U,11)
 Q
PAUSE I $E(IOST,1,2)'="C-" S ACRJ=ACRJ+ACRSCRL Q
 S DIR(0)="YO"
 S DIR("A")="    Display more documents"
 S DIR("B")="YES"
 W !
 D DIR^ACRFDIC
 I Y=1 W ! S ACRJ=ACRJ+ACRSCRL Q
 S ACRQUIT=""
 Q
ACRPOA ;EP;TO ASSIGN PO TO PA
 S ACRPOA=""
 D EN
 K ACRPOA
 Q
ACRPO ;EP;TO BEGIN PO ADD/EDIT
 N ACRPO,ACRENTRY
 S ACRENTRY="PO"
 S ACRPO=""
 F  D MOD^ACRFPO1 Q:$D(ACRQUIT)!$D(ACROUT)
 Q
ACRPPO ;EP;TO PRINT PURCHASE ORDER
 N ACRPRT,ACRPPO,ACRENTRY
 S ACRENTRY="PO"
 S (ACRPRT,ACRPPO)=""
 D PRINT^ACRFPO1
 Q
ITOT ;CALCULATE ITEM TOTALS FOR THE PO
 N X
 S (X,ACRITOT)=0
 F  S X=$O(^ACRSS("J",ACRDOCDA,X)) Q:'X  S ACRITOT=ACRITOT+$P($G(^ACRSS(X,"DT")),U,4)
 Q