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

ACRFACH.m

Go to the documentation of this file.
ACRFACH ;IHS/OIRM/DSD/MRS,AEF - FORMAT ACH ADDENDUM  [ 07/21/2005  12:27 PM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**16,17**;MAY 15, 2001
 ;   NEW ROUTINE   ACR*2.1*16.06 IM15505
 ;
 ;This routine contains formatting specifications and creates the
 ;RMR Treasury ACH Addendum record.
 ;
 ;   INPUT:
 ;   ACRDOCDA = IEN OF DOCUMENT (NULL=NON-ARMS)
 ;   ACRDOC   = DOCUMENT OR PO NUMBER
 ;   ACRTERMS:
 ;   ACRTERMS = DAYS^AMT^RATE^INVOICE#^ACRIVT^ACRBTYP^ACRACH
 ;     ^ACRTCODE^ACRFINAL^ACRORIG^ACRPODT^ACRIVTOT^ACRPOBJ^ACRT
 ;    WHERE:
 ;    Piece 1  - DAYS     = NUMBER OF INTEREST DAYS OR Lost OR Discount
 ;    Piece 2  - AMT      = AMOUNT OF PENALTY OR DISCOUNT
 ;    Piece 3  - RATE     = RATE PENALTY/DISCOUNT CALCULATED
 ;    Piece 4  - INVOICE  = INVOICE NUMBER
 ;    Piece 5  - ACRIVT   = PAYMENT AMOUNT
 ;    Piece 6  - ACRBTYP  = VENDOR OR TRAVEL
 ;    Piece 7  - ACRACH   = CHECKS OR ECS BATCH
 ;    Piece 8  - ACRTCODE = TRANSACTION CODE
 ;    Piece 9  - ACRFINAL = FINAL PAYMENT CODE
 ;    Piece 10 - ACRORIG  = ORIGINAL OBLIGATED AMOUNT - RETURNED ONLY
 ;    Piece 11 - ACRPODT  = DATE OBLIGATED - RETURNED ONLY
 ;    Piece 12 - ACRINTOT = INVOICE AMOUNT FOR INT/DISC/LOST
 ;    Piece 13 - ACRPOBJ  = OBJECT CLASS CODE FOR PENALTY/DISCOUNT
 ;    Piece 14 - ACRT     = DISCOUNT LOST(-2)
 ;                           DISCOUNT TAKEN (>-1)
 ;                           INTEREST (-1)
 ;             
 ;   RETURNS - ACH ADDENDUM STRING THAT BEGINS WITH "RMR"
 ;             OR NULL IF BATCH IS FOR CHECKS
 ;    CAVEAT - STRING IS LIMITED TO 80 CHARACTERS
 ;             STRING CAN ONLY HAVE ONE "REF" SEGMENT
 ;
 ;                 RMR Structure (See User's Manual for more)
 ;   RMR: Remittance Advice Accounts Receivable Open Item Reference
 ;               Segment ID is NOT counted as a piece
 ; 01  128  RNQ: Reference Number Qualifier (IV,VV,CT,PO,RB..)
 ; 02  127   RN: Reference Number (INVOICE/CONTRACT/VOUCHER.. NUMBER)
 ;*03  482  PAC: Payment Action Code (AI, PP, PI)
 ; 04  782   MA: Monetary Amount (total of current payment)
 ; 05  777   TI: Total Invoice or Credit/Debit (total of original obl)
 ; 06  780  ADT: Amount of Discount Taken
 ;
 ;FORMAT - RMR*RNQ*RN*OPTIONAL*OPTIONAL\
 ;RMR*RNQ*RN*PAYMENT ACTION CODE*MONETARY AMOUNT**\ (6 PIECES ALLOWED)
 ; In addition, the 3 piece REF segment may be used
 ;REF*RNQ*RN*DESCRIPTION\                  (ONLY 3 PIECES ALLOWED)
 ;
 ;*THE THIRD PIECE VARIES AND CREATES THE NEED FOR MULTIPLE QUALIFIERS
 ;       SUBSEQUENT SEQMENTS WILL ALWAYS BEGIN WITH REF
 ;       EACH SEGMENT ALWAYS ENDS WITH \
 ;
 ;PAYMENT ACTION CODE - AI AMOUNT PAID INCLUSIVE OF DISCOUNT/ADJUSTMS
 ;                    - PP PARTIAL PAYMENT
 ;                    - PI PAY ITEM
 ;Examples of payments:
 ;   - IF THERE IS AN INVOICE NUMBER IT WILL ALWAYS BE PROVIDED
 ;   - IF NO INVOICE, PURCHASE ORDER OR DOCUMENT NUMBER WILL BE USED
 ;   - PO NUMBER WILL BE PROVIDED, IF ROOM
 ;   - CONTRACT NUMBER WILL ALSO BE PROVIDED, IF ROOM
 ;
 ; VENDOR(FINAL)- RMR*IV*IV NUMBER*PI*AMOUNT\REF*PO*PO#\
 ; VENDOR(PARTIAL)- RMR*IV*IV NUMBER*PP*AMOUNT*OBLIGATION\REF*PO*PO#\
 ; TRAVEL(FINAL)- RMR*VV*VOUCHER NUMBER*PI*AMOUNT\
 ; CONTRACT - RMR*IV*IV NUMBR*PI*AMOUNT\REF*CT*CONTRACT NUMBER*DESCRIPT\
 ; VENDOR WITH INTEREST PENALTY ***MUST HAVE RATE SEQMENT***
 ;      - RMR*IV*IV#*AI*1125*1100\REF*RB*12%*25.00 intX6 d\
 ; VENDOR WITH DISCOUNT
 ;      - RMR*IV*IV#*AI*1100*1125*25\REF*IV*IV#*Discount terms\
 ;
 ;
EN(ACRDOCDA,ACRDOC,ACRTERMS,ACRTCODE,ACRREF)     ;EP; CALLED BY ACRFIV13 ONLY
 N ACRX,ACRDOC0,ACRINV0,ACRGTA,ACRINT,ACRORIG,ACRNO
 N ACRDAYS,ACRRATE,ACRINV,ACRIVT,ACRDOCT,ACRTMP,ACRILEN,ACRTA
 S ACRX=""                            ;Default value
 S ACRACH=$P(ACRTERMS,U,7)            ;CHECKS OR ECS BATCH
 ;I "AB"'[ACRACH Q ACRX               ;ONLY WANT ECS BATCHES ACR*2.1*17.01 IM17097
 I "B"'[ACRACH Q ACRX                 ;ONLY WANT B ECS BATCHES ACR*2.1*17.01 IM17097
 S ACRBTYP=$P(ACRTERMS,U,6)           ;VENDOR OR TRAVEL
 I ACRBTYP="" Q ACRX
 D DATA
 I ACRT]"",ACRT=-1 D MDATA
 S ACRX="RMR*"
 I ACRBTYP="V" D VENDOR(.ACRX,ACRDOC,ACRINV,ACRFINAL,ACRORIG,ACRIVT,ACRILEN)
 I ACRBTYP="T" D
 .D TRAVEL(.ACRX,ACRDOC,$$DOL^ACRFUTL(ACRIVT-ACRTA),ACRFINAL,ACRORIG,ACRILEN)
 I ACRT=-1 D
 .D INTEREST(.ACRX,ACRRATE,ACRIVT,ACRINT,ACRDAYS,ACRILEN)
 I ACRT]"",ACRT>-1 D  Q ACRX
 .D DISCOUNT(.ACRX,ACRRATE,ACRIVT,ACRINT,ACRDOC,ACRILEN)
 I ACRBTYP'="T" D
 .D PO(.ACRX,ACRDOC)
 .D CONTRACT(.ACRX,ACRCTN,ACRGTA)
 Q ACRX
 ;
INTEREST(ACRX,ACRRATE,ACRIVT,ACRINT,ACRDAYS,ACRILEN) ;CHECK FOR INTEREST PENALTY
 ;      - RMR*IV*IV#*AI*1125.00*1100.00\REF*RB*12%*25.00 intX6 d\
 Q:ACRRATE=""
 S $P(ACRX,"*",4)="AI"
 S $P(ACRX,"*",5)=$$DOL^ACRFUTL(ACRIVT+ACRINT)  ;ADD INTEREST TO INV TOT
 S $P(ACRX,"*",6)=ACRIVT_"\"     ;ORIGINAL INVOICE TOTAL
 S ACRTMP="REF*RB*"_ACRRATE_"%*"_ACRINT_" INT@"_ACRDAYS_" DA\"
 I ACRILEN>1,$L(ACRX_ACRTMP)>80 D
 .F  S ACRNO=$P(ACRX,"*",3) Q:$L(ACRX_ACRTMP)'>80!(ACRNO="")  D
 ..S $P(ACRX,"*",3)=$P(ACRNO,",",1,$L(ACRNO,",")-1)
 Q:$L(ACRX_ACRTMP)>80             ;CAN'T ADD, TOO LONG
 S ACRX=ACRX_ACRTMP
 Q
 ;
DISCOUNT(ACRX,ACRRATE,ACRIVT,ACRINT,ACRDOC,ACRILEN)     ;LOCAL ENTRY
 S $P(ACRX,"*",4)="AI"
 S $P(ACRX,"*",5)=$$DOL^ACRFUTL(ACRIVT)         ;DISCOUNTED AMOUNT
 S $P(ACRX,"*",6)=$$DOL^ACRFUTL(ACRIVT+ACRINT)  ;ORIGINAL INVOICE AMOUNT
 S $P(ACRX,"*",7)=ACRINT_"\"                    ;DISCOUNT AMOUNT
 S ACRTMP="REF*PO*"_ACRDOC
 I ACRRATE]"" D
 .S ACRTMP=ACRTMP_"*DIS "_+ACRDAYS_"DA@"_ACRRATE_"%" ;ONLY ADD IF %
 I ACRRATE="" D
 .S ACRTMP=ACRTMP_"*DIS $$"                     ;SHOW IF DOLLAR AMT 
 S ACRTMP=ACRTMP_"\"
 I ACRILEN>1,$L(ACRX_ACRTMP)>80 D
 .F  S ACRNO=$P(ACRX,"*",3) Q:$L(ACRX_ACRTMP)'>80!(ACRNO="")  D
 ..S $P(ACRX,"*",3)=$P(ACRNO,",",1,$L(ACRNO,",")-1)
 Q:$L(ACRX_ACRTMP)>80                           ;CAN'T APPEND, TOO LONG
 S ACRX=ACRX_ACRTMP
 D CONTRACT(.ACRX,ACRCTN,ACRGTA)
 Q
 ;
VENDOR(ACRX,ACRDOC,ACRINV,ACRFINAL,ACRORIG,ACRIVT,ACRILEN) ; LOCAL ENTRY ONLY
 ;SET ACRX STRING FOR VENDOR WITH IV OR PO NUMBER
 N ACRQ
 S ACRQ="PO*",ACRNO=ACRDOC
 I ACRINV]"" D
 .;S ACRQ="IV*" I ACRDOC["TO" S ACRQ="VV*"      ;VENDOR PAID AGAINST A TV
 .S ACRQ="IV*" I $E(ACRDOC,5,6)="TO"!($E(ACRDOC,5,6)="T0") S ACRQ="VV*" ;VENDOR PAID AGAINST TV; ACR*2.1*17.06 IM17204
 .S ACRNO=ACRINV
 S ACRX=ACRX_ACRQ_ACRNO_"*PI*"_ACRIVT_"\"
 ;ADD ORIG OBLIG AMT IF NOT PROCESSED AS FINAL
 I ACRFINAL'=1 D
 .S ACRTMP=""
 .S:ACRORIG]"" ACRTMP="*"_ACRORIG
 .S $P(ACRX,"*",4,6)="PP*"_ACRIVT_ACRTMP_"\"
 I ACRILEN>1,$L(ACRX)>80 D
 .F  S ACRNO=$P(ACRX,"*",3) Q:$L(ACRX)'>80!(ACRNO="")  D
 ..S $P(ACRX,"*",3)=$P(ACRNO,",",1,$L(ACRNO,",")-1)
 Q
 ;
TRAVEL(ACRX,ACRDOC,ACRIVT,ACRFINAL,ACRORIG,ACRILEN) ;LOCAL ENTRY ONLY
 ;SET STRING FOR TRAVEL VOUCHER NUMBER
 S ACRX=ACRX_"VV*"_ACRDOC_"*PI*"_ACRIVT_"\"
 I ACRILEN>1,$L(ACRX)>80 D
 .F  S ACRNO=$P(ACRX,"*",3) Q:$L(ACRX)'>80!(ACRNO="")  D
 ..S $P(ACRX,"*",3)=$P(ACRNO,",",1,$L(ACRNO,",")-1)
 Q
 ;
PO(ACRX,ACRDOC) ;Add purchase order number if not already used, if room
 Q:ACRX["REF"              ;ONLY 1 "REF" SEGMENT ALLOWED ;ACR*2.1*17.06 IM17204
 Q:ACRDOC=""
 Q:ACRX["PO"
 Q:ACRX[ACRDOC
 S ACRTMP="REF*PO*"_ACRDOC_"\"
 Q:$L(ACRX_ACRTMP)>80
 S ACRX=ACRX_ACRTMP
 Q
 ;
CONTRACT(ACRX,ACRCTN,ACRGTA) ; Check for contract number and add if room
 Q:ACRX["REF"         ;ONLY 1 "REF" SEGMENT ALLOWED     ;ACR*2.1*17.06 IM17204
 Q:ACRCTN=""&(ACRGTA="")
 Q:ACRX[ACRCTN!(ACRX[ACRGTA)
 I ACRGTA]"" D  Q
 .S ACRTMP="REF*CT*"_ACRGTA_"*Government Travel Account\"
 I ACRCTN]"" S ACRTMP="REF*CT*"_ACRCTN_"\"
 Q:$L(ACRX_ACRTMP)>80
 S ACRX=ACRX_ACRTMP
 Q
 ;
DATA ;LOCAL ENTRY - SET VARIABLES
 S ACRDOCT=+$G(ACRDOCDA)                      ; NULL VALUE = NON-ARMS
 S ACRDOC0=$G(^ACRDOC(ACRDOCT,0))
 S ACRTMP=$G(^ACRDOC(ACRDOCT,"PO"))
 S ACRPODT=$P(ACRTMP,U)                          ; DATE OBLIGATED
 S ACRCTN=$P(ACRTMP,U,2)                         ; CONTRACT NUMBER
 S ACRSTAT=$P($G(^ACROBL(ACRDOCT,"APV")),U,6)    ; PAYMENT STATUS
 S ACRORIG=$P($G(^ACROBL(ACRDOCT,"DT")),U,4)     ; ORIGINAL OBLIGATION
 S:ACRORIG]"" ACRORIG=$$DOL^ACRFUTL(ACRORIG)
 S ACRGTA=""                                     ; GOVERNMENT TRAVEL
 S ACRT=$P(ACRTERMS,U,14)           ;INTEREST/DISCOUNT FLAG
 I ACRREF=618 S ACRGTA=$P($G(^ACRSYS(1,"DT1")),U,14)
 S ACRDAYS=$P(ACRTERMS,U)           ;NUMBER OF DAYS W/FLAGS  
 S ACRINT=$P(ACRTERMS,U,2)          ;INTEREST/DISCOUNT AMOUNT
 S ACRRATE=$P(ACRTERMS,U,3)         ;INTEREST/DISCOUNT RATE
 S ACRINV=$P(ACRTERMS,U,4)          ;INVOICE NUMBER
 S ACRIVT=$P(ACRTERMS,U,5)          ;INVOICE AMOUNT
 S ACRIVT=$$DOL^ACRFUTL(ACRIVT)
 S ACRFINAL=$P(ACRTERMS,U,9)        ;PAYMENT STATUS; 1=FINAL; 2=PARTIAL
 S $P(ACRTERMS,U,10)=ACRORIG        ;ADD ORIG AMOUNT
 S $P(ACRTERMS,U,11)=ACRPODT        ;ADD DATE OBLIGATED
 S ACRILEN=$L(ACRINV,",")           ;COUNT OF POSSIBLE GROUPED INVOICES
 I ACRBTYP="T" D
 .S ACRTA=0
 .S:ACRTCODE'="06119" ACRTA=$P($G(^ACROTA(ACRDOCT,0)),U,3) ;TRAVEL ADV
 Q
MDATA ; - SET VARIABLES FOR INTEREST/DISCOUNT
 S ACRINT=$$DOL^ACRFUTL(ACRINT)
 S ACRIVT=$P(ACRTERMS,U,12)      ; INVOICE TOTAL AMOUNT
 S ACRIVT=$$DOL^ACRFUTL(ACRIVT)
 Q