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

RCDPXFIX.m

Go to the documentation of this file.
  1. RCDPXFIX ;WISC/RFJ -fix duplicate deposits (! be careful using this !) ;22 Mar 02
  1. ;;4.5;Accounts Receivable;**177,306**;Mar 20, 1995;Build 3
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; this routine is used to back out a duplicate deposit that has
  1. ; been posted to first party bills. do not use this routine
  1. ; unless instructed to by software design and development or
  1. ; national verification and support.
  1. Q
  1. ;
  1. ;
  1. REVERSE(RCDPOSIT,RCTRANDT) ; back out deposit RCDPOSIT
  1. ; RCDPOSIT is the deposit number, example 269296
  1. ; RCTRANDT is the transmission date, example 3001113
  1. ;
  1. ;
  1. N %,RCBILLDA,RCDATA0,RCDPDT,RCFTEST,RCMESSAG,RCRCPT,RCTRAN1,RCTRANDA,X
  1. K ^TMP("RCDPXFIX",$J)
  1. ;
  1. ; this is used for internal testing
  1. ;S RCFTEST=0 ; NO, do not make updates to the database
  1. S RCFTEST=1 ; YES, make changes to the database
  1. ;
  1. ; **306 removing text that says "duplicate"
  1. ; set default message to send to user
  1. ;S RCMESSAG="Duplicate deposit "_RCDPOSIT_" with a transmission date of "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" was not found."
  1. S RCMESSAG="Deposit "_RCDPOSIT_" with a transmission date of "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" was not found."
  1. ;
  1. ; find deposit which was posted erroneously, if no date then it is not found
  1. S RCDPDT=$O(^RCY(344.1,"B",RCDPOSIT,0)) I 'RCDPDT D MAIL^RCDPXFIM(RCDPOSIT,RCTRANDT,RCMESSAG) Q
  1. ;
  1. ; find receipts for deposit
  1. S RCRCPT=0 F S RCRCPT=$O(^RCY(344,"AD",RCDPDT,RCRCPT)) Q:'RCRCPT D
  1. . S RCDATA0=$G(^RCY(344,RCRCPT,0))
  1. . ; check to see if the date opened is equal to the transmission date
  1. . I $P(RCDATA0,"^",3)'=RCTRANDT Q
  1. . ;
  1. . ; ** 306, removing "duplicate"
  1. . ; deposit already backed out (the *end date is set once backed out)
  1. . ;I $P(RCDATA0,"^",10) S RCMESSAG="Duplicate Deposit "_RCDPOSIT_" was previously backed out on "_$E($P(RCDATA0,"^",10),4,5)_"/"_$E($P(RCDATA0,"^",10),6,7)_"/"_$E($P(RCDATA0,"^",10),2,3)_"." Q
  1. . I $P(RCDATA0,"^",10) S RCMESSAG="Deposit "_RCDPOSIT_" was previously backed out on "_$E($P(RCDATA0,"^",10),4,5)_"/"_$E($P(RCDATA0,"^",10),6,7)_"/"_$E($P(RCDATA0,"^",10),2,3)_"." Q
  1. . ;
  1. . ; found deposit/receipt and it needs to be backed out
  1. . ;S RCMESSAG="Duplicate deposit "_RCDPOSIT_" with a transmission date of "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" has been removed."
  1. . S RCMESSAG="Deposit "_RCDPOSIT_" with a transmission date of "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" has been removed."
  1. . ;
  1. . ; loop payments made in transaction 433 file
  1. . S RCTRANDA=0 F S RCTRANDA=$O(^PRCA(433,"AF",$P(RCDATA0,"^"),RCTRANDA)) Q:'RCTRANDA D
  1. . . ; transaction is already marked incomplete
  1. . . I $P(^PRCA(433,RCTRANDA,0),"^",4)=1 Q
  1. . . ;
  1. . . ; lock the transaction
  1. . . L +^PRCA(433,RCTRANDA)
  1. . . ;
  1. . . ; get transaction data
  1. . . S RCTRAN1=$G(^PRCA(433,RCTRANDA,1))
  1. . . S RCBILLDA=$P(^PRCA(433,RCTRANDA,0),"^",2)
  1. . . ;
  1. . . ; lock the bill
  1. . . L +^PRCA(430,RCBILLDA)
  1. . . ;
  1. . . ;
  1. . . ; transaction type = payment in part (2) or
  1. . . ; transaction type = payment in full (34)
  1. . . I $P(RCTRAN1,"^",2)=2!($P(RCTRAN1,"^",2)=34) D PAYMENT(RCTRANDA,1)
  1. . . ;
  1. . . ;
  1. . . ; transaction type = prepayment [increase adjustment (1)]
  1. . . I $P(RCTRAN1,"^",2)=1 D PREPAY
  1. . . ;
  1. . . ; unlock the bill and transaction
  1. . . L -^PRCA(430,RCBILLDA)
  1. . . L -^PRCA(433,RCTRANDA)
  1. . ;
  1. . ; make changes to the payments on the receipt
  1. . D RECEIPT(RCDPOSIT,RCTRANDT,RCRCPT)
  1. . ;
  1. . ; set piece 10 in receipt to show patch as being installed
  1. . I RCFTEST D NOW^%DTC S $P(^RCY(344,RCRCPT,0),"^",10)=%
  1. ;
  1. D MAIL^RCDPXFIM(RCDPOSIT,RCTRANDT,RCMESSAG)
  1. ;
  1. K ^TMP("RCDPXFIX",$J)
  1. Q
  1. ;
  1. ;
  1. PAYMENT(RCTRANDA,RCFREPRT) ; mark payment transaction as incomplete and adjust bill
  1. ; pass rcfrept equal to 1 to build mailman report. since prepayment
  1. ; payments to other bills are already printed on report, pass a zero
  1. ; to stop the setting of the tmp global
  1. ;
  1. N %,DATA0,FYDA,PIECE,RCBILLDA,RCBILL7,RCCOMMNT,RCREPDA,RCTRAN3
  1. ; amount paid
  1. S RCTRAN3=$G(^PRCA(433,RCTRANDA,3))
  1. ; get the bill
  1. S RCBILLDA=$P($G(^PRCA(433,RCTRANDA,0)),"^",2)
  1. ;
  1. ; reset the 7 node on the bill
  1. S RCBILL7=$G(^PRCA(430,RCBILLDA,7))
  1. F PIECE=1:1:5 D
  1. . ; add the payment back to the bills balance
  1. . S $P(RCBILL7,"^",PIECE)=$P(RCBILL7,"^",PIECE)+$P(RCTRAN3,"^",PIECE)
  1. . ; subtract the payment made for the bill
  1. . S $P(RCBILL7,"^",PIECE+6)=$P(RCBILL7,"^",PIECE+6)-$P(RCTRAN3,"^",PIECE)
  1. . I RCFTEST S ^PRCA(430,RCBILLDA,7)=RCBILL7
  1. ;
  1. ; make sure the bill is active (16) if collected/closed (22)
  1. I $P(^PRCA(430,RCBILLDA,0),"^",8)=22 I RCFTEST S %=$$EDIT430^RCBEUBIL(RCBILLDA,"8////16;")
  1. ;
  1. ; reset the fiscal year multiple
  1. S FYDA=$O(^PRCA(430,RCBILLDA,2,999),-1)
  1. I $G(^PRCA(430,RCBILLDA,2,+FYDA,0))'="" I RCFTEST S $P(^PRCA(430,RCBILLDA,2,FYDA,0),"^",2)=$P(RCBILL7,"^")
  1. ;
  1. ; remove repayment plans
  1. S RCREPDA=0 F S RCREPDA=$O(^PRCA(430,RCBILLDA,5,RCREPDA)) Q:'RCREPDA D
  1. . S DATA0=$G(^PRCA(430,RCBILLDA,5,RCREPDA,0))
  1. . I $P(DATA0,"^",4)'=RCTRANDA Q
  1. . ; found one, remove it
  1. . I RCFTEST S ^PRCA(430,RCBILLDA,5,RCREPDA,0)=$P(DATA0,"^")_"^0"
  1. ;
  1. ; set the payment transaction to incomplete
  1. I RCFTEST S $P(^PRCA(433,RCTRANDA,0),"^",4)=1
  1. ;
  1. ; **306, removing "dupicate"
  1. ; add comment to transaction
  1. ;S RCCOMMNT(1)="Duplicate deposit "_RCDPOSIT_" with transmission date "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" removed."
  1. S RCCOMMNT(1)="Deposit "_RCDPOSIT_" with transmission date "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" removed."
  1. I RCFTEST D ADDCOMM^RCBEUTRA(RCTRANDA,.RCCOMMNT)
  1. ;
  1. ; build mailman message
  1. I RCFREPRT S ^TMP("RCDPXFIX",$J,RCBILLDA,RCTRANDA)=""
  1. Q
  1. ;
  1. ;
  1. PREPAY ; fix a prepayment
  1. ; at entry point, rctranda is the increase adjustment to rcbillda
  1. ;
  1. N RCBILL7,RCDECADJ,RCPAYAMT,PAYTRAN
  1. S RCBILL7=$G(^PRCA(430,RCBILLDA,7))
  1. ;
  1. ; simple, prepayment has not been used against another bill:
  1. ; get rid of the increase adjustment
  1. I $P(RCBILL7,"^")'<$P($G(^PRCA(433,RCTRANDA,1)),"^",5) D PREPAYAD(RCTRANDA) Q
  1. ;
  1. ; prepayment has been used against other bills:
  1. ; get rid of the payments to other bills
  1. ; get rid of the decrease adjustments to prepayment bill
  1. ; get rid of the increase adjustment to prepayment bill
  1. S RCPAYAMT=$P($G(^PRCA(433,RCTRANDA,1)),"^",5)
  1. S RCDECADJ=RCTRANDA F S RCDECADJ=$O(^PRCA(433,"C",RCBILLDA,RCDECADJ)) Q:'RCDECADJ D I 'RCPAYAMT Q
  1. . ; not a decrease adjustment
  1. . I $P($G(^PRCA(433,RCDECADJ,1)),"^",2)'=35 Q
  1. . ;
  1. . ; lock the decrease adjustment
  1. . L +^PRCA(433,RCDECADJ)
  1. . ;
  1. . ; get the payment transaction (433) that goes with decrease
  1. . ; to prepayment bill
  1. . S PAYTRAN=$P($G(^PRCA(433,RCDECADJ,5)),"^",1)
  1. . ;
  1. . ; lock the payment transaction
  1. . L +^PRCA(433,PAYTRAN)
  1. . ;
  1. . ; get rid of the payment transaction, activate bill
  1. . ; pass a zero so it does not show on mailman report twice
  1. . I PAYTRAN D PAYMENT(PAYTRAN,0)
  1. . ;
  1. . ; get rid of decrease adjustment
  1. . D PREPAYAD(RCDECADJ)
  1. . ;
  1. . ; subtract the decrease adjustment from the payment amount
  1. . ; do this till it reaches zero
  1. . S RCPAYAMT=RCPAYAMT-$P($G(^PRCA(433,RCDECADJ,1)),"^",5)
  1. . ;
  1. . ; unlock
  1. . L -^PRCA(433,PAYTRAN)
  1. . L -^PRCA(433,RCDECADJ)
  1. ;
  1. ; get rid of the increase adjustment to the prepayment bill
  1. D PREPAYAD(RCTRANDA)
  1. Q
  1. ;
  1. ;
  1. PREPAYAD(RCTRANDA) ; get rid of a transaction on a prepayment bill
  1. N FYDA,RCBILL7,RCCOMMNT,RCTRAN1
  1. S RCTRAN1=$G(^PRCA(433,RCTRANDA,1))
  1. S RCBILL7=$G(^PRCA(430,RCBILLDA,7))
  1. ;
  1. ; reset the 7 node on the bill
  1. ; increase: subtract the payment from the bills principal balance
  1. I $P(RCTRAN1,"^",2)=1 S $P(RCBILL7,"^")=$P(RCBILL7,"^")-$P(RCTRAN1,"^",5)
  1. ; decrease: add the payment from the bills principal balance
  1. I $P(RCTRAN1,"^",2)=35 S $P(RCBILL7,"^")=$P(RCBILL7,"^")+$P(RCTRAN1,"^",5)
  1. I RCFTEST S ^PRCA(430,RCBILLDA,7)=RCBILL7
  1. ;
  1. ; reset the fiscal year multiple
  1. S FYDA=$O(^PRCA(430,RCBILLDA,2,999),-1)
  1. I $G(^PRCA(430,RCBILLDA,2,+FYDA,0))'="" I RCFTEST S $P(^PRCA(430,RCBILLDA,2,FYDA,0),"^",2)=$P(RCBILL7,"^")
  1. ;
  1. ; if the bills balance is zero, cancel it
  1. I '$P(RCBILL7,"^") I RCFTEST S %=$$EDIT430^RCBEUBIL(RCBILLDA,"8////39;")
  1. ;
  1. ; set the payment transaction to incomplete
  1. I RCFTEST S $P(^PRCA(433,RCTRANDA,0),"^",4)=1
  1. ;
  1. ; **306, removing "duplicate" to make more generic
  1. ; add comment to transaction
  1. ;S RCCOMMNT(1)="Duplicate deposit "_RCDPOSIT_" with transmission date "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" removed."
  1. S RCCOMMNT(1)="Deposit "_RCDPOSIT_" with transmission date "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" removed."
  1. I RCFTEST D ADDCOMM^RCBEUTRA(RCTRANDA,.RCCOMMNT)
  1. ;
  1. ; build for mailman report
  1. S ^TMP("RCDPXFIX",$J,RCBILLDA,RCTRANDA)=""
  1. Q
  1. ;
  1. ;
  1. RECEIPT(RCDPOSIT,RCTRANDT,RCRCPT) ; make changes to receipt file
  1. N RCACCT,RCBILLDA,RCDEBTDA,RCPAYDA
  1. S RCPAYDA=0 F S RCPAYDA=$O(^RCY(344,RCRCPT,1,RCPAYDA)) Q:'RCPAYDA D
  1. . ; add comment to payment in receipt file
  1. . ;**306, removing "duplicate"
  1. . ;I RCFTEST S $P(^RCY(344,RCRCPT,1,RCPAYDA,1),"^",2)="Duplicate deposit "_RCDPOSIT_" with transmission date "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" removed."
  1. . I RCFTEST S $P(^RCY(344,RCRCPT,1,RCPAYDA,1),"^",2)="Deposit "_RCDPOSIT_" with transmission date "_$E(RCTRANDT,4,5)_"/"_$E(RCTRANDT,6,7)_"/"_$E(RCTRANDT,2,3)_" removed."
  1. . ;
  1. . ; if the account is missing on the payment, then zero out the dollar amount
  1. . ; to prevent it from showing as an unlinked payment
  1. . S RCACCT=$P(^RCY(344,RCRCPT,1,RCPAYDA,0),"^",3)
  1. . I 'RCACCT S:RCFTEST $P(^RCY(344,RCRCPT,1,RCPAYDA,0),"^",4)=0 Q
  1. . ;
  1. . ; check acct to see if it has prepayments open with active bills. if so,
  1. . ; apply the prepayment to the active bill
  1. . S RCDEBTDA=$O(^RCD(340,"B",RCACCT,0)) I 'RCDEBTDA Q
  1. . ;
  1. . ; no prepayments for account
  1. . I '$O(^PRCA(430,"AS",RCDEBTDA,42,0)) Q
  1. . ;
  1. . ; no active bills for account
  1. . I '$O(^PRCA(430,"AS",RCDEBTDA,16,0)) Q
  1. . ;
  1. . ; loop active (16) bills for debtor and apply prepayment
  1. . S RCBILLDA=0 F S RCBILLDA=$O(^PRCA(430,"AS",RCDEBTDA,16,RCBILLDA)) Q:'RCBILLDA D
  1. . . ; no prepayments left, stop loop
  1. . . I '$O(^PRCA(430,"AS",RCDEBTDA,42,0)) S RCBILLDA="A" Q
  1. . . ;
  1. . . ; this line is for testing
  1. . . I 'RCFTEST W !,"Prepayment being applied to bill ",RCBILLDA Q
  1. . . D PREPAY^RCBEPAYP(RCBILLDA,0)
  1. Q