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

PRCPSFIV.m

Go to the documentation of this file.
  1. PRCPSFIV ;WOIFO/RFJ,LKG-create fms iv issues code sheet ;4/27/05 14:08
  1. ;;5.1;IFCAP;**81**;Oct 20, 2000
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. Q
  1. ;
  1. ;
  1. IV(INVPT,TRANID,TRANNO,TRANDATE,STACKDA) ; create fms iv document
  1. ; tranid=transaction register id number; tranno=ib number (from 410)
  1. ; trandate=optional FMS acctg period, otherwise it uses the
  1. ; transaction date
  1. ; pass stackda for regeneration of document
  1. ; loop transaction register for posted items
  1. ; variables required:
  1. ; prcpwsta = whse station #; prcppsta = buyer station #
  1. ; prcpwfcp = whse fcp ; prcppfcp = buyer fcp
  1. ; prcpwbfy = whse beg fy ; prcppbfy = buyer beg fy
  1. N ACCT,BUYBFY,BUYEFY,BUYFUND,BUYJOB,BUYLINE,BUYTABLE,BUYXPROG,COSTCNTR,DATA,FMSLINE,GECSFMS,INVCOST,LINEDA,LINEDOC,PRCPDA,PRCPFMOD,PRCPFMS,PRCPSEC1,PROFIT,PROFLINE
  1. N SELBFY,SELEFY,SELFUND,SELLCOST,SELLINE,SELTABLE,SELXPROG,SIGN,SUBACCT,TOTAL,TRANDA,VOUCHER
  1. S PRCPDA=$O(^PRCS(410,"B",TRANNO,0)) I 'PRCPDA Q
  1. I $D(^PRCS(410,PRCPDA,"IT","FMSLINE")) S PRCPFMOD=1
  1. K PRCPFMS
  1. S (TRANDA,TOTAL)=0 F S TRANDA=$O(^PRCP(445.2,"T",INVPT,TRANID,TRANDA)) Q:'TRANDA S DATA=$G(^PRCP(445.2,TRANDA,0)) I DATA'="" D
  1. . S LINEDA=+$P(DATA,"^",24) I 'LINEDA Q
  1. . I 'TRANDATE S TRANDATE=$P(DATA,"^",3)
  1. . D FINDLINE^PRCPSFU0(PRCPDA,LINEDA)
  1. . ; invcost and sellcost is minus when coming out of the whse
  1. . ; inventory point. fms is positive when coming out of the whse.
  1. . S INVCOST=-$P(DATA,"^",22),SELLCOST=-$P(DATA,"^",23)
  1. . S PROFIT=SELLCOST-INVCOST
  1. . ; total is total of unsigned amounts on all lines
  1. . S TOTAL=TOTAL+SELLCOST
  1. . I '$D(PRCPFMS(FMSLINE)) S PRCPFMS(FMSLINE)=ACCT_"^"_SUBACCT
  1. . S $P(PRCPFMS(FMSLINE),"^",3)=$P(PRCPFMS(FMSLINE),"^",3)+INVCOST
  1. . S $P(PRCPFMS(FMSLINE),"^",4)=$P(PRCPFMS(FMSLINE),"^",4)+PROFIT
  1. I '$D(PRCPFMS) Q
  1. IVCOTS ;Entry Point for building IV for COTS inventory transaction
  1. ; set up document variables
  1. S COSTCNTR=$P($G(^PRCS(410,PRCPDA,3)),"^",3),COSTCNTR=$S($D(^PRCD(420.1,+COSTCNTR,0)):$P(^(0),"^"),1:COSTCNTR)
  1. S VOUCHER=$P($G(^PRCS(410,PRCPDA,445)),"^") S VOUCHER=$E(VOUCHER_"00000",1,6)
  1. ; seller=whse
  1. ; table=^^xprogram(fcp/prj)^^linefund^beginfy^endfy^^^job
  1. S SELTABLE=$$ACC^PRC0C(PRCPWSTA,PRCPWFCP_"^"_$P(TRANNO,"-",2)_"^"_PRCPWBFY)
  1. S SELXPROG=$P(SELTABLE,"^",3),SELFUND=$P(SELTABLE,"^",5),SELBFY=$E($P(SELTABLE,"^",6),3,4),SELEFY=$E($P(SELTABLE,"^",7),3,4)
  1. I SELEFY=SELBFY S SELEFY=""
  1. ; buyer
  1. S BUYTABLE=$$ACC^PRC0C(PRCPPSTA,PRCPPFCP_"^"_$P(TRANNO,"-",2)_"^"_PRCPPBFY)
  1. S BUYXPROG=$P(BUYTABLE,"^",3),BUYFUND=$P(BUYTABLE,"^",5),BUYBFY=$E($P(BUYTABLE,"^",6),3,4),BUYEFY=$E($P(BUYTABLE,"^",7),3,4),BUYJOB=$P(BUYTABLE,"^",10)
  1. I BUYEFY=BUYBFY S BUYEFY=""
  1. ;
  1. ; build control segments in gcs
  1. S PRCPSEC1=$$SEC1^PRC0C(PRCPWSTA) S:PRCPSEC1="" PRCPSEC1=10
  1. I '$G(STACKDA) D CONTROL^GECSUFMS("I",PRCPWSTA,PRCPWSTA_VOUCHER,"IV",PRCPSEC1,+$G(PRCPFMOD),"Y","post issue book: "_TRANNO_" tranid: "_TRANID)
  1. I $G(STACKDA) D REBUILD^GECSUFM1(STACKDA,"I",PRCPSEC1,"Y","Rebuild post issue book: "_TRANNO_" tranid: "_TRANID) S GECSFMS("DA")=STACKDA
  1. D SETPARAM^GECSSDCT(GECSFMS("DA"),TRANID)
  1. ;
  1. ; build iv2 segment
  1. S LINEDOC="IV2^"_$E(TRANDATE,2,3)_"^"_$E(TRANDATE,4,5)_"^"_$E(TRANDATE,6,7)
  1. S $P(LINEDOC,"^",9)=$S($D(GECSFMS("BAT")):"M",1:"E")
  1. S $P(LINEDOC,"^",21)=$E($TR($P(TRANNO,"-",2,5),"-"),1,12)
  1. S $P(LINEDOC,"^",22)=$J($S(TOTAL<0:-TOTAL,1:TOTAL),0,2)
  1. D SETCS^GECSSTAA(GECSFMS("DA"),LINEDOC_"^~")
  1. ;
  1. ; build line documents
  1. S LINEDA=0 F S LINEDA=$O(PRCPFMS(LINEDA)) Q:'LINEDA S DATA=PRCPFMS(LINEDA) D
  1. . S ACCT=$P(DATA,"^"),SUBACCT=$P(DATA,"^",2),INVCOST=$P(DATA,"^",3),PROFIT=$P(DATA,"^",4)
  1. . S SIGN="I" I INVCOST<0 S INVCOST=-INVCOST,SIGN="D"
  1. . S SELLINE="LIN^~IVA^"_$E("000",$L(LINEDA)+1,3)_LINEDA_"^"_$J(INVCOST,0,2)_"^"_SIGN_"^^"_SELBFY_"^"_SELEFY_"^"_SELFUND_"^"_PRCPWSTA_"^^^^"_SELXPROG_"^^^^SFCS^^^0"_$S(ACCT=1:4,ACCT=2:6,ACCT=8:2,1:8)_"^^"
  1. . S BUYLINE="^"_BUYBFY_"^"_BUYEFY_"^"_BUYFUND_"^"_PRCPPSTA_"^^"_$E(COSTCNTR,1,4)_"00^"_$E(COSTCNTR,5,6)_"^"_BUYXPROG_"^"_SUBACCT_"^~"
  1. . S LINEDOC=SELLINE_BUYLINE_"IVB^01^~"
  1. . I INVCOST D SETCS^GECSSTAA(GECSFMS("DA"),LINEDOC)
  1. . I 'PROFIT Q
  1. . ; create profit line
  1. . S SIGN="I" I PROFIT<0 S PROFIT=-PROFIT,SIGN="D"
  1. . S PROFLINE=LINEDA+1
  1. . S SELLINE="LIN^~IVA^"_$E("000",$L(PROFLINE)+1,3)_PROFLINE_"^"_$J(PROFIT,0,2)_"^"_SIGN_"^^"_SELBFY_"^"_SELEFY_"^"_SELFUND_"^"_PRCPWSTA_"^^^^"_SELXPROG_"^^^^SFPR^^^0"_($S(ACCT=1:4,ACCT=2:6,ACCT=8:2,1:8)+1)_"^^"
  1. . S BUYLINE="^"_BUYBFY_"^"_BUYEFY_"^"_BUYFUND_"^"_PRCPPSTA_"^^"_$E(COSTCNTR,1,4)_"00^"_$E(COSTCNTR,5,6)_"^"_BUYXPROG_"^"_SUBACCT_"^~"
  1. . S LINEDOC=SELLINE_BUYLINE_"IVB^01^~"
  1. . D SETCS^GECSSTAA(GECSFMS("DA"),LINEDOC)
  1. ;
  1. D SETSTAT^GECSSTAA(GECSFMS("DA"),"Q")
  1. D EN^DDIOL("FMS IV "_$S($D(GECSFMS("BAT")):"MODIFICATION ",1:"")_PRCPWSTA_VOUCHER_" document automatically "_$S($G(STACKDA):"RE-",1:"")_"transmitted.","","!?4")
  1. Q