Description
Creates tFARevalDetSaf records for fixed asset account
Parameters
icParentRowid | input | character | |
iiFAAssetId | input | integer | Asset ID |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bfixedassetrevaluation.p)
if not can-find (first tNoFAAssetSaf where
tNoFAAssetSaf.tiFAAsset_ID = iiFAAssetId) and
not can-find (first tqFAAssetSafByAsset where
tqFAAssetSafByAsset.tiFAAsset_ID = iiFAAssetId)
then do:
<Q-1 run FAAssetSafByAsset (all) (Read) (Cache)
(input iiFAAssetId, (FAAssetId)
output dataset tqFAAssetSafByAsset) in BFixedAssetAsset >
find first tqFAAssetSafByAsset no-error.
if not available tqFAAssetSafByAsset
then do:
create tNoFAAssetSaf.
assign tNoFAAssetSaf.tiFAAsset_ID = iiFAAssetId.
end.
end.
for each tqFAAssetSafByAsset where
tqFAAssetSafByAsset.tiFAAsset_ID = iiFAAssetId:
<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 = tqFAAssetSafByAsset.tcFAAssetSafParentType
tFARevalDetSaf.FARevalDetSafSequence = tqFAAssetSafByAsset.tiFAAssetSafInputSequence.
/*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 tqFAAssetSafByAsset.tiSaf_ID > 0
then do:
find first tqSafPrim where
tqSafPrim.tiSaf_ID = tqFAAssetSafByAsset.tiSaf_ID no-error.
if not available tqSafPrim
then do:
<Q-4 run SafPrim (all) (Read) (NoCache)
(input tqFAAssetSafByAsset.tiSaf_ID, (SafID)
input '':U, (SafCode)
input '':U, (SafConceptCode)
output dataset tqSafPrim) in BSaf >
end.
find first tqSafPrim where
tqSafPrim.tiSaf_ID = tqFAAssetSafByAsset.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 tqFAAssetSafByAsset.tiSafStructure_ID > 0
then do:
find first tqSafStructurePrim where
tqSafStructurePrim.tiSafStructure_ID = tqFAAssetSafByAsset.tiSafStructure_ID no-error.
if not available tqSafStructurePrim
then do:
<Q-5 run SafStructurePrim (all) (Read) (NoCache)
(input tqFAAssetSafByAsset.tiSafStructure_ID, (SafStructureID)
input '':U, (SafStructureCode)
output dataset tqSafStructurePrim) in BSafStructure >
end.
find first tqSafStructurePrim where
tqSafStructurePrim.tiSafStructure_ID = tqFAAssetSafByAsset.tiSafStructure_ID no-error.
end.
assign tFARevalDetSaf.tcSafStructureCode = if available tqSafStructurePrim then tqSafStructurePrim.tcSafStructureCode else "":U.
end.