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

RCDPXPAY.m

Go to the documentation of this file.
  1. RCDPXPAY ;WISC/RFJ-server top to receive electronic payments ;1 Jun 99
  1. ;;4.5;Accounts Receivable;**114,148,150,301**;Mar 20, 1995;Build 144
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. Q
  1. ;
  1. ;
  1. START ; start receiving message
  1. N RCDPCNTL,RCDPCSUM,RCDPDATA,RCDPDATE,RCDPFLAG,RCDPFSUM,RCDPLIDA,RCDPLINE,RCDPNEXT,RCDPSEQ,RCDPSITE,RCDPTOTL,RCDPXMZ,X,Y,RCBETYPE
  1. K ^TMP($J,"RCDPXPAY") S U="^"
  1. ;
  1. ; not a valid mail message
  1. I '$D(^XMB(3.9,XMZ,0)) Q
  1. ;
  1. S RCDPXMZ=XMZ
  1. ; find line 1 of data and make sure it is correctly formatted
  1. S RCDPLINE=.99 F S RCDPLINE=$O(^XMB(3.9,RCDPXMZ,2,RCDPLINE)) Q:'RCDPLINE S RCDPDATA=^(RCDPLINE,0) I $E(RCDPDATA,1,2)="RT" Q
  1. ; first 2 characters of line 1 must equal RT
  1. I $E($G(RCDPDATA),1,2)'="RT" D ERROR^RCDPXPAM("",RCDPXMZ,"RT expected (line 1, piece 1)"),COMPLETE Q
  1. ; check the station number
  1. S RCDPSITE=$$SITE^RCMSITE
  1. I $P(RCDPDATA,"^",4)'=RCDPSITE D ERROR^RCDPXPAM("",RCDPXMZ,"Wrong station number (line 1, piece 4), station number should be "_RCDPSITE),COMPLETE Q
  1. ; get the transmission date and convert it to a fileman date
  1. S RCDPDATE=$$CONVDATE($P(RCDPDATA,"^",8)) I RCDPDATE<0 D ERROR^RCDPXPAM("",RCDPXMZ,"Invalid transmission date (line 1, piece 8)"),COMPLETE Q
  1. ; get the sequence number
  1. S RCDPSEQ=+$P(RCDPDATA,"^",2) I 'RCDPSEQ D ERROR^RCDPXPAM("",RCDPXMZ,"Sequence number of the message is missing (line 1, piece 2)"),COMPLETE Q
  1. ;
  1. ; check for zero payments on message
  1. ; sequence=1 ,total sequence=1 ,no payments ,no dollars on RT ,no total dollars
  1. I +$P(RCDPDATA,"^",2)=1,+$P(RCDPDATA,"^",3)=1,'$P(RCDPDATA,"^",5),'$P(RCDPDATA,"^",6),'$P(RCDPDATA,"^",7) D ZEROMSG^RCDPXPAM($P(RCDPDATA,"^",8)) Q
  1. ;
  1. ; stay and wait for lock to clear
  1. L +^RCY(344.2,RCDPDATE)
  1. ;
  1. ; check for duplicate message, only store/process the first one
  1. ; still go and check to see if all messages have been received and can be processed
  1. I $D(^RCY(344.2,RCDPDATE,1,RCDPSEQ,0)) D DUPLCATE^RCDPXPAM(RCDPDATE,RCDPSEQ,RCDPXMZ),STARPROC Q
  1. ;
  1. ; add transmission date if not in file
  1. I '$$ADDTRAN^RCDPXPA1(RCDPDATE) D ERROR^RCDPXPAM("",RCDPXMZ,"Unable to add transmission to AR PAYMENT TRANSACTIONS file 344.2"),COMPLETE Q
  1. ; store total sequences and dollars if available for transmission
  1. D TRANDOLL^RCDPXPA1(RCDPDATE,+$P(RCDPDATA,"^",3),+$P(RCDPDATA,"^",7)/100)
  1. ;
  1. ; add the sequence to the transmission multiple
  1. S RCDPSEQ=$$ADDSEQ^RCDPXPA1(RCDPDATE,+$P(RCDPDATA,"^",2)) I 'RCDPSEQ D ERROR^RCDPXPAM(RCDPDATE,RCDPXMZ,"Unable to add the sequence number (line 1, piece 2)"),COMPLETE Q
  1. ; store number of transactions, total dollars for the sequence, mail message number
  1. D SEQUDOLL^RCDPXPA1(RCDPDATE,RCDPSEQ,+$P(RCDPDATA,"^",5),+$P(RCDPDATA,"^",6)/100,RCDPXMZ)
  1. ;
  1. ; once the sequence has been added, future errors must pass the
  1. ; variable rcdpdate to the label error to set the status to error
  1. ; and prevent further processing later on.
  1. ;
  1. ; store control header line 1 for comparing count and dollars of transactions
  1. S RCDPCNTL=RCDPDATA
  1. ;
  1. ; loop transactions and store the data
  1. S RCDPCSUM=0 ;used to compute checksum for sequence
  1. S RCDPLIDA=0 ;used to count entries stored in the data wp field
  1. S RCDPTOTL=0 ;used to total all payments (transactions)
  1. TXSET F S RCDPLINE=$O(^XMB(3.9,RCDPXMZ,2,RCDPLINE)) Q:'RCDPLINE D
  1. . S RCDPDATA=^XMB(3.9,RCDPXMZ,2,RCDPLINE,0)
  1. . I RCDPDATA=""!($E(RCDPDATA,1,4)="NNNN") Q
  1. . ; convert deposit date to fm
  1. . S $P(RCDPDATA,"^",7)=$$CONVDATE($P(RCDPDATA,"^",7))
  1. . I $P(RCDPDATA,"^",7)<0 S $P(RCDPDATA,"^",7)=0
  1. . ; check for errors
  1. . I $E(RCDPDATA,1,2)'="RD" S ^TMP($J,"RCDPXPAY","ERROR",RCDPLINE)="RD expected (line "_RCDPLINE_", piece 1)"
  1. . I '$P(RCDPDATA,"^",3) S ^TMP($J,"RCDPXPAY","ERROR",RCDPLINE)="No payment amount (line "_RCDPLINE_", piece 3)"
  1. . I $P(RCDPDATA,"^",6)="" S ^TMP($J,"RCDPXPAY","ERROR",RCDPLINE)="Deposit/215 number missing (line "_RCDPLINE_", piece 6)"
  1. . I '$P(RCDPDATA,"^",7) S ^TMP($J,"RCDPXPAY","ERROR",RCDPLINE)="Deposit date missing/invalid format (line "_RCDPLINE_", piece 7)"
  1. . ; add up dollars
  1. . S RCDPTOTL=RCDPTOTL+($P(RCDPDATA,"^",3)/100)
  1. . ; remove RT, remove station number from account (based on site length)
  1. . ; since the station number is variable 3 to 5 characters
  1. . S RCDPDATA=$P(RCDPDATA,"^",2,99),RCDPDATA=$E(RCDPDATA,$L(RCDPSITE)+1,99999),$P(RCDPDATA,"^",9)=$E($P(RCDPDATA,"^",5),1,3) ;PRCA*4.5*301
  1. . ; store the data
  1. . S RCDPLIDA=RCDPLIDA+1
  1. . S ^RCY(344.2,RCDPDATE,1,RCDPSEQ,1,RCDPLIDA,0)=RCDPDATA
  1. . ; compute checksum
  1. . S X=RCDPCSUM_RCDPDATA X $S($G(^%ZOSF("LPC"))'="":^("LPC"),1:"S Y=""""") S RCDPCSUM=Y
  1. ;
  1. ; store 0th node with count of lines and date
  1. S ^RCY(344.2,RCDPDATE,1,RCDPSEQ,1,0)="^^"_RCDPLIDA_"^"_RCDPLIDA_"^"_DT_"^"
  1. ; store the checksum for sequence
  1. D TRANCSUM^RCDPXPA1(RCDPDATE,RCDPSEQ,RCDPCSUM)
  1. ;
  1. ; check number of transactions for sequence
  1. I $P(RCDPCNTL,"^",5)'=RCDPLIDA D ERROR^RCDPXPAM(RCDPDATE,RCDPXMZ,"Expected number of transactions not equal actual number (line 1, piece 5)"),COMPLETE Q
  1. ; check total dollars for sequence
  1. I ($P(RCDPCNTL,"^",6)/100)'=RCDPTOTL D ERROR^RCDPXPAM(RCDPDATE,RCDPXMZ,"Expected dollars of transactions not equal actual dollars (line 1, piece 6)"),COMPLETE Q
  1. ;
  1. ; if errors on rd lines, stop process
  1. I $O(^TMP($J,"RCDPXPAY","ERROR",0)) D ERROR^RCDPXPAM(RCDPDATE,RCDPXMZ,""),COMPLETE Q
  1. ;
  1. STARPROC ; start processing
  1. ; check to see if all messages (sequences) have been received
  1. S RCDPFLAG=1
  1. S RCDPDATA=^RCY(344.2,RCDPDATE,0) I $P(RCDPDATA,"^",2) D
  1. . S RCDPFLAG=0
  1. . F RCDPSEQ=1:1:$P(RCDPDATA,"^",2) I '$D(^RCY(344.2,RCDPDATE,1,RCDPSEQ)) S RCDPFLAG=1 Q
  1. ; not all sequences received yet
  1. I $G(RCDPFLAG) D COMPLETE Q
  1. ;
  1. ; ***** all sequences received, start processing *****
  1. ; if status is error, quit and wait for tomorrow to send retransmission
  1. ; message to mail group
  1. I $P(^RCY(344.2,RCDPDATE,0),"^",4)="e" D COMPLETE Q
  1. ; already processing/processed the payments
  1. I $P(^RCY(344.2,RCDPDATE,0),"^",4)="p" D COMPLETE Q
  1. ;
  1. ; set status to processing
  1. D TRANSTAT^RCDPXPA1(RCDPDATE,"p")
  1. S RCDPTOTL=0
  1. S RCDPNEXT=0 ;used for making tmp global entry unique
  1. SETTMP F RCDPSEQ=1:1 Q:'$D(^RCY(344.2,RCDPDATE,1,RCDPSEQ)) D
  1. . S RCDPCSUM=0
  1. . S RCDPTOTL=RCDPTOTL+$P(^RCY(344.2,RCDPDATE,1,RCDPSEQ,0),"^",3)
  1. . F RCDPLIDA=1:1 Q:'$D(^RCY(344.2,RCDPDATE,1,RCDPSEQ,1,RCDPLIDA,0)) D
  1. . . S RCDPDATA=^RCY(344.2,RCDPDATE,1,RCDPSEQ,1,RCDPLIDA,0)
  1. . . ; compute checksum
  1. . . S X=RCDPCSUM_RCDPDATA X $S($G(^%ZOSF("LPC"))'="":^("LPC"),1:"S Y=""""") S RCDPCSUM=Y
  1. . . ; store transaction for processing
  1. . . ; the deposit number and date should not be null unless the
  1. . . ; data was modified after receipt
  1. . . I $P(RCDPDATA,"^",5)="" S $P(RCDPDATA,"^",5)=" " ; deposit number
  1. . . S RCDPNEXT=RCDPNEXT+1,^TMP($J,"RCDPXPAY","DEPOSIT",$P(RCDPDATA,"^",5),RCDPNEXT)=$P(RCDPDATA,"^",1,4)_"^"_$P(RCDPDATA,"^",7,99)
  1. . . ; save original data for posting & suspense considerations PRCA*4.5*301 BB
  1. . . ; store deposit date for deposit if it is needed
  1. . . I $P(RCDPDATA,"^",6),'$G(^TMP($J,"RCDPXPAY","DEPDATE",$P(RCDPDATA,"^",5))) S ^TMP($J,"RCDPXPAY","DEPDATE",$P(RCDPDATA,"^",5))=$P(RCDPDATA,"^",6)
  1. . ; verify checksum
  1. . I $P(^RCY(344.2,RCDPDATE,1,RCDPSEQ,0),"^",5)'=RCDPCSUM S RCDPFSUM=1
  1. ;
  1. ; verify totals for all sequences
  1. I $P(^RCY(344.2,RCDPDATE,0),"^",3)'=RCDPTOTL D ERROR^RCDPXPAM(RCDPDATE,RCDPXMZ,"The total dollars for all sequences do not balance with expected total"),COMPLETE Q
  1. ; checksum error
  1. I $G(RCDPFSUM) D ERROR^RCDPXPAM(RCDPDATE,RCDPXMZ,"The deposit information has been altered before processing occured"),COMPLETE Q
  1. ;
  1. ; everything checks out, start processing
  1. ; modify the lockbox lookup for accepting payment from other systems
  1. D PROCESS^RCDPXPAP(RCDPDATE,$O(^RC(341.1,"B","LOCKBOX",0)))
  1. ;
  1. COMPLETE ; complete the process
  1. ; check for errors in the transmission file for prior dates
  1. ; if they exist, mail a message to the users asking for retrans
  1. ; remove the entries
  1. N DATA,DEPDATE,DEPOSIT,RCDPDA
  1. S RCDPDA=DT F S RCDPDA=$O(^RCY(344.2,RCDPDA),-1) Q:'RCDPDA D
  1. . ; if the status was last updated today, do not modify
  1. . I $P(^RCY(344.2,RCDPDA,0),"^",5)=DT Q
  1. . ; try and find deposit number and deposit date
  1. . S (DEPOSIT,DEPDATE)="",RCDPFLAG=0
  1. . F RCDPSEQ=1:1 Q:'$D(^RCY(344.2,RCDPDA,1,RCDPSEQ)) D Q:RCDPFLAG
  1. . . F RCDPLIDA=1:1 Q:'$D(^RCY(344.2,RCDPDA,1,RCDPSEQ,1,RCDPLIDA,0)) D Q:RCDPFLAG
  1. . . . S DATA=$G(^RCY(344.2,RCDPDA,1,RCDPSEQ,1,RCDPLIDA,0))
  1. . . . I $P(DATA,"^",5)'="" S DEPOSIT=$P(DATA,"^",5)
  1. . . . I $P(DATA,"^",6)'="" S DEPDATE=$P(DATA,"^",6)
  1. . . . I DEPOSIT'="",DEPDATE'="" S RCDPFLAG=1 ; used to stop for loops
  1. . ;
  1. . S ^TMP($J,"RCDPXPAY","RETRAN",RCDPDA)=DEPOSIT_"^"_DEPDATE_"^"_$P(^RCY(344.2,RCDPDA,0),"^",4)
  1. . ; remove the entry from the file so it will not appear later
  1. . D DELETRAN^RCDPXPA1(RCDPDA)
  1. ; if there are any, send a message asking for retransmission
  1. I $O(^TMP($J,"RCDPXPAY","RETRAN",0)) D RETRAN^RCDPXPAM
  1. ;
  1. ; clear the current transmission date lock, clear it here to prevent
  1. ; two processes from sending the retransmission request message
  1. I $G(RCDPDATE) L -^RCY(344.2,RCDPDATE)
  1. ;
  1. ; clean up
  1. K ^TMP($J,"RCDPXPAY")
  1. ;
  1. ; remove message from server basket
  1. N K,X,XMK,XMSER,Y
  1. S XMSER="S.RCDP AUTOMATIC PAYMENTS",XMZ=RCDPXMZ
  1. D REMSBMSG^XMA1C
  1. Q
  1. ;
  1. ;
  1. CONVDATE(DATE) ; convert date from mmddyyyy to fm date cyymmdd
  1. Q ($E(DATE,5,6)-17)_$E(DATE,7,8)_$E(DATE,1,2)_$E(DATE,3,4)