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

PRCPPOLB.m

Go to the documentation of this file.
PRCPPOLB ;WISC/RFJ-receive purchase order (build array)             ;06 Jan 94
 ;;5.1;IFCAP;;Oct 20, 2000
 ;Per VHA Directive 10-93-142, this routine should not be modified.
 Q
 ;
 ;
REBUILD ;  called here to rebuild array
 K PRCPDATA,^TMP($J,"PRCPPOLM"),^TMP($J,"PRCPPOLMREC")
 S (PRCPFLAG,PRCPFCOS)=0
 N %,AVGCOST,CONV,INVDATA,ITEMDA,LINE,LINEDA,PODATA,POQTY,POUI,QTYRECVE,TOTCOST,TRANDA,TRANDATA,TRUI,UNITCOST,X
 S TRANDA=+$P(^PRC(442,PRCPORDR,0),"^",12)
 S LINE=0
 S LINEDA=0 F  S LINEDA=$O(^PRC(442,PRCPORDR,2,LINEDA)) Q:'LINEDA  S PODATA=$G(^(LINEDA,0)) I PODATA'="" D
 .   S %=$O(^PRC(442,PRCPORDR,2,LINEDA,3,"AC",PRCPPART,0)) Q:'%
 .   S POQTY=+$P($G(^PRC(442,PRCPORDR,2,LINEDA,3,%,0)),"^",2) I 'POQTY Q
 .   S ITEMDA=+$P(PODATA,"^",5) I 'ITEMDA,$P(PODATA,"^",13)'="" S ITEMDA=+$O(^PRC(441,"BB",$P(PODATA,"^",13),0))
 .   S LINE=LINE+1
 .   D SET(LINEDA,LINE,1,80,IORVON,IORVOFF)
 .   D SET($$DESCR^PRCPUX1(PRCPINPT,ITEMDA),LINE,6,23)
 .   D SET($J(+ITEMDA,6),LINE,24,29)
 .   D SET($J(POQTY,8),LINE,30,37)
 .   ;
 .   ;  get outstanding transaction data
 .   I 'TRANDA S TRANDA=+$P(PODATA,"^",10)
 .   S TRANDATA=$G(^PRCP(445,PRCPINPT,1,ITEMDA,7,TRANDA,0)),TRUI=$$UNITVAL^PRCPUX1($P(TRANDATA,"^",4),$P(TRANDATA,"^",3),"/"),CONV=$P(TRANDATA,"^",5)
 .   ;  if there is not a due-in established, look up conversion factor
 .   ;  from procurement source multiple
 .   I 'CONV S CONV=$P($$GETVEN^PRCPUVEN(PRCPINPT,ITEMDA,+$P($G(^PRC(442,PRCPORDR,1)),"^")_";PRC(440,",0),"^",4)
 .   I 'CONV S CONV="?"
 .   S QTYRECVE=POQTY*$S('CONV:1,1:CONV)
 .   ;
 .   ;  get costs
 .   S TOTCOST=$J(POQTY*$P(PODATA,"^",9),0,2),UNITCOST=$J(TOTCOST/QTYRECVE,0,2)
 .   S INVDATA=$G(^PRCP(445,PRCPINPT,1,ITEMDA,0)),AVGCOST=$P(INVDATA,"^",22)
 .   D SET($J(CONV,5),LINE,38,42)
 .   D SET($J(QTYRECVE,8),LINE,43,50)
 .   D SET($J(AVGCOST,10,2),LINE,51,60)
 .   D SET($J(UNITCOST,10,2),LINE,61,70)
 .   D SET($J(TOTCOST,10,2),LINE,71,80)
 .   ;
 .   ;  cost to distribution point
 .   I '$D(^PRCP(445,PRCPINPT,1,ITEMDA,0)) D
 .   .   S X=$G(^TMP($J,"PRCPPOLMCOS",LINEDA))
 .   .   I X="" S ^TMP($J,"PRCPPOLMCOS",LINEDA)=ITEMDA
 .   .   S %=$$INVNAME^PRCPUX1($P(X,"^",2))
 .   .   I '$P(X,"^",2) S PRCPFCOS=1,%="<NONE>"
 .   .   S LINE=LINE+1
 .   .   I ITEMDA D SET("WARNING: ITEM NOT STORED IN INVENTORY POINT, COST TO: "_%,LINE,6,80)
 .   .   I 'ITEMDA D SET("WARNING: NO ITEM MASTER NUMBER, COST TO: "_%,LINE,6,80)
 .   ;
 .   ;  check for errors
 .   I $P($G(^PRCS(410,TRANDA,0)),"^",6)'=PRCPINPT S LINE=LINE+1,PRCPFLAG=1 D SET("ERROR: INVENTORY POINT NOT TIED TO 2237 ("_$P($G(PRCS(410,TRANDA,0)),"^")_")",LINE,6,80,IORVON,IORVOFF)
 .   I $D(^PRCP(445,PRCPINPT,1,ITEMDA,0)),TRANDATA="",QTYRECVE>0 S LINE=LINE+1,PRCPFLAG=1 D SET("ERROR: 2237 ("_$P($G(^PRCS(410,TRANDA,0)),"^")_") NOT ESTABLISHED AS A DUE-IN",LINE,6,80,IORVON,IORVOFF)
 .   S POUI=$$UNITVAL^PRCPUX1($P(PODATA,"^",12),$P(PODATA,"^",3),"/")
 .   I TRANDATA'="",POUI'=TRUI S LINE=LINE+1,PRCPFLAG=1 D SET("ERROR: PO U/I ("_POUI_") DOES NOT EQUAL DUE-IN U/R ("_TRUI_")",LINE,6,80,IORVON,IORVOFF)
 .   I $P(QTYRECVE,".",2) S LINE=LINE+1,PRCPFLAG=1 D SET("ERROR: RECEIVING QUANTITY CANNOT BE A FRACTION",LINE,6,80,IORVON,IORVOFF)
 .   I $D(^PRCP(445,PRCPINPT,1,ITEMDA,0)),'CONV S LINE=LINE+1,PRCPFLAG=1 D SET("ERROR: NO CONVERSION FACTOR.  EDIT THE DUE-IN OR VENDOR TO SET THE CF",LINE,6,80,IORVON,IORVOFF)
 .   I PRCPFLAG S VALMSG="FIX ERRORS BEFORE RECEIVING" Q
 .   S ^TMP($J,"PRCPPOLMREC",LINEDA)=ITEMDA_"^"_QTYRECVE_"^"_TOTCOST_"^"_TRANDA_"^"_POUI
 S VALMCNT=LINE
 Q
 ;
 ;
SET(STRING,LINE,COLUMN,CLREND,ON,OFF)      ;  set array
 I '$D(@VALMAR@(LINE,0)) D SET^VALM10(LINE,$J("",80))
 D SET^VALM10(LINE,$$SETSTR^VALM1(STRING,@VALMAR@(LINE,0),COLUMN,CLREND))
 I $G(ON)]""!($G(OFF)]"") D CNTRL^VALM10(LINE,COLUMN,$L(STRING),ON,OFF)
 Q