project QadFinancials > class BFixedAssetRevaluation > method RevaluationCreateDetSafForRevalAccount

Description

Creates tFARevalDetSaf records for the revaluation account


Parameters


icParentRowidinputcharacterparent rowid
iiFAAssetGLIdinputintegerFAAssetGLId
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BFixedAssetRevaluation.RevaluationCreate


program code (program3/bfixedassetrevaluation.p)

if  not can-find (first tNoFAAssetGLSaf where
                        tNoFAAssetGLSaf.tiFAAssetGL_ID = iiFAAssetGLId) and
    not can-find (first tqFAAssetGLSafByAssetGLId where
                        tqFAAssetGLSafByAssetGLId.tiFAAssetGL_ID = iiFAAssetGLId)
then do:  
    <Q-6 run FAAssetGLSafByAssetGLId (all) (Read) (NoCache)
          (input iiFAAssetGLId, (FAAssetGLId)
           output dataset tqFAAssetGLSafByAssetGLId) in BFixedAssetAsset >
                                   
    find first tqFAAssetGLSafByAssetGLId no-error.
    if not available tqFAAssetGLSafByAssetGLId 
    then do:
        create tNoFAAssetGLSaf.
        assign tNoFAAssetGLSaf.tiFAAssetGL_ID = iiFAAssetGLId.
    end.
end.
for each tqFAAssetGLSafByAssetGLId where
         tqFAAssetGLSafByAssetGLId.tiFAAssetGL_ID = iiFAAssetGLId:
    <M-2 run AddDetailLine (input  'FARevalDetSaf':U (icTable), 
                        input  icParentRowid (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.

    assign tFARevalDetSaf.FARevalDetSafParentType = tqFAAssetGLSafByAssetGLId.tcFAAssetGLSafParentType
           tFARevalDetSaf.FARevalDetSafSequence   = tqFAAssetGLSafByAssetGLId.tiFAAssetGLSafInputSeq.
    
    /*Unfortunately Calculate does not work for newly created records 
    therefore we have to do the Id-Code conversion ourselves (results of the following Prim queries will be cached)*/
    /*Saf*/
    if tqFAAssetGLSafByAssetGLId.tiSaf_ID > 0
    then do:
        find first tqSafPrim where
                   tqSafPrim.tiSaf_ID = tqFAAssetGLSafByAssetGLId.tiSaf_ID no-error.
        if not available tqSafPrim 
        then do:
            <Q-4 run SafPrim (all) (Read) (NoCache)
          (input tqFAAssetGLSafByAssetGLId.tiSaf_ID, (SafID)
           input '':U, (SafCode)
           input '':U, (SafConceptCode)
           output dataset tqSafPrim) in BSaf >
        end.               
        find first tqSafPrim where
                   tqSafPrim.tiSaf_ID = tqFAAssetGLSafByAssetGLId.tiSaf_ID no-error.
    end.
    assign tFARevalDetSaf.tcSafCode         = if available tqSafPrim then tqSafPrim.tcSafCode else "":U
           tFARevalDetSaf.tcSafConceptCode  = if available tqSafPrim then tqSafPrim.tcSafConceptCode else "":U.
    /*SafStructure*/
    if tqFAAssetGLSafByAssetGLId.tiSafStructure_ID > 0
    then do:
        find first tqSafStructurePrim where
                   tqSafStructurePrim.tiSafStructure_ID = tqFAAssetGLSafByAssetGLId.tiSafStructure_ID no-error.
        if not available tqSafStructurePrim 
        then do:
            <Q-5 run SafStructurePrim (all) (Read) (NoCache)
          (input tqFAAssetGLSafByAssetGLId.tiSafStructure_ID, (SafStructureID)
           input '':U, (SafStructureCode)
           output dataset tqSafStructurePrim) in BSafStructure >
        end.               
        find first tqSafStructurePrim where
                   tqSafStructurePrim.tiSafStructure_ID = tqFAAssetGLSafByAssetGLId.tiSafStructure_ID no-error.
    end.
    assign tFARevalDetSaf.tcSafStructureCode = if available tqSafStructurePrim then tqSafStructurePrim.tcSafStructureCode else "":U.
end.