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

RCXFMST1.m

Go to the documentation of this file.
  1. RCXFMST1 ;ALB/TMK-EDI Lockbox fms transfer (tr) cd sht gen ;31 Mar 03
  1. ;;4.5;Accounts Receivable;**173,220,184,238**;Mar 20, 1995
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. Q
  1. ;
  1. ;
  1. GETTR(RCRECTDA,RCGECSDA) ; extract transfer data for TR code sheet for
  1. ; a receipt in rcrectda
  1. ; rcgecsda is the ien for the gcs stack file 2100.1 for rebuilds
  1. ;
  1. N TRANDA,AMOUNT,DETAIL,UNAPPLY,TOTAL,RCTOTAL,FUND,REVSRCE,VENDORID,RCSEQ,RESULT,GECSDATA,RCTRANS,UNAPPNUM,TRANNUMB
  1. ;
  1. ; extract all payments on receipt
  1. S RESULT=""
  1. K ^TMP($J,"RCFMSCR") ; used for 215 report, not used here
  1. D FMSLINES^RCXFMSC1(RCRECTDA,1)
  1. K ^TMP($J,"RCFMSCR")
  1. ;
  1. ; unapplied payments to accounts
  1. S TRANDA=0 F S TRANDA=$O(^RCY(344,RCRECTDA,1,TRANDA)) Q:'TRANDA D
  1. . ; dollars applied in AR
  1. . I $P(^RCY(344,RCRECTDA,1,TRANDA,0),U,5) Q
  1. . ; no dollars on transaction
  1. . S AMOUNT=$P(^RCY(344,RCRECTDA,1,TRANDA,0),U,4) I 'AMOUNT Q
  1. . ;
  1. . S UNAPPLY($$GETUNAPP^RCXFMSCR(RCRECTDA,TRANDA,1))=AMOUNT
  1. ;
  1. ; no code sheets to send
  1. I '$D(DETAIL),'$D(TOTAL),'$D(UNAPPLY) S RESULT="-1^No code sheets to send for this receipt" G QUIT
  1. ;
  1. ; get the next common number in the series = station "-" nextnumber
  1. ; use (field 200 in file 344) if document previously sent
  1. S TRANNUMB=$P($P($G(^RCY(344,RCRECTDA,2)),U),"-",2)
  1. I TRANNUMB="" S TRANNUMB=$$ENUM^RCMSNUM
  1. I TRANNUMB<0 S RESULT="0^Unable to lookup next transaction number" G QUIT
  1. ; remove the dash (i,e, 460-K1A05HY)
  1. S TRANNUMB=$TR(TRANNUMB,"-")
  1. ;
  1. ; extract transfer from/to array for applied payments
  1. S (RCTOTAL,RCSEQ)=0
  1. S FUND="" F S FUND=$O(TOTAL(FUND)) Q:FUND="" D
  1. . S REVSRCE="" F S REVSRCE=$O(TOTAL(FUND,REVSRCE)) Q:REVSRCE="" D
  1. . . S VENDORID="" F S VENDORID=$O(TOTAL(FUND,REVSRCE,VENDORID)) Q:VENDORID="" D
  1. . . . S RCSEQ=RCSEQ+1,RCTRANS($$TRFUND(),"8NZZ",RCSEQ)=FUND_U_REVSRCE_U_TOTAL(FUND,REVSRCE,VENDORID)_U_U_VENDORID
  1. ;
  1. ; extract unapplied payments
  1. S UNAPPNUM="" F S UNAPPNUM=$O(UNAPPLY(UNAPPNUM)) Q:UNAPPNUM="" D
  1. . S RCSEQ=RCSEQ+1,RCTRANS($$TRFUND(),"8NZZ",RCSEQ)=3875_U_U_UNAPPLY(UNAPPNUM)_U_UNAPPNUM
  1. ;
  1. ; build the TR document
  1. S RESULT=$$BUILDTR(.RCTRANS,.DETAIL,+$G(GECSDATA),TRANNUMB,RCRECTDA)
  1. ;
  1. QUIT Q RESULT
  1. ;
  1. BUILDTR(RCTRANS,RCDETAIL,RCGECSDA,TRANNUMB,RCRECTDA) ; generate a tr code
  1. ; sheet for transferring dollars out of 528704/8NZZ
  1. ;
  1. ; rctrans(fund,rsc,seq) = data array passed
  1. ; fund=fund to transfer from (always 528704)
  1. ; rsc = rsc to transfer from (always 8NZZ)
  1. ; seq = sequence to make record unique for each 'transferred to' rsc
  1. ; data = fund to transfer to (piece 1)
  1. ; rsc to transfer to (piece 2)
  1. ; dollars to transfer (piece 3)
  1. ; unapplied deposit # for suspense (fund to transfer to=3875)
  1. ; vendor id (piece 5)
  1. ;
  1. ; rcgecsda is the ien for the gcs stack file 2100.1 for rebuilds
  1. ;
  1. ; trannumb is the document identifier
  1. ;
  1. ; rcrectda is the ien of the receipt (file 344)
  1. ;
  1. ; rcdetail array contains accrual data for BD transactions
  1. ;
  1. N COUNT,DATA,DESCRIP,FISCALYR,FUND,GECSFMS,LINE,REVSRCE,TR2,X,Y,RCSUSP,BILLDA,FMSTYPE,AMOUNT,RCSEQ
  1. ;
  1. S FISCALYR=$$FY^RCFN01(DT)
  1. ;
  1. ; build detail lines
  1. S COUNT=0
  1. ;
  1. S FMSTYPE="" F S FMSTYPE=$O(RCDETAIL(FMSTYPE)) Q:FMSTYPE="" D
  1. . S BILLDA=0 F S BILLDA=$O(RCDETAIL(FMSTYPE,BILLDA)) Q:'BILLDA D
  1. . . S AMOUNT=RCDETAIL(FMSTYPE,BILLDA)
  1. . . ; Decrease from 528704/8NZZ
  1. . . S COUNT=COUNT+1
  1. . . S LINE(COUNT)=$$DEC(COUNT,FISCALYR,TRANNUMB,AMOUNT)
  1. . . ; Send BD
  1. . . S COUNT=COUNT+1
  1. . . S LINE(COUNT)="LIN^~CRA^"_$S($L(COUNT)=1:"00",$L(COUNT)=2:"0",1:"")_COUNT
  1. . . S $P(LINE(COUNT),U,20)=$J(AMOUNT,0,2)
  1. . . S $P(LINE(COUNT),U,21)="I"
  1. . . S $P(LINE(COUNT),U,23)=$S(FMSTYPE'=75:FMSTYPE,$$GETFUNDB^RCXFMSUF(BILLDA,1)["5287":33,1:75)
  1. . . S $P(LINE(COUNT),U,24)="BD"
  1. . . S $P(LINE(COUNT),U,25)=$TR($P(^PRCA(430,BILLDA,0),U),"-")
  1. . . S $P(LINE(COUNT),U,26)=$$LINE^RCXFMSC1(BILLDA)
  1. . . S $P(LINE(COUNT),U,27)="~"
  1. . ;
  1. ;
  1. S FUND=$$TRFUND(),REVSRCE="8NZZ"
  1. S RCSEQ=0 F S RCSEQ=$O(RCTRANS(FUND,REVSRCE,RCSEQ)) Q:'RCSEQ D
  1. . S DATA=RCTRANS(FUND,REVSRCE,RCSEQ)
  1. . ; if no value, quit
  1. . I '$P(DATA,U,3) Q
  1. . ;
  1. . ; create line to transfer from (decrease)
  1. . S COUNT=COUNT+1
  1. . S LINE(COUNT)=$$DEC(COUNT,FISCALYR,TRANNUMB,$P(DATA,U,3))
  1. . ;
  1. . ; create line to transfer to (increase)
  1. . S COUNT=COUNT+1
  1. . S RCSUSP=($P(DATA,U)=3875)
  1. . S LINE(COUNT)="LIN^~CRA^"_$S($L(COUNT)=1:"00",$L(COUNT)=2:"0",1:"")_COUNT
  1. . S $P(LINE(COUNT),U,4)=FISCALYR
  1. . S $P(LINE(COUNT),U,4)=$S($E(FUND,1,4)=5287:"05",1:FISCALYR)
  1. . S $P(LINE(COUNT),U,6)=$P(DATA,U)
  1. . S $P(LINE(COUNT),U,7)=$E(TRANNUMB,1,3) ; station #
  1. . I 'RCSUSP S $P(LINE(COUNT),U,10)=$P(DATA,U,2)
  1. . ;
  1. . ; vendor id
  1. . I 'RCSUSP S $P(LINE(COUNT),U,18)=$P(DATA,U,5)
  1. . ;
  1. . S $P(LINE(COUNT),U,20)=$J($P(DATA,U,3),0,2)
  1. . S $P(LINE(COUNT),U,21)="I"
  1. . S $P(LINE(COUNT),U,23)=$S('RCSUSP:33,1:24)
  1. . S $P(LINE(COUNT),U,24)=$S('RCSUSP:"~",1:"~CRB")
  1. . I RCSUSP D
  1. . . S $P(LINE(COUNT),U,32)=$P(DATA,U,4)
  1. . . S $P(LINE(COUNT),U,33)="~"
  1. ;
  1. ; build tr2
  1. N FMSDT S FMSDT=$$FMSDATE^RCBEUTRA(DT)
  1. S TR2="CR2^"_$E(FMSDT,2,3)_U_$E(FMSDT,4,5)_U_$E(FMSDT,6,7)_"^^^^^^E^^^"
  1. ; deposit number which is equal to the gcs id
  1. ; $j(0,0,2) is the document total which is zero
  1. S TR2=TR2_$P(TRANNUMB,U)_"^^"_$J(0,0,2)_"^^"
  1. ; deposit/transfer date
  1. S TR2=TR2_$E(DT,2,3)_U_$E(DT,4,5)_U_$E(DT,6,7)_"^~"
  1. ;
  1. ; put together document in gcs
  1. N D0,DA,DI,DIC,DIE,DIQ2,DQ,DR
  1. S DESCRIP="EDI Lockbox Detail Receipt: "_$P(^RCY(344,RCRECTDA,0),U)
  1. I 'RCGECSDA D CONTROL^GECSUFMS("A",$E(TRANNUMB,1,3),TRANNUMB,"TR",10,0,"",DESCRIP)
  1. I RCGECSDA D REBUILD^GECSUFM1(RCGECSDA,"A",10,"N","Rebuild "_DESCRIP) S GECSFMS("DA")=RCGECSDA
  1. ;
  1. ; store document in gcs
  1. D SETCS^GECSSTAA(GECSFMS("DA"),TR2)
  1. F COUNT=1:1 Q:'$D(LINE(COUNT)) D SETCS^GECSSTAA(GECSFMS("DA"),LINE(COUNT))
  1. D SETCODE^GECSSDCT(GECSFMS("DA"),"D RETN^RCFMFN02")
  1. D SETSTAT^GECSSTAA(GECSFMS("DA"),"Q")
  1. ;
  1. ; add/update entry in file 347 for unprocessed document report
  1. N %DT,%X,D,DA347,D0,DI,DQ,DIC,ERROR,FMSDOCNO,X
  1. S FMSDOCNO="TR-"_$P(GECSFMS("CTL"),U,9)
  1. S DA347=$O(^RC(347,"C",FMSDOCNO,0))
  1. ; if not in the file, addit fmsdocid tr id
  1. I 'DA347 D OPEN^RCFMDRV1(FMSDOCNO,9,"TR-"_$P($G(^RCY(344,RCRECTDA,0)),U),.DA347,.ERROR)
  1. I DA347 D SSTAT^RCFMFN02(FMSDOCNO,1)
  1. ;
  1. ; return 1 for success ^ fms document id
  1. Q 1_"^TR-"_$P(GECSFMS("CTL"),U,9)
  1. ;
  1. ;
  1. DEC(COUNT,FISCALYR,TRANNUMB,AMOUNT) ; Add decrease from 528704/8NZZ
  1. ; Returns LINE with decrease TR info
  1. ; FISCALYR/TRANNUMB from above
  1. ; COUNT = line counter
  1. ; AMOUNT = amount to be transferred
  1. ;
  1. S LINE="LIN^~CRA^"_$S($L(COUNT)=1:"00",$L(COUNT)=2:"0",1:"")_COUNT
  1. S $P(LINE,U,4)=FISCALYR
  1. S $P(LINE,U,6)=$$TRFUND()
  1. S $P(LINE,U,4)=$S($E($P(LINE,U,6),1,4)=5287:"05",1:FISCALYR)
  1. S $P(LINE,U,7)=$E(TRANNUMB,1,3) ; station #
  1. S $P(LINE,U,10)="8NZZ"
  1. ;
  1. ; vendor id
  1. S $P(LINE,U,18)="MCCFVALUE"
  1. S $P(LINE,U,20)=$J(AMOUNT,0,2)
  1. S $P(LINE,U,21)="D"
  1. S $P(LINE,U,23)=33
  1. S $P(LINE,U,24)="~"
  1. Q LINE
  1. ;
  1. TRFUND() ; Determine if fund should be 5287 or 528704, based on date
  1. I DT<3030926 Q 5287
  1. I DT<$$ADDPTEDT^PRCAACC() Q 5287.4
  1. Q 528704
  1. ;