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

ACRFIV5.m

Go to the documentation of this file.
ACRFIV5 ;IHS/OIRM/DSD/THL,AEF - INVOICE AUDIT;  [ 07/24/2002  10:20 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**3**;NOV 05, 2001
 ;;ROUTINE CALLED DURING PROCESSING OF INVOICES
EN K ^TMP("ACRSYNC",$J)
 D EXIT
 D GATHER
 Q:'$D(^TMP("ACRIV",$J))
 F  D CHOOSE Q:$D(ACRQUIT)!$D(ACROUT)
EXIT K ACRSSDT,ACRSSNMS,ACRSSDSC,ACRNOTES,ACRSSUP,ACRSSORD,ACRSSACT,ACRIVACP,ACRSSIT,ACRIVIT,ACRSST,ACRIVT,ACRSSTX,ACRIVTX,ACRRR,ACRRRDA,ACRSS,ACRQUIT,ACRIVPAY,ACRIVTA,ACRRRACP,ACRRRIT,ACRRRT,ACRRRTA,ACRRRUP
 K ^TMP("ACRIV",$J)
 S ACRQUIT=""
 S:'$D(ACROUT)&$D(ACRIVPAY) ACRFINAL=0
 Q:'$D(^TMP("ACRSYNC",$J))
 K ACRIVPAY
 S ACRSSDA=0
 F  S ACRSSDA=$O(^TMP("ACRSYNC",$J,ACRSSDA)) Q:'ACRSSDA  D PAY
 I '$D(ACRIVPAY) D  Q
 .W !!,"No items were marked to be paid at this time."
 .D PAUSE^ACRFWARN
 .S ACRQUIT=""
 Q
GATHER ;EP;GATHER INFO ON RECEIVING ACTIONS
 I '$D(^ACRRR("AC",ACRDOCDA)) D  Q
 .W !!,"No RECEIVING REPORTS on file for this DOCUMENT." ;ACR*2.1*3.16
 .D PAUSE^ACRFWARN
 .S ACRQUIT="" Q
 N ACRSSDA,X,Y,Z
 S (ACRSSDA,ACRMAX)=0
 F  S ACRSSDA=$O(^ACRSS("J",ACRDOCDA,ACRSSDA)) Q:'ACRSSDA  D
 .S ACRX=+^ACRSS(ACRSSDA,0)
 .S ACRMAX=ACRMAX+1
 .I ACRX'=ACRMAX D
 ..S DA=ACRSSDA
 ..S DIE="^ACRSS("
 ..S DR=".01///^S X=ACRMAX"
 ..D DIE^ACRFDIC
 ..S ACRX=ACRMAX
 .S ^TMP("ACRIV",$J,ACRX)=ACRSSDA
 Q
CHOOSE ;CHOOSE WHICH ORDERED ITEMS TO INVOICE FOR
 D ITEMS
 S DIR(0)="SO^1:Invoice ALL REMAINING QUANTITIES for ALL items;2:Invoice for SELECTED items only;3:RE-Set Number Invoiced;4:Display PURCHASE ORDER Items"
 S DIR("A")="Which one"
 W !
 D DIR^ACRFDIC
 I 'Y S ACRQUIT="" Q
 I Y=1 D ALL Q
 I Y=2 D SELECT Q
 I Y=3 D RESET Q
 I Y=4 D ITEMS
 Q
ALL ;
 N ACRSSDA,ACRZ
 S ACRZ=0
 F  S ACRZ=$O(^TMP("ACRIV",$J,ACRZ)) Q:'ACRZ  D ALL1
 W !!,"All items have been marked as INVOICED in full."
 D PAUSE^ACRFWARN
 Q
ALL1 S ACRSSDA=+^TMP("ACRIV",$J,ACRZ)
 S $P(^TMP("ACRSYNC",$J,ACRSSDA),U,3)=$P(^TMP("ACRSYNC",$J,ACRSSDA),U)-$P(^(ACRSSDA),U,2)
 S $P(^TMP("ACRSYNC",$J,ACRSSDA),U,2)=$P(^TMP("ACRSYNC",$J,ACRSSDA),U)
 S $P(^TMP("ACRSYNC",$J,ACRSSDA),U,5)=ACRIVUP
 Q
SELECT D S1
 Q:$G(ACRXX)=""
 S DIR(0)="SO^1:Selected Items COMPLETELY INVOICED at listed cost;2:Edit Individual Items"
 S DIR("A")="Which one"
 W !
 D DIR^ACRFDIC
 Q:'Y
 I Y=1 D EALL Q
 I Y=2 D EDIT
 Q
S1 ;SELECT ITEM(S)
 I ACRMAX=1 S ACRY=+ACRSS0
 E  D
 .S DIR(0)="LOA^1:"_ACRMAX
 .S DIR("A")="Invoice for which items: "
 .W !
 .D DIR^ACRFDIC
 .I '+Y S ACRQUIT="" Q
 S ACRXX=ACRY
 Q
EALL ;
 F ACRI=1:1 S ACRZ=$P(ACRXX,",",ACRI) Q:'ACRZ  D:$D(^TMP("ACRIV",$J,ACRZ)) ALL1
 Q
EDIT F ACRI=1:1 S ACRZ=$P(ACRXX,",",ACRI) Q:'ACRZ  D:$D(^TMP("ACRIV",$J,ACRZ)) IQ
 Q
IQ ;EDIT INVOICE QUANTITIES
 D IDHEAD
 S ACRSSDA=+^TMP("ACRIV",$J,ACRZ)
 D IDISPLAY
 D IEDIT
 Q
IEDIT S DIR(0)="NOA^"_(ACRIVTA*-1)_":"_(ACRRRTA-ACRIVTA)_":3"
 S DIR("A")="QUANTITY INVOICED: "
 W !
 D DIR^ACRFDIC
 Q:$D(ACRQUIT)!$D(ACROUT)!'Y
 S $P(^TMP("ACRSYNC",$J,ACRSSDA),U,2)=Y+ACRIVTA
 S:Y>0 $P(^TMP("ACRSYNC",$J,ACRSSDA),U,3)=Y+$P(^TMP("ACRSYNC",$J,ACRSSDA),U,3)
 S DIR(0)="NOA^0:"_($P(^ACRSS(ACRSSDA,"DT"),U,3)+100)_":4"
 S DIR("A")="INVOICE AMOUNT...: "
 S DIR("B")=$P(^ACRSS(ACRSSDA,"DT"),U,3)
 D DIR^ACRFDIC
 Q:$D(ACRQUIT)!$D(ACROUT)!'Y
 S $P(^TMP("ACRSYNC",$J,ACRSSDA),U,4)=Y
 Q
RESET ;RESET ITEM(S) TO ORIGINAL REMAINING QUANTITY
 D S1
 Q:$G(ACRXX)=""
 F ACRI=1:1 S ACRZ=$P(ACRXX,",",ACRI) Q:'ACRZ  I $D(^TMP("ACRIV",$J,ACRZ)) S ACRSSDA=^(ACRZ) Q:'$D(^TMP("ACRSYNC",$J,+ACRSSDA))  S $P(^(ACRSSDA),U,3)=0
 Q
ITEMS ;DISPLAY ALL ITEMS FROM THE ORDER
 K ACRQUIT
 D IDHEAD
 S ACRZ=0
 F  S ACRZ=$O(^TMP("ACRIV",$J,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RRT=ACRRRT+ACRRRIT
 .S ACRIVT=ACRIVT+ACRIVIT
 I $D(^TMP("ACRSYNC",$J,ACRSSDA)) S ACRIVTA=$P(^(ACRSSDA),U,2)
 E  S $P(^TMP("ACRSYNC",$J,ACRSSDA),U)=ACRRRTA,$P(^(ACRSSDA),U,2)=ACRIVTA,$P(^(ACRSSDA),U,3)=0,$P(^(ACRSSDA),U,4)=ACRIVUP,$P(^(ACRSSDA),U,5)=ACRIVTA,$P(^(ACRSSDA),U,6)=ACRRRTA-ACRIVTA
 Q
IDHEAD ;INVOICE DISPLAY HEADER
 W @IOF
 W !?10,"PURCHASE ORDER NO.......: ",$P(ACRDOC0,U,2),"  ",$P(ACRDOC0,U)
 W !!,?40,"RECEIVED/",?50,"ALREADY"
 W ?70,"REMAINING"
 W !,"ITM"
 W ?4,"ORDER #/DESCRIPT"
 W ?30,"OBLIGATED"
 W ?40,"ACCEPTED"
 W ?50,"PAID"
 W ?60,"THIS PMT"
 W ?70,"TO BE PD"
 W !,"---"
 W ?4,"-------------------------"
 W ?30,"---------"
 W ?40,"---------"
 W ?50,"---------"
 W ?60,"---------"
 W ?70,"---------"
 Q
IDISPLAY ;CONTROL DISPLAY OF ITEMS
 D SS
 D IDISP
 Q
IDISP ;DISPLAY INVOICE HISTORY FOR ITEM
 K ACR1,ACR2,ACR3
 W !,ACRZ
 I $P(ACRSSNMS,U)]"" D
 .W ?4,"VON: ",$P(ACRSSNMS,U)
 .D 1
 .W !?3
 I $P(ACRSSNMS,U,3)]"" D
 .W ?4,"NDC: ",$P(ACRSSNMS,U,3)
 .D 1:'$D(ACR1)
 .D 2:'$D(ACR2)&$D(ACR1)
 .D 3:'$D(ACR3)&$D(ACR1)&$D(ACR2)
 .W !?3
 I $P(ACRSSNMS,U,2)]"" D
 .W ?4,"NSN: ",$P(ACRSSNMS,U,2)
 .D 1:'$D(ACR1)
 .D 2:'$D(ACR2)&$D(ACR1)
 .D 3:'$D(ACR3)&$D(ACR1)&$D(ACR2)
 .W !?3
 W ?4,$P(ACRSSDSC,U)
 N ACRJ,ACRI,ACRX
 F ACRJ=2:1:5 I $P(ACRSSDSC,U,ACRJ)]"" S ACRX=$P(ACRSSDSC,U,ACRJ) D
 .F ACRI=1:1 S ACRY=$P(ACRX," ",ACRI) Q:ACRY=""  D
 ..W:$X+$L(ACRY)>79 !?3
 ..W ?$X+1,ACRY
 D 1:'$D(ACR1)
 I '$D(ACR2)&$D(ACR1) W ! D 2
 I '$D(ACR3)&$D(ACR1)&$D(ACR2) W ! D 3
 W:$L(ACRNOTES)>4 !
 N ACRI,ACRJ,ACRX,ACRY
 F ACRJ=1:1:5 I $P(ACRNOTES,U,ACRJ)]"" S ACRX=$P(ACRNOTES,U,ACRJ) D
 .F ACRI=1:1 S ACRY=$P(ACRX," ",ACRI) Q:ACRY=""  D
 ..W:$X+$L(ACRY)>79 !?3
 ..W ?$X+1,ACRY
 K ACRSSDSC,ACRNOTES,ACRSSNMS
 D 2:'$D(ACR2)
 D 3:'$D(ACR3)
 W $$DASH^ACRFMENU
 I IOSL-4<$Y D
 .S DIR(0)="YO"
 .S DIR("A")="Display Remaining Items"
 .S DIR("B")="YES"
 .W !
 .D DIR^ACRFDIC
 .I Y'=1 S ACRQUIT="" Q
 .D IDHEAD
 Q
1 N X
 S X=^TMP("ACRSYNC",$J,ACRSSDA)
 W:$X>30 !
 W ?30,$J(ACRSSORD,8)
 W ?40,$J($P(X,U),8)
 W ?50,$J($P(X,U,2),8)
 W ?60,$J($P(X,U,3),8)
 W ?70,$J($P(X,U)-$P(X,U,2),8)
 S ACR1=""
 Q
2 N X
 S X=^TMP("ACRSYNC",$J,ACRSSDA)
 W:$X>15 !
 W ?15,"UNIT PRICE:",?30,$J($FN(ACRSSUP,"P,",2),9)
 W ?40,$J($FN(ACRRRUP,"P,",2),9)
 W ?50,$J($FN($P(X,U,4),"P,",2),9)
 S ACR2=""
 Q
3 N X
 S X=^TMP("ACRSYNC",$J,ACRSSDA)
 W:$X>15 !
 W ?15,"TOTAL.....:",?28,$J($FN(ACRSST,"P,",2),9)
 W ?38,$J($FN(ACRRRT,"P,",2),9)
 S ACR3=""
 Q
SYNC ;EP - SYNCHRONIZE NEW INVOICED ITEMS
 K ACRIVPAY
 S ACRSSDA=0
 F  S ACRSSDA=$O(^TMP("ACRSYNC",$J,ACRSSDA)) Q:'ACRSSDA  D
 .S DA=$O(^ACRRR("B",ACRSSDA,0))
 .Q:'DA
 .S ACRRRDA=DA
 .S DIE="^ACRRR("
 .S DR="6////"_$P(^TMP("ACRSYNC",$J,ACRSSDA),U,2)_";5////"_$P(^TMP("ACRSYNC",$J,ACRSSDA),U,4)
 .D DIE^ACRFDIC
 .F  S ACRRRDA=$O(^ACRRR("B",ACRSSDA,ACRRRDA)) Q:'ACRRRDA  D
 ..S DA=ACRRRDA
 ..S DIE="^ACRRR("
 ..S DR="6////0"
 ..I $P($G(^ACRRR(ACRRRDA,"DT")),U,6) D DIE^ACRFDIC
 .D PAY
 K ^TMP("ACRSYNC",$J)
 Q
PAY I '$P(^TMP("ACRSYNC",$J,ACRSSDA),U,3) K ^TMP("ACRSYNC",$J,ACRSSDA) Q
 S ACRCANDA=$P(^ACRSS(ACRSSDA,0),U,5)
 S ACROBJDA=$P(^ACRSS(ACRSSDA,0),U,4)
 S ACRIVPAY(ACRCANDA,ACROBJDA)=$G(ACRIVPAY(ACRCANDA,ACROBJDA))+($P(^TMP("ACRSYNC",$J,ACRSSDA),U,3)*$P(^TMP("ACRSYNC",$J,ACRSSDA),U,4))
 Q
 N ACRSSDA,X,Y,Z,J
 S (ACRSSDA,ACRMAX,J)=0
 F  S ACRSSDA=$O(^ACRSS("J",ACRDOCDA,ACRSSDA)) Q:'ACRSSDA  D
 .S ACRX=+^ACRSS(ACRSSDA,0)
 .S J=J+1
 .I ACRX'=J D
 ..S DA=ACRSSDA
 ..S DIE="^ACRSS("
 ..S DR=".01///^S X=J"
 ..D DIE^ACRFDIC
 ..S ACRX=J
 .I $D(^ACRRR("B",ACRSSDA)) S ^TMP("ACRIV",$J,ACRX)=ACRSSDA,ACRMAX=ACRMAX+1
 Q