ENFACTU ;(WCIOFO)/SAB-FAP CAPITALIZATION THRESHOLD UTILITIES ;5/22/2002
;;7.0;ENGINEERING;**63,71**;August 17, 1993
TOPSYS(ENDA) ; Topmost System
; input ENDA - equipment entry #
; returns
; entry # of topmost equipment in system of which ENDA is a part
; OR 0 if ENDA is not part of a system (parent or component)
; OR ?^message if error detected
;
N ENDAC,ENDAP,ENPL,ENRET
S ENRET=""
;
; start with ENDA as component and determine top-most item in system
S ENPL=U ; init list of parents (used for detection of endless loop)
S ENDAC=ENDA ; start with ENDA as a component
; traverse parent chain
F S ENDAP=$P($G(^ENG(6914,ENDAC,0)),U,3) Q:ENDAP=""!(ENPL[(U_ENDAP_U)) S ENDAC=ENDAP,ENPL=ENPL_ENDAP_U
I ENDAP]"" S ENRET="?^ENDLESS LOOP DETECTED"
;
; use topmost parent if found
I ENRET="",ENDAC'=ENDA S ENRET=ENDAC
; if not component then is item a parent?
I ENRET="",$O(^ENG(6914,"AE",ENDA,""))]"" S ENRET=ENDA
; must not be part of system
I ENRET="" S ENRET=0
;
Q ENRET
;
SYSVAL(ENDAT,ENSW) ; System Value
; input ENDAT - entry # parent for system
; ENSW - optional switch
; contains "C" if only capitalized values should be
; included in return value
; returns sum of asset values for parent and all it's components
;
N ENDA,ENMD,ENNODE,ENSUM,ENDA
S ENSW=$G(ENSW)
S ENSUM=0
;
; build list of all items in the system
K ^TMP("ENSYS",$J)
S ENMD=1
D GETC^ENEQRP6(ENDAT,"","^TMP(""ENSYS"",$J,")
;
; loop thru all equipment on system list and sum asset values
S ENNODE="^TMP(""ENSYS"",$J,"""")"
F S ENNODE=$Q(@ENNODE) Q:$QS(ENNODE,1)_$QS(ENNODE,2)'=("ENSYS"_$J) D
. S ENDA=$QS(ENNODE,$QL(ENNODE))
. I ENSW["C",$$CHKFA^ENFAUTL(ENDA)'>0 Q ; if only capitalized $
. S ENSUM=ENSUM+$P($G(^ENG(6914,ENDA,2)),U,3)
;
K ^TMP("ENSYS",$J)
Q ENSUM
;
CHKEXP(ENDA) ; Check if capitalized equipment item should be expensed
; input ENDA - equipment Entry # if check
; returns
; 1 (true) if it should be expensed
; 0^reason if it should not be expensed due to system criteria
; U^username if it should not be expensed due to user edit
;
N ENSYS,ENUSER
; must be reported to Fixed Assets/FMS to be an issue
I $$CHKFA^ENFAUTL(ENDA)'>0 Q "0^NOT CURRENTLY REPORTED TO FAP"
;
; does item meet any of the system criteria to remain capitalized?
I $$GET1^DIQ(6914,ENDA,38)="1524" Q "0^SGL 1524 (EXCESS)"
I $$GET1^DIQ(6914,ENDA,62)="4539" Q "0^FUND 4539 (FRANCHISE)"
I $$GET1^DIQ(6914,ENDA,12)>99999.99 Q "0^ASSET VALUE > 99999.99"
S ENSYS=$$TOPSYS(ENDA) ; if part of system then check system value
I ENSYS,$$SYSVAL(ENSYS,"C")>99999.99 Q "0^SYSTEM VALUE > 99999.99"
;
; did user specify that item should remain capitalized
S ENUSER=$$GET1^DIQ(6914,ENDA,99,"E")
I ENUSER]"" Q "U^"_ENUSER
;
; item did not meet any of criteria to remain capitalized
Q 1
;
;ENFACTU
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HENFACTU 2962 printed Dec 13, 2024@01:53:28 Page 2
ENFACTU ;(WCIOFO)/SAB-FAP CAPITALIZATION THRESHOLD UTILITIES ;5/22/2002
+1 ;;7.0;ENGINEERING;**63,71**;August 17, 1993
TOPSYS(ENDA) ; Topmost System
+1 ; input ENDA - equipment entry #
+2 ; returns
+3 ; entry # of topmost equipment in system of which ENDA is a part
+4 ; OR 0 if ENDA is not part of a system (parent or component)
+5 ; OR ?^message if error detected
+6 ;
+7 NEW ENDAC,ENDAP,ENPL,ENRET
+8 SET ENRET=""
+9 ;
+10 ; start with ENDA as component and determine top-most item in system
+11 ; init list of parents (used for detection of endless loop)
SET ENPL=U
+12 ; start with ENDA as a component
SET ENDAC=ENDA
+13 ; traverse parent chain
+14 FOR
SET ENDAP=$PIECE($GET(^ENG(6914,ENDAC,0)),U,3)
if ENDAP=""!(ENPL[(U_ENDAP_U))
QUIT
SET ENDAC=ENDAP
SET ENPL=ENPL_ENDAP_U
+15 IF ENDAP]""
SET ENRET="?^ENDLESS LOOP DETECTED"
+16 ;
+17 ; use topmost parent if found
+18 IF ENRET=""
IF ENDAC'=ENDA
SET ENRET=ENDAC
+19 ; if not component then is item a parent?
+20 IF ENRET=""
IF $ORDER(^ENG(6914,"AE",ENDA,""))]""
SET ENRET=ENDA
+21 ; must not be part of system
+22 IF ENRET=""
SET ENRET=0
+23 ;
+24 QUIT ENRET
+25 ;
SYSVAL(ENDAT,ENSW) ; System Value
+1 ; input ENDAT - entry # parent for system
+2 ; ENSW - optional switch
+3 ; contains "C" if only capitalized values should be
+4 ; included in return value
+5 ; returns sum of asset values for parent and all it's components
+6 ;
+7 NEW ENDA,ENMD,ENNODE,ENSUM,ENDA
+8 SET ENSW=$GET(ENSW)
+9 SET ENSUM=0
+10 ;
+11 ; build list of all items in the system
+12 KILL ^TMP("ENSYS",$JOB)
+13 SET ENMD=1
+14 DO GETC^ENEQRP6(ENDAT,"","^TMP(""ENSYS"",$J,")
+15 ;
+16 ; loop thru all equipment on system list and sum asset values
+17 SET ENNODE="^TMP(""ENSYS"",$J,"""")"
+18 FOR
SET ENNODE=$QUERY(@ENNODE)
if $QSUBSCRIPT(ENNODE,1)_$QSUBSCRIPT(ENNODE,2)'=("ENSYS"_$JOB)
QUIT
Begin DoDot:1
+19 SET ENDA=$QSUBSCRIPT(ENNODE,$QLENGTH(ENNODE))
+20 ; if only capitalized $
IF ENSW["C"
IF $$CHKFA^ENFAUTL(ENDA)'>0
QUIT
+21 SET ENSUM=ENSUM+$PIECE($GET(^ENG(6914,ENDA,2)),U,3)
End DoDot:1
+22 ;
+23 KILL ^TMP("ENSYS",$JOB)
+24 QUIT ENSUM
+25 ;
CHKEXP(ENDA) ; Check if capitalized equipment item should be expensed
+1 ; input ENDA - equipment Entry # if check
+2 ; returns
+3 ; 1 (true) if it should be expensed
+4 ; 0^reason if it should not be expensed due to system criteria
+5 ; U^username if it should not be expensed due to user edit
+6 ;
+7 NEW ENSYS,ENUSER
+8 ; must be reported to Fixed Assets/FMS to be an issue
+9 IF $$CHKFA^ENFAUTL(ENDA)'>0
QUIT "0^NOT CURRENTLY REPORTED TO FAP"
+10 ;
+11 ; does item meet any of the system criteria to remain capitalized?
+12 IF $$GET1^DIQ(6914,ENDA,38)="1524"
QUIT "0^SGL 1524 (EXCESS)"
+13 IF $$GET1^DIQ(6914,ENDA,62)="4539"
QUIT "0^FUND 4539 (FRANCHISE)"
+14 IF $$GET1^DIQ(6914,ENDA,12)>99999.99
QUIT "0^ASSET VALUE > 99999.99"
+15 ; if part of system then check system value
SET ENSYS=$$TOPSYS(ENDA)
+16 IF ENSYS
IF $$SYSVAL(ENSYS,"C")>99999.99
QUIT "0^SYSTEM VALUE > 99999.99"
+17 ;
+18 ; did user specify that item should remain capitalized
+19 SET ENUSER=$$GET1^DIQ(6914,ENDA,99,"E")
+20 IF ENUSER]""
QUIT "U^"_ENUSER
+21 ;
+22 ; item did not meet any of criteria to remain capitalized
+23 QUIT 1
+24 ;
+25 ;ENFACTU