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

ENFACTU.m

Go to the documentation of this file.
  1. ENFACTU ;(WCIOFO)/SAB-FAP CAPITALIZATION THRESHOLD UTILITIES ;5/22/2002
  1. ;;7.0;ENGINEERING;**63,71**;August 17, 1993
  1. TOPSYS(ENDA) ; Topmost System
  1. ; input ENDA - equipment entry #
  1. ; returns
  1. ; entry # of topmost equipment in system of which ENDA is a part
  1. ; OR 0 if ENDA is not part of a system (parent or component)
  1. ; OR ?^message if error detected
  1. ;
  1. N ENDAC,ENDAP,ENPL,ENRET
  1. S ENRET=""
  1. ;
  1. ; start with ENDA as component and determine top-most item in system
  1. S ENPL=U ; init list of parents (used for detection of endless loop)
  1. S ENDAC=ENDA ; start with ENDA as a component
  1. ; traverse parent chain
  1. F S ENDAP=$P($G(^ENG(6914,ENDAC,0)),U,3) Q:ENDAP=""!(ENPL[(U_ENDAP_U)) S ENDAC=ENDAP,ENPL=ENPL_ENDAP_U
  1. I ENDAP]"" S ENRET="?^ENDLESS LOOP DETECTED"
  1. ;
  1. ; use topmost parent if found
  1. I ENRET="",ENDAC'=ENDA S ENRET=ENDAC
  1. ; if not component then is item a parent?
  1. I ENRET="",$O(^ENG(6914,"AE",ENDA,""))]"" S ENRET=ENDA
  1. ; must not be part of system
  1. I ENRET="" S ENRET=0
  1. ;
  1. Q ENRET
  1. ;
  1. SYSVAL(ENDAT,ENSW) ; System Value
  1. ; input ENDAT - entry # parent for system
  1. ; ENSW - optional switch
  1. ; contains "C" if only capitalized values should be
  1. ; included in return value
  1. ; returns sum of asset values for parent and all it's components
  1. ;
  1. N ENDA,ENMD,ENNODE,ENSUM,ENDA
  1. S ENSW=$G(ENSW)
  1. S ENSUM=0
  1. ;
  1. ; build list of all items in the system
  1. K ^TMP("ENSYS",$J)
  1. S ENMD=1
  1. D GETC^ENEQRP6(ENDAT,"","^TMP(""ENSYS"",$J,")
  1. ;
  1. ; loop thru all equipment on system list and sum asset values
  1. S ENNODE="^TMP(""ENSYS"",$J,"""")"
  1. F S ENNODE=$Q(@ENNODE) Q:$QS(ENNODE,1)_$QS(ENNODE,2)'=("ENSYS"_$J) D
  1. . S ENDA=$QS(ENNODE,$QL(ENNODE))
  1. . I ENSW["C",$$CHKFA^ENFAUTL(ENDA)'>0 Q ; if only capitalized $
  1. . S ENSUM=ENSUM+$P($G(^ENG(6914,ENDA,2)),U,3)
  1. ;
  1. K ^TMP("ENSYS",$J)
  1. Q ENSUM
  1. ;
  1. CHKEXP(ENDA) ; Check if capitalized equipment item should be expensed
  1. ; input ENDA - equipment Entry # if check
  1. ; returns
  1. ; 1 (true) if it should be expensed
  1. ; 0^reason if it should not be expensed due to system criteria
  1. ; U^username if it should not be expensed due to user edit
  1. ;
  1. N ENSYS,ENUSER
  1. ; must be reported to Fixed Assets/FMS to be an issue
  1. I $$CHKFA^ENFAUTL(ENDA)'>0 Q "0^NOT CURRENTLY REPORTED TO FAP"
  1. ;
  1. ; does item meet any of the system criteria to remain capitalized?
  1. I $$GET1^DIQ(6914,ENDA,38)="1524" Q "0^SGL 1524 (EXCESS)"
  1. I $$GET1^DIQ(6914,ENDA,62)="4539" Q "0^FUND 4539 (FRANCHISE)"
  1. I $$GET1^DIQ(6914,ENDA,12)>99999.99 Q "0^ASSET VALUE > 99999.99"
  1. S ENSYS=$$TOPSYS(ENDA) ; if part of system then check system value
  1. I ENSYS,$$SYSVAL(ENSYS,"C")>99999.99 Q "0^SYSTEM VALUE > 99999.99"
  1. ;
  1. ; did user specify that item should remain capitalized
  1. S ENUSER=$$GET1^DIQ(6914,ENDA,99,"E")
  1. I ENUSER]"" Q "U^"_ENUSER
  1. ;
  1. ; item did not meet any of criteria to remain capitalized
  1. Q 1
  1. ;
  1. ;ENFACTU