Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bfixedassetrevaluation.p)
<ANCESTOR-CODE>
/*No validations for the records that are being deleted or that have not been modified*/
for each t_sFAReval where
t_sFAReval.tc_Status = "N":U or
t_sFAReval.tc_Status = "C":U
group by t_SFAReval.FAAssetBook_ID:
assign t_sFAReval.FARevalPercentage = if t_sFAReval.FARevalPercentage = ? then 0 else t_sFAReval.FARevalPercentage
t_sFAReval.FARevalIndexType = if t_sFAReval.FARevalIndexType = ? then "":U else t_sFAReval.FARevalIndexType.
/*Error: t_sFAReval.FARevalType = "PERCENTAGE" and t_sFAReval.FARevalPercentage = 0*/
if t_sFAReval.FARevalType = {&FAREVALTYPE-PERCENTAGE} and
t_sFAReval.FARevalPercentage = 0
then do:
assign vcMessage = trim(subst(#T-1'The revaluation percentage cannot be zero if the revaluation type is &1.':200(13874)t-1#,
{&FAREVALTYPE-PERCENTAGE-TR}))
oiReturnStatus = -1.
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tFAReval.FARevalPercentage':U (icFieldName),
input t_sFAReval.FARevalPercentage (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3107':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*Error: t_sFAReval.FARevalType = "VALUE" and t_sFAReval.FARevalAmountLC = 0*/
if t_sFAReval.FARevalType = {&FAREVALTYPE-VALUE} and
t_sFAReval.FARevalAmountLC = 0
then do:
assign vcMessage = trim(subst(#T-4'The revaluation value cannot be zero if the revaluation type is &1.':200(13880)t-4#,
{&FAREVALTYPE-VALUE-TR}))
oiReturnStatus = -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tFAReval.FARevalAmountLC':U (icFieldName),
input t_sFAReval.FARevalAmountLC (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3110':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*Error: The revaluation percentage should be zero when the revaluation type is VALUE*/
if t_sFAReval.FARevalType = {&FAREVALTYPE-VALUE} and
t_sFAReval.FARevalPercentage <> 0
then do:
assign vcMessage = trim(subst(#T-6'The revaluation percentage should be zero when the revaluation type is &1.':200(13881)t-6#,
{&FAREVALTYPE-VALUE-TR}))
oiReturnStatus = -1.
<M-5 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tFAReval.FARevalPercentage':U (icFieldName),
input t_sFAReval.FARevalPercentage (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3112':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*Error: The index revaluation type should be specified when the revaluation type is PERCENTAGE*/
if t_sFAReval.FARevalType = {&FAREVALTYPE-PERCENTAGE} and
t_sFAReval.FARevalIndexType = "":U
then do:
assign vcMessage = trim(subst(#T-8'The index revaluation type should be specified when the revaluation type is &1.':200(13883)t-8#,
{&FAREVALTYPE-PERCENTAGE-TR}))
oiReturnStatus = -1.
<M-7 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tFAReval.FARevalIndexType':U (icFieldName),
input t_sFAReval.FARevalIndexType (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3113':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*Error: The revaluation index type cannot be specified when the revaluation type is VALUE*/
if t_sFAReval.FARevalType = {&FAREVALTYPE-VALUE} and
t_sFAReval.FARevalIndexType <> "":U
then do:
assign vcMessage = trim(subst(#T-10'The index revaluation type cannot be specified when the revaluation type is &1.':200(13884)t-10#,
{&FAREVALTYPE-VALUE-TR}))
oiReturnStatus = -1.
<M-9 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tFAReval.FARevalIndexType':U (icFieldName),
input t_sFAReval.FARevalIndexType (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3114':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*Refresh all AssetBook related data before following validations*/
if first-of (t_sFAReval.FAAssetBook_ID)
then do:
<Q-11 run FAAssetBookByFAReval (all) (Read) (NoCache)
(input t_sFAReval.FAAssetBook_ID, (AssetBookID)
input '':U, (AssetBookCode)
input '':U, (AssetCode)
input ?, (CompanyId)
output dataset tqFAAssetBookByFAReval) in BFixedAssetAsset>
/*the AssetBook should always be found in here, nevetheless I will give an error if not found*/
find first tqFAAssetBookByFAReval no-error.
if not available tqFAAssetBookByFAReval
then do:
<M-13 run SetMessage
(input trim(#T-13'Asset book ($1) not found.':250(2016)t-13#) (icMessage),
input t_sFAReval.FAAssetBook_ID (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-3214':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
assign oiReturnStatus = -1.
return.
end.
else do:
assign t_sFAReval.tcFAAssetBookCode = tqFAAssetBookByFAReval.tcFAAssetBookCode
t_sFAReval.tcFAAssetBookDepreciationType = tqFAAssetBookByFAReval.tcFAAssetBookDeprType
t_sFAReval.tcFAAssetCode = tqFAAssetBookByFAReval.tcFAAssetCode
t_sFAReval.tiFAAsset_ID = tqFAAssetBookByFAReval.tiFAAsset_ID
t_sFAReval.tcFABookTypeCode = tqFAAssetBookByFAReval.tcFABookTypeCode
t_sFAReval.tdFAAssetBookAmountCC = tqFAAssetBookByFAReval.tdFAAssetBookAmountCC
t_sFAReval.tdFAAssetBookAmountLC = tqFAAssetBookByFAReval.tdFAAssetBookAmountLC
t_sFAReval.tdFAAssetBookDeprAmountCC = tqFAAssetBookByFAReval.tdFAAssetBookDeprAmountCC
t_sFAReval.tdFAAssetBookDeprAmountLC = tqFAAssetBookByFAReval.tdFAAssetBookDeprAmountLC
t_sFAReval.tdFAAssetBookDisposedDeprLC = tqFAAssetBookByFAReval.tdFAAssetBookDisposedDeprLC
t_sFAReval.tdFAAssetBookDisposedLC = tqFAAssetBookByFAReval.tdFAAssetBookDisposedLC
t_sFAReval.tdFAAssetBookSalvageAmountCC = tqFAAssetBookByFAReval.tdFAAssetBookSalvageAmountCC
t_sFAReval.tdFAAssetBookSalvageAmountLC = tqFAAssetBookByFAReval.tdFAAssetBookSalvageAmountLC.
end.
end.
/*Error: Asset should be capitalized*/
if not tqFAAssetBookByFAReval.tlFAAssetIsCapitalized
then do:
assign vcMessage = trim(subst(#T-16'An asset can only be revaluated if it is capitalized (asset: &1).':200(14137)T-16#,
trim(t_sFAReval.tcFAAssetCode)))
oiReturnStatus = -1.
<M-14 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tFAReval.tcFAAssetCode':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3216':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*Error: Asset cannot be disposed*/
if tqFAAssetBookByFAReval.tlFAAssetBookIsDisposed
then do:
assign vcMessage = trim(subst(#T-17'An asset book can only be revaluated if it is not yet disposed (asset book: &1).':200(14138)T-17#,
trim(t_sFAReval.tcFAAssetBookCode)))
oiReturnStatus = -1.
<M-15 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tFAReval.tcFAAssetBookCode':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3217':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*Warning: Parent asset of that asset is not being revaluated.
check only the instance data no DB*/
if tqFAAssetBookByFAReval.tcParentAssetCode <> "":U and
tqFAAssetBookByFAReval.tcParentAssetCode <> ? and
not can-find (t_sFAReval where
t_sFAReval.tcFAAssetCode = tqFAAssetBookByFAReval.tcParentAssetCode)
then do:
assign vcMessage = trim(subst(#T-18'Asset code &1 is a child of asset code &2 which is not being revaluated in this run.':200(14140)t-18#,
trim(t_sFAReval.tcFAAssetCode),
trim(tqFAAssetBookByFAReval.tcParentAssetCode)))
oiReturnStatus = if oiReturnStatus = 0
then 1
else oiReturnStatus.
<M-19 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sFAReval.tc_Rowid (icRowid),
input 'QADFIN-3219':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
end.