PRCAI16A ;WISC/RFJ-post init patch 169 continued ; 1 Apr 01 ;;4.5;Accounts Receivable;**169**;Mar 20, 1995 ;;Per VHA Directive 10-93-142, this routine should not be modified. Q ; ; START ; start post init (fix exempt transactions) ; break out the exempt transaction to interest and admin N RCDATE,RCTRANDA ; ; start finding exempt transactions and fixing them S RCDATE=9999999 F S RCDATE=$O(^PRCA(433,"AT",14,RCDATE),-1) Q:'RCDATE D . S RCTRANDA=999999999999999 . F S RCTRANDA=$O(^PRCA(433,"AT",14,RCDATE,RCTRANDA),-1) Q:'RCTRANDA D FIXEXEM(RCTRANDA) Q ; ; FIXEXEM(RCTRANDA) ; fix an exempt charge ; if transaction status not valid, quit I '$$VALID^RCRJRCOT(RCTRANDA) Q ; N ADMIN,BALANCE,CC,INTEREST,MF,RCBALANC,RCBILLDA,RCDATA7,RCLIST,TRANTOTL ; L +^PRCA(433,RCTRANDA) ; ; if node 2 already breaks out the int/admin, quit I $G(^PRCA(433,RCTRANDA,2))'="" L -^PRCA(433,RCTRANDA) Q ; S RCBILLDA=$P(^PRCA(433,RCTRANDA,0),"^",2) ; no bill on transaction I 'RCBILLDA L -^PRCA(433,RCTRANDA) Q ; ; lock the bill and get the current bill balance L +^PRCA(430,RCBILLDA) S RCBALANC=$$GETTRANS^RCDPBTLM(RCBILLDA) S TRANTOTL=$P(^PRCA(433,RCTRANDA,1),"^",5) I 'TRANTOTL D UNLOCK Q ; ; if the bill is in balance and the balance is zero, ; make the transaction all interest I $TR($P(RCBALANC,"^",2,5),"^0")="",$$OUTOFBAL^RCBDBBAL(RCBILLDA)="" S $P(^PRCA(433,RCTRANDA,2),"^",7)=TRANTOTL D UNLOCK Q ; ; if the interest balance is equal to the admin balance and ; the interest balance is zero, move to admin I $P(RCBALANC,"^",2)<0,-$P(RCBALANC,"^",2)=$P(RCBALANC,"^",3) D Q . S ADMIN=$P(RCBALANC,"^",3) I ADMIN>TRANTOTL S ADMIN=TRANTOTL . S INTEREST=TRANTOTL-ADMIN . S (MF,CC)=0 . D SET ; ; if the stored interest balance minus the calculated ; interest balance is equal to the transaction total ; of the exemption, then the exemption is ; for all admin. S RCDATA7=$P($G(^PRCA(430,RCBILLDA,7)),"^",1,5) I ($P(RCDATA7,"^",2)-$P(RCBALANC,"^",2))=TRANTOTL D Q . S (INTEREST,MF,CC)=0 . S ADMIN=TRANTOTL D SET ; ; calculate the bills balance up to the exempt transaction S BALANCE=$$CALCBAL(0,RCTRANDA-1) ; S (INTEREST,ADMIN,MF,CC)="" S INTEREST=$P(BALANCE,"^",2) I INTEREST<0 S INTEREST=0 I INTEREST'$E(RCDATE,1,7) S RCSTOP=1 Q . ; . S TRANDA="" F S TRANDA=$O(RCLIST(DATE,TRANDA)) Q:TRANDA="" D . . I TRANDA>RCTRANDA S RCSTOP=1 Q . . ; . . S PRINBAL=PRINBAL+$P(RCLIST(DATE,TRANDA),"^",2) . . S INTBAL=INTBAL+$P(RCLIST(DATE,TRANDA),"^",3) . . S ADMBAL=ADMBAL+$P(RCLIST(DATE,TRANDA),"^",4) . . S MFBAL=MFBAL+$P(RCLIST(DATE,TRANDA),"^",5) . . S CCBAL=CCBAL+$P(RCLIST(DATE,TRANDA),"^",6) ; Q PRINBAL_"^"_INTBAL_"^"_ADMBAL_"^"_MFBAL_"^"_CCBAL