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

ACRFUFM2.m

Go to the documentation of this file.
ACRFUFM2 ;IHS/OIRM/DSD/AEF - UTILITY STANDALONE TO FIND OPEN DOCUMENTS FOR UFMS [ 12/26/2006   9:44 AM ]
 ;;2.1;ADMIN RESOURCE MGMT SYSTEM;**22**;NOV 05, 2001
 ;
 ;This routine loops through the FMS Document file looking for
 ;approved non-Credit Card and non-BPA Purchase Orders that do
 ;not have a Final Receiving Report or a Final Invoice
 ;Also checks for Cancelled
 ;
EN(ACRBDAT) ;----- MAIN ENTRY POINT
 ;
 ;ENTERS WITH BEGIN SEARCH DATE IN DT FORMAT
 ;         IF DATE=NULL, ROUTINE SETS DEFAULT TO FY 2005,06+
 I ACRBDAT="" S ACRBDAT=3041000
 D ^XBKVAR
 D HOME^%ZIS
 K ^TMP("ACROPEN")
 K ^TMP("ACROVEN")
 K ^TMP("ACRAVEN")
 D LOOP(ACRBDAT)
 Q
LOOP(ACRBDAT) ;----- LOOP THROUGH FMS DOCUMENT FILE AND SET TMP FILE
 ;              USE DOCUMENT DATE "DT" CROSS-REFERENCE
 ;
 N ACRCNT,ACRDOCDA,ACRDOC0,ACRREQ,ACRCNC,ACRRTYP,ACRREF
 N ACRAVEN,ACROVEN,ACROPEN,ACRTMP
 S (ACRAVEN,ACROVEN,ACRODOC)=0
 F  S ACRBDAT=$O(^ACRDOC("DT",ACRBDAT)) Q:'ACRBDAT  D
 .S ACRDOCDA=0
 .F  S ACRDOCDA=$O(^ACRDOC("DT",ACRBDAT,ACRDOCDA)) Q:'ACRDOCDA  D
 ..S ACRDOC0=$G(^ACRDOC(ACRDOCDA,0))
 ..S ACRREQ=$P(ACRDOC0,U)
 ..Q:ACRREQ']""
 ..S ACRDOC=$P(ACRDOC0,U,2)
 ..S ACRVND=$P($$VENDOR(ACRDOCDA),U)
 ..I ACRVND]"",ACRVND'="NO VENDOR",ACRRTYP'["TRAVEL" D
 ...S ACRTMP=$$VEND(ACRVND)
 ...I '$D(^TMP("ACRAVEN",$J,ACRVND)) S ACRAVEN=ACRAVEN+1  ;COUNT ACTIVE VENDORS
 ...S ^TMP("ACRAVEN",$J,ACRVND)=ACRBDAT_U_ACRTMP     ;CAPTURE ALL VENDORS
 ..S ACRAPV=$G(^ACROBL(ACRDOCDA,"APV"))
 ..S ACRCNC=$$CANCEL(ACRDOC0,ACRAPV)
 ..Q:ACRCNC="CANCEL"                       ;DON'T WANT CANCELLED
 ..S ACRRTYP=$$REQTP^ACRFSSU(ACRDOCDA)     ;GET REQUEST TYPE
 ..S ACRREF=$$REF^ACRFUTL(ACRDOCDA)        ;GET EXTERNAL REFERENCE CODE
 ..Q:ACRREF=130                            ;TRAVEL ORDER
 ..Q:ACRREF=116                            ;REQUISITION
 ..I ACRVND,ACRREF=148!(ACRRTYP["TRAINING") D  Q
 ...S ACRDOC=ACRREQ
 ...D REST(ACRDOCDA,ACRDOC,ACRAPV,ACRVND)
 ..I ACRREF=600!(ACRREF=602)!(ACRRTYP["TRAVEL") D TRAVEL(ACRDOCDA) Q  ;TREAT TRAVEL VOUCHER/ADVANCE LATER
 ..D REST(ACRDOCDA,ACRDOC,ACRAPV,ACRVND)    ;EVERYTHING ELSE SHOULD BE SOME KIND OF PURCHASE ORDER
 S ^TMP("ACRAVEN",$J,"ALL CURRENT VENDORS")=ACRAVEN
 S ^TMP("ACROVEN",$J,"ALL OPEN DOC VENDORS")=ACROVEN
 S ^TMP("ACROPEN",$J,"ALL OPEN DOCUMENTS")=ACRODOC
 Q
REST(ACRDOCDA,ACRDOC,ACRAPV,ACRVND) ;SCREEN THE REST
 N ACRTMP
 I ACRDOC="" Q                            ;ONLY WANT PURCHASE ORDERS
 I $E(ACRDOC,9,10)="BP" Q                 ;DON'T WANT ORIGINAL BPA'S
 S ACROPEN=$$OPEN(ACRAPV)
 Q:ACROPEN="CLOSED"                        ;NOT OPEN
 S ACRTMP=ACRCNC_U_ACRBDAT_U_ACRDOCDA_U_ACRREQ_U_ACRDOC_U_ACRVND_U
 S ACRTMP=ACRTMP_$P(ACRRTYP,U,2)_U_ACRREF
 I ACRREF=148 D  Q
 .S ^TMP("ACRTRNG",$J,ACRVND)=ACRBDAT_U_$$VEND(ACRVND)
 I '$D(^TMP("ACROPEN",$J,ACRVND)) S ACRODOC=ACRODOC+1
 S ^TMP("ACROPEN",$J,ACROPEN,ACRDOCDA)=ACRTMP
 S ^TMP("ACROPEN",$J,ACROPEN)=$G(^TMP("ACROPEN",$J,ACROPEN))+1
 ;NOW CAPTURE OPEN DOCUMENT VENDORS WITH MOST RECENT DATE
 D
 .I ACRVND["NO VENDOR" S ACRVND=ACRVND_ACRDOCDA,ACRTMP="" Q
 .S ACRTMP=$$VEND(ACRVND)
 I '$D(^TMP("ACROVEN",$J,ACRVND)) S ACROVEN=ACROVEN+1
 S ^TMP("ACROVEN",$J,ACRVND)=ACRBDAT_U_ACRTMP
 Q
 ;
CANCEL(X,Z) ;
 ; ENTERS WITH X=ACRDOC0
 ;             Z=ACRAPV (FMS REQUEST, "APV" NODE)
 N Z1,Z3
 S Z1=$P(Z,U)
 S Z3=$P(Z,U,3)
 S Z8=$P(Z,U,8)
 I Z1="A",Z3="A",Z8="A" Q "APPROVED"   ;DOCUMENT APPROVED
 ;
 I Z1="C"!(Z1="D") Q "CANCEL"          ;REQUISITION CANCELLED OR DISAPPROVED
 I Z3="C"!(Z3="D") Q "CANCEL"          ;REQ AUTH CANCELLED OR DISAPPROVED
 I Z8="D" Q "CANCEL"                   ;PO AUTH CANCELLED OR DISAPPROVED
 I Z1="" Q "NO REQ APP CODE"           ;PO WITH NO REQ APPROVAL
 I Z3="" Q "NO REQ AUTH CODE"           ;PO AUTH NOT CODED
 I Z8="" Q "NO PO AUTH CODE"
 Q "UNKNOWN IF APPROVED"                           ;APPROVED
 ;
OPEN(ACRAPV) ;
 ;(#909) FINAL RECEIVING REPORT [6S] ^
 ;       '1' FOR FINAL;
 ;       '2' FOR PARTIAL;
 ;(#912) FINAL INVOICE [9S] ^
 ;       '1' FOR FINAL;
 ;       '2' FOR PARTIAL;
 ;       '3' FOR PENDING;
 N Z6,Z9
 S Z6=$P(ACRAPV,U,6)
 S Z9=$P(ACRAPV,U,9)
 I Z9=1!(Z6=1) Q "CLOSED"             ;FINAL INVOICE OR RECEIVING REPORT
 ;I Z6=1,Z9'=1 Q "FINAL INVOICE ONLY"
 I Z6=2!(Z9=2) Q "P"                   ;PARTIAL RECEIVING REPORT
 I Z6="",Z9="" Q "O"                   ;OPEN DOCUMENT
 Q "QUESTIONABLE "_Z6_"-"_Z9
 ;
WRITE(JOB) ;EP; WRITE FLAT FILE
 N ACRA,ACRB,ACRC,ACRD
 S:JOB="" JOB=$J
 S ACRA=0
 F  S ACRA=$O(^TMP("ACROPEN",JOB,ACRA)) Q:ACRA=""  D
 .W !,ACRA_" -- ",^TMP("ACROPEN",JOB,ACRA)              ;TOTAL FOR TYPE
 .S ACRB=0
 .F  S ACRB=$O(^TMP("ACROPEN",JOB,ACRA,ACRB)) Q:ACRB=""  D
 ..W !,ACRA_U_^TMP("ACROPEN",JOB,ACRA,ACRB)
 Q
WRITEV(JOB) ;EP; WRITE TO FLAT FILE
 N ACRA
 S:JOB="" JOB=$J
 F I="ACRAVEN","ACROVEN" D
 .S ACRA=0
 .F  S ACRA=$O(^TMP(I,JOB,ACRA)) Q:ACRA=""  D
 ..W !,ACRA_U_^TMP(I,JOB,ACRA)
 Q
VEND(ACRV) ;
 N ACRO
 I ACRV="" Q ""
 S ACR0=^AUTTVNDR(+ACRV,0)
 S ACRP1=$P(ACR0,U)               ;VENDOR NAME
 S ACRP5=$P(ACR0,U,5)             ;DATE INACTIVATED
 S ACRP7=$P(ACR0,U,7)             ;DUNS
 S ACRP13=$P($G(^AUTTVNDR(+ACRV,11)),U,13)        ;EIN + SUFFIX
 Q ACRP1_U_ACRP5_U_ACRP7_U_ACRP13
 ;
VENDOR(ACR) ;EP; FIND VENDOR FROM PO,TRAINING OR TRAVEL (SSN FROM NEW PERSON)
 N ACRV
 S ACRRTYP=$$REQTP^ACRFSSU(ACR)     ;GET REQUEST TYPE
 I ACRRTYP["TRAVEL" Q $$TRAVEL(ACR)
 S ACRV=$P($G(^ACRDOC(ACR,"PO")),U,5)
 S:ACRV=-1 ACRV=""
 I ACRV="",ACRRTYP["TRAINING" D
 .S ACRV=$P($G(^ACRDOC(ACR,"TRNG3")),U) ;GET VENDOR FROM TRAINING NODE
 I ACRV="" S ACRV="NO VENDOR^"
 Q ACRV
TRAVEL(ACR) ;TRAVEL VOUCHER OR ADVANCE
 S ACRDUZ=$P($G(^ACRDOC(ACR,"TO")),U,9)
 I ACRDUZ="" Q "NO TRAVELER^NO SSN"
 S ACRV=$P($G(^VA(200,+ACRDUZ,1)),U,9)
 I ACRV="" Q ACRDUZ_"^NO SSN"
 Q ACRV=ACRDUZ_U_2_ACRV      ;TURN SSN INTO INDIV VENDOR NUMBER