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

ACRFPAID.m

Go to the documentation of this file.
ACRFPAID ;IHS/OIRM/DSD/THL,AEF - RECONCILE PAID AMOUNTS; [ 11/01/2001   9:44 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;;NOV 05, 2001
 ;;
DOCPAID ;EP;CALCULATE AMOUNT PAID FOR ALL ITEMS ON A DOCUMENT
 N ACRSSDA
 S ACRSSDA=0
 F  S ACRSSDA=$O(^ACRSS("J",ACRDOCDA,ACRSSDA)) Q:'ACRSSDA  D ITEM
 Q
ITEM ;CALCULATE AMOUNT PAID FOR AN ITEM
 N ACRITOT,ACRRRDA
 S ACRITOT=0
 S ACRRRDA=0
 F  S ACRRRDA=$O(^ACRRR("B",ACRSSDA,ACRRRDA)) Q:'ACRRRDA  D
 .Q:'$P($G(^ACRRR(ACRRRDA,0)),U,11)
 .S X=$G(^ACRRR(ACRRRDA,"DT"))
 .S ACRITOT=ACRITOT+($P(X,U,5)*$P(X,U,6))
 Q:'ACRITOT
 S DA=ACRSSDA
 S DIE="^ACRSS("
 S DR="16.1////"_ACRITOT
 I $G(ACRFINAL)'=1 S $P(^ACRSS(ACRSSDA,"DT"),U,21)=ACRITOT
 E  D DIE^ACRFDIC
 Q
TVPAID ;EP;ENTER TRAVEL EXPENSES PAID
 D ALTOT^ACRFCLM
 S ACRSSDA=0
 F  S ACRSSDA=$O(^ACRSS("J",ACRDOCDA,ACRSSDA)) Q:'ACRSSDA  D
 .S ACRSS0=$G(^ACRSS(ACRSSDA,0)),ACRSSDT=$G(^ACRSS(ACRSSDA,"DT"))
 .S ACRITOT=$S(+ACRSS0'=1:$P(ACRSSDT,U,9),1:ACRALTOT)
 .S DA=ACRSSDA
 .S DIE="^ACRSS("
 .S DR="16.1////"_ACRITOT
 .D DIE^ACRFDIC
 Q
PAIDUP ;EP;TO UPDATE ARMS WHEN 1166 BATCH IS CERTIFIED
 Q:'$G(ACRFYDA)!'$G(ACRBATDA)
 N ACRBATNO,ACRBTYP
 S ACRBATNO=$P($G(^AFSLAFP(ACRFYDA,1,ACRBATDA,0)),U)
 Q:ACRBATNO=""
 S ACRBTYP=$S("ABCG"[$E(ACRBATNO):"V","DEF"[$E(ACRBATNO):"T",1:"")
 Q:ACRBTYP=""
 N ACRSEQDA
 S ACRSEQDA=0
 F  S ACRSEQDA=$O(^AFSLAFP(ACRFYDA,1,ACRBATDA,1,ACRSEQDA)) Q:'ACRSEQDA  D
 .Q:'+$G(^AFSLAFP(ACRFYDA,1,ACRBATDA,1,ACRSEQDA,"ARMS"))  S ACRDOCDA=+^("ARMS")
 .D DOCPAID:$G(ACRBTYP)="V"
 .D TVPAID:$G(ACRBTYP)="T"
 Q
SYNC ;EP;TO SYNCHRONIZE ARMS FMS DOCUMENT POINTER IN 1166 RECORDS
 D ^XBKVAR
 D DCALC
 D TCALC
 D ODOC
 N ACRDOC
 S ACRDOC=""
 F  S ACRDOC=$O(^AFSLAFP("N",ACRDOC)) Q:ACRDOC=""  D
 .S ACRDOCDA=$O(^ACRDOC("C",ACRDOC,0))
 .I 'ACRDOCDA S ACRDOCDA=$O(^ACRDOC("B",ACRDOC,0))
 .Q:'ACRDOCDA
 .N ACRFYDA
 .S ACRFYDA=0
 .F  S ACRFYDA=$O(^AFSLAFP("N",ACRDOC,ACRFYDA)) Q:'ACRFYDA  D
 ..N ACRBATDA
 ..S ACRBATDA=0
 ..F  S ACRBATDA=$O(^AFSLAFP("N",ACRDOC,ACRFYDA,ACRBATDA)) Q:'ACRBATDA  D
 ...N ACRSEQDA
 ...S ACRSEQDA=0
 ...F  S ACRSEQDA=$O(^AFSLAFP("N",ACRDOC,ACRFYDA,ACRBATDA,ACRSEQDA)) Q:'ACRSEQDA  D
 ....S DA=ACRSEQDA
 ....S DA(2)=ACRFYDA
 ....S DA(1)=ACRBATDA
 ....S DIE="^AFSLAFP("_DA(2)_",1,"_DA(1)_",1,"
 ....S DR=".02////"_ACRDOCDA
 ....D DIE^ACRFDIC
 ....W "*" ;!,ACRDOC,?10,ACRDOCDA,?20,ACRFYDA,?30,ACRBATDA,?40,ACRSEQDA
 Q
DCALC ;EP;CALCULATE ACTUAL PAID AMOUNT FOR ALL DOCUMENTS
 N ACRDOCDA
 S ACRDOCDA=0
 F  S ACRDOCDA=$O(^ACRRR("C",ACRDOCDA)) Q:'ACRDOCDA  D DOCPAID W "."
 Q
TCALC ;EP;TO CALCULATE TRAVEL EXPENSES PAID
 N ACRDOCDA
 S ACRDOCDA=0
 F  S ACRDOCDA=$O(^ACRDOC("REF",133,ACRDOCDA)) Q:'ACRDOCDA  I $P($G(^ACROBL(ACRDOCDA,"APV")),U,8)="A" D TVPAID W "."
 Q
ODOC ;EP;TO CALCULATE DISBURSEMENTS FOR ARMS DOCUMENTS FROM THE OPEN
 ;DOCUMENT FILE
 K ACRDTOT
 N ACRDOCDA,ACRATOT,ACRDOC,ACRDTOT,ACROFYDA,ACRODDA,ACRITOT,ACRPTOT
 S ACRDOCDA=0
 F  S ACRDOCDA=$O(^ACRDOC(ACRDOCDA)) Q:'ACRDOCDA  D
 .Q:$P(^ACRDOC(ACRDOCDA,0),U,15)
 .S ACRDOC=$S($P(^ACRDOC(ACRDOCDA,0),U,2)]"":$P(^(0),U,2),1:$P(^(0),U))
 .I ACRDOC["-" S ACRDOC=$TR(ACRDOC,"-",""),ACRDOC=$E(ACRDOC,2,11)
 .Q:ACRDOC=""
 .D O1
 .D O2
 .D O3
 .I ACRDTOT,ACRDTOT'=ACRITOT D
 ..W "." ;!,ACRDOC,?15,$J($FN(ACRDTOT,"P,",2),12),?30,$J($FN(ACRATOT,"P,",2),12),?45,$J($FN(ACRITOT,"P,",2),12),?60,$J($FN(ACRPTOT,"P,",2),12)
 ..I $P(^ACROBL(ACRDOCDA,"APV"),U,6)=1,$P(^("DT"),U,2)'=ACRATOT S $P(^("DT"),U,2)=$S(ACRDTOT>ACRATOT:ACRDTOT,1:ACRATOT)
 Q
O1 N ACROFYDA,X
 S (ACROFYDA,ACRDTOT)=0
 F  S ACROFYDA=$O(^AFSLODOC("DOCNO",ACRDOC,ACROFYDA)) Q:'ACROFYDA  D
 .N ACRODDA
 .S ACRODDA=0
 .F  S ACRODDA=$O(^AFSLODOC("DOCNO",ACRDOC,ACROFYDA,ACRODDA)) Q:'ACRODDA  D
 ..S X=$P($G(^AFSLODOC(ACROFYDA,1,ACRODDA,4)),U,4)
 ..S:$E(X)="+" X=+$E(X,2,99)
 ..S X=+X
 ..S:X ACRDTOT=ACRDTOT+X
 S:ACRDTOT ACRDTOT=ACRDTOT/100
 Q
O2 N X
 S (X,ACRITOT,ACRPTOT)=0
 F  S X=$O(^ACRSS("J",ACRDOCDA,X)) Q:'X  S ACRITOT=ACRITOT+$P($G(^ACRSS(X,"DT")),U,4),ACRPTOT=ACRPTOT+$P($G(^("DT")),U,21)
 N Z
 S Z=0
 F  S Z=$O(^ACRDOC("MOD",ACRDOCDA,Z)) Q:'Z  D O21
 Q
O21 S X=0
 F  S X=$O(^ACRSS("J",Z,X)) Q:'X  S ACRITOT=ACRITOT+$P($G(^ACRSS(X,"DT")),U,4),ACRPTOT=ACRPTOT+$P($G(^("DT")),U,21)
 Q
O3 N X,Y,Z
 S (X,ACRATOT)=0
 F  S X=$O(^AFSLAFP("N",ACRDOC,X)) Q:'X  D
 .S Y=0
 .F  S Y=$O(^AFSLAFP("N",ACRDOC,X,Y)) Q:'Y  D
 ..S Z=0
 ..F  S Z=$O(^AFSLAFP("N",ACRDOC,X,Y,Z)) Q:'Z  S ACRATOT=ACRATOT+$P($G(^AFSLAFP(X,1,Y,1,Z,0)),U,11)-$P($G(^(0)),U,12)+$P($G(^(1)),U,6)
 Q
MODS ;EP; SYNC ARMS PO MODS
 N ACRDOCX,ACRDOCDA,ACRITOT,ACRRRDA
 S ACRDOCX=0
 F  S ACRDOCX=$O(^ACRDOC("MOD",ACRDOCX)) Q:'ACRDOCX  D
 .S (ACRDOCDA,ACRITOT)=0
 .F  S ACRDOCDA=$O(^ACRDOC("MOD",ACRDOCX,ACRDOCDA)) Q:'ACRDOCDA  D
 ..S ACRRRDA=0
 ..F  S ACRRRDA=$O(^ACRRR("C",ACRDOCDA,ACRRRDA)) Q:'ACRRRDA  D
 ...Q:'$P(^ACRRR(ACRRRDA,0),U,11)&'$P(^("DT"),U,5)  S X=^("DT")
 ...S ACRITOT=ACRITOT+($P(X,U,5)*$P(X,U,6))
 ...S ACRDOC=$S($P(^ACRDOC(ACRDOCDA,0),U,2)]"":$P(^(0),U,2),1:$P(^(0),U))
 ...I ACRDOC["-" S ACRDOC=$TR(ACRDOC,"-",""),ACRDOC=$E(ACRDOC,2,11)
 ...S X=0
 ...F  S X=$O(^AFSLAFP("N",ACRDOC,X)) Q:'X  D
 ....S Y=0
 ....F  S Y=$O(^AFSLAFP("N",ACRDOC,X,Y)) Q:'Y  D
 .....S Z=0
 .....F  S Z=$O(^AFSLAFP("N",ACRDOC,X,Y,Z)) Q:'Z  I $P(^AFSLAFP(X,1,Y,1,Z,0),U,11)=ACRITOT W !,ACRDOC,?15,ACRDOCDA
 Q