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

RCBECHGI.m

Go to the documentation of this file.
  1. RCBECHGI ;WISC/RFJ-add interest charges to bill (called by rcbechgs) ;1 Jun 00
  1. ;;4.5;Accounts Receivable;**153**;Mar 20, 1995
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. Q
  1. ;
  1. ;
  1. INTEREST ; this is called by rcbechgs and is a continuation of that routine
  1. ; variables passed to this entry point:
  1. ; rcdata0 = the 0th node for the debtor in file 340
  1. ; rcupdate = the fm date that charges are being added
  1. ; the rcupdate variable is the statement date for non-benefit
  1. ; debts or (statement date minus 3 days) for benefit (first
  1. ; party debts)
  1. ;
  1. N DAYSINT,FROMDATE,RCBILLDA,RCDATA6,RCDATE,RCLASTDT
  1. ;
  1. S RCDATE=0 F S RCDATE=$O(^TMP("RCBECHGS",$J,"LIST",RCDATE)) Q:'RCDATE D
  1. . S RCBILLDA=0 F S RCBILLDA=$O(^TMP("RCBECHGS",$J,"LIST",RCDATE,RCBILLDA)) Q:'RCBILLDA D
  1. . . ; bill category is set up to not charge interest
  1. . . I '$P($G(^PRCA(430.2,+$P(^PRCA(430,RCBILLDA,0),"^",2),0)),"^",10) Q
  1. . . S RCDATA6=$G(^PRCA(430,RCBILLDA,6))
  1. . . ; get the last date interest was charged to this bill
  1. . . ; if the last date is not set in field .11, use field 67
  1. . . S RCLASTDT=$P($G(^PRCA(430,RCBILLDA,.1)),"^") I 'RCLASTDT S RCLASTDT=$P(RCDATA6,"^",7)
  1. . . ; take the current statement date in variable rcupdate
  1. . . ; (this is actually 3 days before the statement date for
  1. . . ; benefit first party debts and is when interest charges
  1. . . ; get added) and subtract 1 month (this date will be the
  1. . . ; last statement date). If the last interest charge date
  1. . . ; is greater than the last statement date, do not add
  1. . . ; interest a second time for the same month.
  1. . . I RCLASTDT>$$FPS^RCAMFN01(RCUPDATE,-1) Q
  1. . . ;
  1. . . ; *** for benefit debts (first party) notified by CCPC ***
  1. . . ; *** interest assessed unless payment is received within ***
  1. . . ; *** the first 57 days after initial notification. after ***
  1. . . ; *** initial charge, interest is assessed every 30 days ***
  1. . . ; *** letter 1 = initial notification ***
  1. . . ; *** letter 2 = 30 days from initial notification ***
  1. . . ; *** letter 3 = 60 days from initial notification ***
  1. . . ; if it is a first party bill (file 340 data node 0)
  1. . . I $P(RCDATA0,"^")["DPT(" D Q
  1. . . . ; if the letter3 date is not set and there is interest
  1. . . . ; balance, then this bill has had interest charged for
  1. . . . ; 57 days do not charge interest until after letter3 sent
  1. . . . I '$P(RCDATA6,"^",3),$P($G(^PRCA(430,RCBILLDA,7)),"^",2)>0 Q
  1. . . . ; calculate the days of interest. if the 2nd letter sent,
  1. . . . ; then days of interest is 57. if the 3rd letter sent,
  1. . . . ; then days of interest is 30
  1. . . . S DAYSINT=0
  1. . . . I $P(RCDATA6,"^",2) S DAYSINT=57
  1. . . . I $P(RCDATA6,"^",3) S DAYSINT=30
  1. . . . ; calculate the interest
  1. . . . S $P(^TMP("RCBECHGS",$J,"ADDCHG",RCBILLDA),"^")=$$CALCINT(RCBILLDA,DAYSINT)
  1. . . ;
  1. . . ; *** for non-benefit debts (vendor,ex-employee,employee) ***
  1. . . ; *** interest is assessed unless payment is received with***
  1. . . ; *** in 30 days of initial notification ***
  1. . . ; has the initial notification been sent?
  1. . . I '$P(RCDATA6,"^",1) Q
  1. . . ; has it been 1 month since the initial notification?
  1. . . I RCUPDATE<$$FPS^RCAMFN01($P(RCDATA6,"^",1),1) Q
  1. . . ; calculate the number of days of interest from the last int
  1. . . ; charge date to the date the account is being updated
  1. . . ; (rcupdate). rcupdate is usually the current day (the
  1. . . ; statement date). if the last int charge is not defined,
  1. . . ; use the letter1 date.
  1. . . S FROMDATE=RCLASTDT I 'FROMDATE S FROMDATE=$P(RCDATA6,"^",1)
  1. . . S DAYSINT=$$FMDIFF^XLFDT(RCUPDATE,$P(FROMDATE,"."))
  1. . . I DAYSINT<1 Q
  1. . . ; calculate the interest
  1. . . S $P(^TMP("RCBECHGS",$J,"ADDCHG",RCBILLDA),"^")=$$CALCINT(RCBILLDA,DAYSINT)
  1. Q
  1. ;
  1. ;
  1. CALCINT(RCBILLDA,DAYSINT) ; calc the interest for a number of days (daysint)
  1. N DATEPREP,INTEREST,PRINCPAL
  1. ; get the date the bill was prepared
  1. S DATEPREP=$P($G(^PRCA(430,RCBILLDA,0)),"^",10) I 'DATEPREP Q 0
  1. ; get the principal balance
  1. S PRINCPAL=$P($G(^PRCA(430,RCBILLDA,7)),"^") I 'PRINCPAL Q 0
  1. ; the interest rate based on the date the bill is prepared (rcdate)
  1. ; divided by 360 days in the year equals the current daily rate.
  1. ; multiply by the number of days to charge interest and by the
  1. ; principal balance
  1. S INTEREST=+$J(+$$INT^RCMSFN01(DATEPREP)/360*DAYSINT*PRINCPAL,0,2)
  1. I 'INTEREST S INTEREST=""
  1. Q INTEREST