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

ACRFIRS6.m

Go to the documentation of this file.
ACRFIRS6 ;IHS/OIRM/DSD/AEF - PRINT 1099s [ 07/24/2002  3:17 PM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**1,3**;NOV 05, 2001
 ;
EN ;EP -- PRINT ALL VENDOR 1099S
 ;
 N ACRLOC,ACRYR,ZTSAVE
 ;
 D HOME^%ZIS
 D ^XBKVAR
 ;
 D LOC(.ACRLOC)
 Q:'$G(ACRLOC)
 ;
 D YR(.ACRYR)
 Q:'$G(ACRYR)
 ;
 S ZTSAVE("ACRLOC")=""
 S ZTSAVE("ACRYR")=""
 D QUE^ACRFUTL("DQ^ACRFIRS6",.ZTSAVE,"PRINT 1099s")
 ;
 D ^%ZISC
 Q
DQ ;EP -- QUEUED JOB STARTS HERE
 ;
 ;      INCOMING VARIABLES:
 ;      ACRLOC  = PAYER IEN
 ;      ACRYR   = CALENDAR YEAR
 ;
 ;      OTHER VARIABLES USED:
 ;      ACRTAMT = ARRAY CONTAINING AMOUNT TOTALS BY TYPE CODE
 ;      ACRTCNT = ARRAY CONTAINING VENDOR COUNT BY TYPE CODE
 ;
 N ACRTAMT,ACRTCNT
 ;
 D ^XBKVAR
 ;
 D LOOP(ACRLOC,ACRYR,.ACRTAMT,.ACRTCNT)
 ;
 D TOTALS(.ACRTAMT,.ACRTCNT)
 ;
 K ACRLOC,ACRYR
 ;
 D ^%ZISC
 Q
LOOP(ACRLOC,ACRYR,ACRTAMT,ACRTCNT)     ;
 ;----- LOOP THROUGH ARMS VENDOR FILE AND PRINT 1099s
 ;
 ;      INPUT:
 ;      ACRLOC  = PAYER IEN
 ;      ACRYR   = CALENDAR YEAR
 ;
 ;      RETURNS:
 ;      ACRTAMT = ARRAY CONTAINING PAYMENT AMOUNTS BY TYPE CODE
 ;      ACRTCNT = ARRAY CONTAINING VENDOR COUNTS BY TYPE CODE
 ;
 N ACRCNT,ACRNAME,ACRVEN
 ;
 K ^TMP("ACR1099",$J)
 ;
 D ALPHA(ACRYR)
 Q:'$D(^TMP("ACR1099",$J))
 ;
 S ACRCNT=0
 S ACRNAME=""
 F  S ACRNAME=$O(^TMP("ACR1099",$J,ACRNAME)) Q:ACRNAME']""  D
 . S ACRVEN=0 F  S ACRVEN=$O(^TMP("ACR1099",$J,ACRNAME,ACRVEN)) Q:'ACRVEN  D
 . . Q:$$AMT(ACRVEN,ACRYR)<600
 . . S ACRCNT=ACRCNT+1
 . . I ACRCNT>1,ACRCNT#2 W @IOF
 . . D PRT(ACRVEN,ACRLOC,ACRYR,ACRCNT,.ACRTAMT,.ACRTCNT)
 . . D UPDATE(ACRVEN,ACRYR)
 ;
 K ^TMP("ACR1099",$J)
 Q
ALPHA(ACRYR)       ;
 ;----- BUILD ALPHABETIC ARRAY OF VENDORS IN ^TMP("ACR1099",$J)
 ;
 ;      INPUT:
 ;      ACRYR   = CALENDAR YEAR
 ;
 N ACRNAME,ACRVEN
 S ACRVEN=0
 F  S ACRVEN=$O(^ACR1099V("C",ACRYR,ACRVEN)) Q:'ACRVEN  D
 . S ACRNAME=$P(^AUTTVNDR(ACRVEN,0),U)
 . S ^TMP("ACR1099",$J,ACRNAME,ACRVEN)=0
 Q
PRT(ACRVEN,ACRLOC,ACRYR,ACRCNT,ACRTAMT,ACRTCNT)  ;
 ;----- PRINT VENDOR 1099
 ;
 ;      INPUT:
 ;      ACRVEN  = VENDOR IEN
 ;      ACRLOC  = PAYER IEN
 ;      ACRYR   = CALENDAR YEAR
 ;
 ;      RETURNS:
 ;      ACRTAMT = ARRAY CONTAINING AMOUNT TOTALS BY TYPE CODE
 ;      ACRTCNT = ARRAY CONTAINING COUNT TOTALS BY TYPE CODE
 ;
 ;      VARIABLES SET AND USED BY THIS SUBROUTINE:
 ;      ACRAMT  = ARRAY CONTAINING PAYMENT AMOUNTS BY TYPE CODE
 ;      ACRCOR  = CORRECTED RETURN INDICATOR
 ;      ACRIRS  = PAYER IRS NAME
 ;      ACRPADD = ARRAY CONTAINING PAYER ADDRESS
 ;      ACRPSN  = PAYER STATE NUMBER
 ;      ACRPTIN = PAYER TAX ID NUMBER
 ;      ACRTYP  = PAYMENT TYPE CODE
 ;      ACRVADD = ARRAY CONTAINING VENDOR ADDRESS
 ;      ACRVTIN = VENDOR TAX ID NUMBER
 ;
 ;
 ;----- SET VARIABLES
 ;
 N ACRAMT,ACRCOR,ACRIRS,ACRPADD,ACRPSN,ACRPTIN,ACRTYP,ACRVADD,ACRVTIN,DATA
 I '$D(^ACR1099V(ACRVEN,1,ACRYR)) D  Q   ;ACR*2.1*3.30
 . W !,"NO DATA FOUND" ;ACR*2.1*3.30
 ;
 F I=1:1:8,"A","B","C" S ACRAMT(I)=""
 S ACRCOR=""
 I $P($G(^ACR1099V(ACRVEN,1,ACRYR,0)),U,6)="Y" S ACRCOR="X"
 S DATA=^ACR1099V(ACRVEN,0)
 S ACRTYP=$P(DATA,U,2)
 S ACRIRS=$P(DATA,U,3)
 S ACRAMT(ACRTYP)=$$AMT(ACRVEN,ACRYR)
 D PADD(ACRLOC,.ACRPADD)
 D VADD(ACRVEN,ACRIRS,.ACRVADD)
 S ACRPTIN=$P(^ACR1099P(ACRLOC,0),U,8)
 S ACRVTIN=$E($P(^AUTTVNDR(ACRVEN,11),U),2,10)
 S ACRPSN=$P($G(^ACR1099P(ACRLOC,1)),U)
 ;
 ;----- PRINT INDIVIDUAL LINES
 ;
 ;LINE2 BLANK
 ;W !
 ;         
 ;LINE3 CORRECTED RETURN INDICATOR
 ;W !
 W ?30,ACRCOR
 ;
 ;LINE4 BLANK
 W !
 ;
 ;LINE5 PAYER'S NAME
 W !
 W ?5,ACRPADD(1)
 ;
 ;LINE6 PAYER'S ADDRESS LINE 1 / RENTS AMOUNT
 W !
 W ?5,ACRPADD(2)
 W ?39,$J(ACRAMT(1),12,2)
 ;
 ;LINE7 PAYER'S ADDRESS LINE 2
 W !
 W ?5,ACRPADD(3)
 ;
 ;LINE8 PAYER'S CITY,STATE,ZIP
 W !
 W ?5,ACRPADD(4)
 ;
 ;LINE9 ROYALTIES AMOUNT
 W !
 W ?39,$J(ACRAMT(2),12,2)
 ;
 ;LINE10 BLANK
 W !
 ;
 ;LINE11 OTHER INCOME AMOUNT / FEDERAL INCOME TAX WHLD AMOUNT
 W !
 W ?39,$J(ACRAMT(3),12,2)
 W ?53,$J(ACRAMT(4),12,2)
 ;
 ;LINE12 BLANK
 W !
 ;
 ;LINE13 BLANK  
 W !
 ;
 ;LINE14 BLANK     
 W !
 ;
 ;LINE15 PAYER TIN / PAYEE TIN / FISHING BOAT AMOUNT / MEDICAL AMOUNT
 W !
 W ?5,ACRPTIN
 W ?25,ACRVTIN
 W ?39,$J(ACRAMT(5),12,2)
 W ?53,$J(ACRAMT(6),12,2)
 ;
 ;LINE16 BLANK
 W !
 ;
 ;LINE17 PAYEE'S NAME
 W !
 W ?5,ACRVADD(1)
 ;
 ;LINE18 BLANK
 W !
 ;
 ;LINE19 NONEMPLOYEE COMP AMOUNT / SUBSTITUTE PMT AMOUNT
 W !
 W ?39,$J(ACRAMT(7),12,2)
 W ?53,$J(ACRAMT(8),12,2)
 ;
 ;LINE20 BLANK
 W !
 ;
 ;LINE21 PAYEE ADDRESS LINE 1
 W !
 W ?5,ACRVADD(2)
 ;
 ;LINE22 PAYEE ADDRESS LINE 2 / CROP INSURANCE AMOUNT
 W !
 W ?5,ACRVADD(3)
 W ?53,$J(ACRAMT("A"),12,2)
 ;
 ;LINE23 BLANK
 W !
 ;
 ;LINE24 PAYEE CITY,STATE,ZIP
 W !
 W ?5,ACRVADD(4)
 ;
 ;LINE25 BLANK
 W !
 ;
 ;LINE26 BLANK   
 W !
 ;
 ;LINE27 GOLDEN PARACHUTE AMOUNT / PROCEEDS TO ATTORNEY AMOUNT
 W !
 W ?39,$J(ACRAMT("B"),12,2)
 W ?53,$J(ACRAMT("C"),12,2)
 ;
 ;LINE28 BLANK
 W !
 ;
 ;LINE29 STATE/PAYER'S STATE NO.
 W !
 W ?55,ACRPSN
 ;
 ;LINE30 BLANK  
 W !
 ;
 I $G(ACRCNT)#2 F I=1:1:6 W !
 ;
 ;----- SET DOLLAR AMOUNT ARRAY
 ;
 S ACRTAMT(ACRTYP)=$G(ACRTAMT(ACRTYP))+ACRAMT(ACRTYP)
 S ACRTCNT(ACRTYP)=$G(ACRTCNT(ACRTYP))+1
 Q
LOC(ACRLOC)        ;
 ;----- ASK FINANCE LOCATION
 ;
 ;      RETURNS:
 ;      ACRLOC  = PAYER IEN
 ;
 N DIC,DTOUT,DUOUT,X,Y
 S DIC="^ACR1099P("
 S DIC(0)="AEMQ"
 S DIC("A")="Select FINANCE LOCATION: "
 D ^DIC
 Q:$D(DTOUT)!($D(DUOUT))
 Q:+Y'>0
 S ACRLOC=+Y
 Q
YR(ACRYR)          ;
 ;----- ASK CALENDAR YEAR
 ;
 ;      RETURNS:
 ;      ACRYR   = CALENDAR YEAR
 ;
 N DIR,DIRUT,DTOUT,DUOUT,X,Y
 S DIR(0)="N^0000:9999"
 S DIR("A")="Select CALENDAR YEAR"
 S DIR("B")=($E(DT,1,3)+1700)-1
 D ^DIR
 Q:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))
 Q:+Y'>0
 S ACRYR=+Y
 Q
VEN(ACRVEN)        ;
 ;----- ASK VENDOR
 ;
 ;      RETURNS:
 ;      ACRVEN  = VENDOR IEN
 ;
 N DIC,DTOUT,DUOUT,X,Y
 S DIC="^ACR1099V("
 S DIC(0)="AEMQ"
 S DIC("A")="Select VENDOR: "
 D ^DIC
 Q:$D(DTOUT)!($D(DUOUT))
 Q:+Y'>0
 S ACRVEN=+Y
 Q
UPDATE(ACRVEN,ACRYR)         ;
 ;----- UPDATE 1099 PRINT DATE FIELD IN ARMS 1099 VENDOR FILE
 ;
 ;      INPUT:
 ;      ACRVEN  = VENDOR IEN
 ;      ACRYR   = CALENDAR YEAR
 ;
 N DA,DIE,DR,X,Y
 S DA(1)=ACRVEN
 S DA=ACRYR
 S DIE="^ACR1099V("_DA(1)_",1,"
 S DR=".05////"_DT
 D ^DIE
 Q
ONE ;EP -- PRINT ONE VENDOR 1099
 ;
 N ACRLOC,ACRVEN,ACRYR,ZTSAVE
 ;
 D HOME^%ZIS
 D ^XBKVAR
 ;
 D LOC(.ACRLOC)
 Q:'$G(ACRLOC)
 ;
 D YR(.ACRYR)
 Q:'$G(ACRYR)
 ;
 D VEN(.ACRVEN)
 Q:'$G(ACRVEN)
 ;
 S ZTSAVE("ACRLOC")=""
 S ZTSAVE("ACRYR")=""
 S ZTSAVE("ACRVEN")=""
 D QUE^ACRFUTL("DQ1^ACRFIRS6",.ZTSAVE,"PRINT ONE 1099")
 ;
 D ^%ZISC
 Q
DQ1 ;EP -- QUEUED JOB STARTS HERE
 ;
 ;      INPUT:
 ;      ACRLOC  = PAYER IEN
 ;      ACRVEN  = VENDOR IEN
 ;      ACRYR   = CALENDAR YEAR
 ;
 N ACRMTOT,ACRMAMT,ACRNTOT,ACRNAMT
 ;
 W @IOF
 ;
 D ^XBKVAR
 ;
 D PRT(ACRVEN,ACRLOC,ACRYR,$G(ACRCNT),.ACRTAMT,.ACRTCNT)
 ;
 D TOTALS(.ACRTAMT,.ACRTCNT)
 ;
 D ^%ZISC
 K ACRLOC,ACRVEN,ACRYR
 Q
TEST ;EP -- PRINT TEST 1099s
 ;
 N ACRLOC,ACRYR,ZTSAVE
 ;
 D ^XBKVAR
 ;
 D LOC(.ACRLOC)
 Q:'$G(ACRLOC)
 ;
 D YR(.ACRYR)
 Q:'$G(ACRYR)
 ;
 S ZTSAVE("ACRLOC")=""
 S ZTSAVE("ACRYR")=""
 D QUE^ACRFUTL("DQ2^ACRFIRS6",.ZTSAVE,"PRINT TEST 1099s")
 ;
 D ^%ZISC
 Q
DQ2 ;EP -- QUEUED JOB STARTS HERE
 ;
 ;      INPUT:
 ;      ACRLOC  = PAYER IEN
 ;      ACRYR   = CALENDAR YEAR
 ;
 N ACRTAMT,ACRTCNT,ACRVEN,ACRCNT
 ;
 W @IOF
 ;
 D ^XBKVAR
 ;
 S (ACRVEN,ACRCNT)=0
 F  Q:ACRCNT>9  S ACRVEN=$O(^ACR1099V("C",ACRYR,ACRVEN)) Q:'ACRVEN  D
 . S ACRCNT=ACRCNT+1
 . Q:ACRCNT>9
 . I ACRCNT>1,ACRCNT#2 W @IOF
 . D PRT(ACRVEN,ACRLOC,ACRYR,ACRCNT,.ACRTAMT,.ACRTCNT)
 ;
 D TOTALS(.ACRTAMT,.ACRTCNT)
 ;
 K ACRLOC,ACRYR
 D ^%ZISC
 Q
RANGE ;EP -- PRINT RANGE OF VENDOR 1099S
 ;
 N ACRLOC,ACRVEN,ACRYR,ZTSAVE
 ;
 D ^XBKVAR
 ;
 K ^TMP("ACR1099",$J)
 ;
 D LOC(.ACRLOC)
 Q:'$G(ACRLOC)
 ;
 D YR(.ACRYR)
 Q:'$G(ACRYR)
 ;
 D ALPHA(ACRYR)
 I '$D(^TMP("ACR1099",$J)) D  G RANGE
 . W !,"No Vendor data found for ",ACRYR
 ;
 D VEND(.ACRVEN)
 Q:ACRVEN']""
 ;
 S ZTSAVE("ACRLOC")=""
 S ZTSAVE("ACRYR")=""
 S ZTSAVE("ACRVEN")=""
 D QUE^ACRFUTL("DQ3^ACRFIRS6",.ZTSAVE,"PRINT RANGE OF 1099S")
 ;
 D ^%ZISC
 Q
DQ3 ;EP -- QUEUED JOB STARTS HERE
 ;
 ;      INPUT:
 ;      ACRLOC  = PAYER IEN
 ;      ACRVEN  = VENDOR RANGE
 ;      ACRYR   = CALENDAR YEAR
 ;
 N ACRTAMT,ACRTCNT
 ;
 D ^XBKVAR
 ;
 D LOOP3(ACRLOC,ACRYR,ACRVEN,.ACRTAMT,.ACRTCNT)
 ;
 K ACRLOC,ACRYR,ACRVEN
 D ^%ZISC
 Q
LOOP3(ACRLOC,ACRYR,ACRVEN,ACRTAMT,ACRTCNT)       ;
 ;
 ;     INPUT:
 ;     ACRLOC  = PAYER IEN
 ;     ACRVEN  = VENDOR RANGE
 ;     ACRYR   = CALENDAR YEAR
 ;
 ;     RETURNS:
 ;     ACRTAMT = ARRAY CONTAINING AMOUNTS BY PAYMENT TYPE CODE
 ;     ACRTCNT = ARRAY CONTAINING VENDOR COUNTS BY PAYMENT TYPE CODE
 ;
 N ACREND,ACRNAME,ACRCNT
 ;
 D ALPHA(ACRYR)
 Q:'$D(^TMP("ACR1099",$J))
 ;
 S ACREND=$P(ACRVEN,U,2)
 S ACRNAME=$P(ACRVEN,U)
 S ACRNAME=$O(^TMP("ACR1099",$J,ACRNAME),-1)
 ;
 S ACRCNT=0
 F  S ACRNAME=$O(^TMP("ACR1099",$J,ACRNAME)) Q:ACRNAME']""  Q:ACRNAME]ACREND  D
 . S ACRVEN=0
 . F  S ACRVEN=$O(^TMP("ACR1099",$J,ACRNAME,ACRVEN)) Q:'ACRVEN  D
 . . Q:$$AMT(ACRVEN,ACRYR)<600
 . . S ACRCNT=ACRCNT+1
 . . I ACRCNT>1,ACRCNT#2 W @IOF
 . . D PRT(ACRVEN,ACRLOC,ACRYR,ACRCNT,.ACRTAMT,.ACRTCNT)
 ;
 D TOTALS(.ACRTAMT,.ACRTCNT)
 ;
 K ^TMP("ACR1099",$J)
 Q
VEND(ACRVEN)       ;
 ;----- GETS START AND END VENDORS IN RANGE SELECTION
 ;
V ;      RETURNS:
 ;      ACRVEN  = CONTAINS BEGINNING AND ENDING VENDOR NAME RANGE
 ; 
 N DIR,X,Y
 S ACRVEN=""
 S DIR(0)="F"
 S DIR("A")="Start with VENDOR"
 S DIR("?")="Enter BEGINNING VENDOR in range"
 D ^DIR
 I $D(DTOUT)!($D(DUOUT))!($D(DIRUT)) S ACRVEN="" Q
 Q:Y']""
 S ACRVEN=Y
 S DIR("A")="End with VENDOR"
 S DIR("?")="Enter ENDING VENDOR in range"
 D ^DIR
 I $D(DTOUT)!($D(DUOUT))!($D(DIRUT)) S ACRVEN="" Q
 I Y']"" S ACRVEN="" Q
 I Y']ACRVEN D  G V
 . W !,"'",Y,"' does not follow '",ACRVEN,"'"
 S ACRVEN=ACRVEN_"^"_Y
 Q
TOTALS(ACRTAMT,ACRTCNT)      ;
 ;----- PRINTS GRAND TOTALS
 ;
 ;      INPUT:
 ;      ACRTAMT = ARRAY CONTAINING AMOUNT TOTALS BY PAYMENT TYPE CODE
 ;      ACRTCNT = ARRAY CONTAINING VENDOR COUNTS BY PAYMENT TYPE CODE
 ;
 W @IOF
 ;
 N ACRGAMT,ACRGCNT,ACRTYP,I
 ;
 S ACRTYP(1)="RENTS"
 S ACRTYP(2)="ROYALTIES"
 S ACRTYP(3)="OTHER INCOME"
 S ACRTYP(4)="FED INC TAX WHLD"
 S ACRTYP(5)="FISHING BOAT PROC"
 S ACRTYP(6)="MED & HLTH CARE"
 S ACRTYP(7)="NONEMPLOYEE COMP"
 S ACRTYP(8)="SUBSTITUTE PMTS"
 S ACRTYP("A")="CROP INS PROC"
 S ACRTYP("B")="EXC GOLD PARA"
 S ACRTYP("C")="PROC TO ATTY"
 ;
 F I=1:1:3 W !
 ;
 S (ACRGCNT,ACRGAMT)=0
 F I=1:1:8,"A","B","C" D
 . ;Q:'$D(ACRTAMT(I))
 . W ?5,"TOTAL FOR ",ACRTYP(I)," PMTS:"
 . W ?40,$J(+$G(ACRTCNT(I)),4)
 . W ?50,$J(+$G(ACRTAMT(I)),12,2)
 . S ACRGCNT=$G(ACRGCNT)+$G(ACRTCNT(I))
 . S ACRGAMT=$G(ACRGAMT)+$G(ACRTAMT(I))
 . W !!
 ;
 W ?40,"----"
 W ?50,"------------"
 W !
 W ?40,$J(ACRGCNT,4)
 W ?50,$J(ACRGAMT,12,2)
 Q
AMT(ACRVEN,ACRYR)  ;
 ;----- EXTRINSIC FUNCTION TO RETURN DOLLAR AMOUNT
 ;
 N X
 S X=$G(^ACR1099V(ACRVEN,1,ACRYR,0))
 S Y=$P(X,U,2)
 I $P(X,U,6)="Y" S Y=$P(X,U,8)
 Q Y
PADD(ACRLOC,ACRPADD)         ;
 ;----- RETURN PAYER'S ADDRESS ARRAY
 ;
 N I,DATA,X
 K ACRPADD
 F I=1:1:4 S ACRPADD(I)=""
 S I=0
 S DATA=$G(^ACR1099P(ACRLOC,0))
 I $P(DATA,U,2)]"" D
 . S I=I+1
 . S ACRPADD(I)=$P(DATA,U,2)
 I $P(DATA,U,3)]"" D
 . S I=I+1
 . S ACRPADD(I)=$P(DATA,U,3)
 I $P(DATA,U,4)]"" D
 . S I=I+1
 . S ACRPADD(I)=$P(DATA,U,4)
 S X=$P(DATA,U,5)_", "_$P(^DIC(5,$P(DATA,U,6),0),U,2)_"  "_$P(DATA,U,7)
 S I=I+1
 S ACRPADD(I)=X
 Q
VADD(ACRVEN,ACRIRS,ACRVADD)  ;
 ;----- RETURN VENDOR'S ADDRESS ARRAY
 ;
 N I,DATA,X
 K ACRVADD
 F I=1:1:4 S ACRVADD(I)=""
 S ACRVADD(1)=$P(^AUTTVNDR(ACRVEN,0),U)
 I ACRIRS]"" S ACRVADD(1)=ACRIRS
 S I=1
 S DATA=$G(^AUTTVNDR(ACRVEN,13))
 I $P(DATA,U)]"" D
 . S I=I+1
 . S ACRVADD(I)=$P(DATA,U)
 I $P(DATA,U,10)]"" D
 . S I=I+1
 . S ACRVADD(I)=$P(DATA,U,10)
 S X=$P(DATA,U,2)_", "_$P(^DIC(5,$P(DATA,U,3),0),U,2)_"  "_$P(DATA,U,4)
 S ACRVADD(4)=X
 Q