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/bfixedassetassettype.p)
<ANCESTOR-CODE>
assign oiReturnStatus = -98.
/* ============= */
/* Start queries */
/* ============= */
<Q-37 run GLByCode (Start) in BGL >
/* Need to define buffer here, because CB defines buffers on t_o-table. */
def buffer bFAAssetTypeFABook for t_sFAAssetTypeFABook.
for each t_sFAAssetType where
t_sFAAssetType.tc_Status <> 'D':U:
/************************************************************************************************/
/* Catalogues 2 to 6 are NOT mandatory, but no gaps are allowed. */
/* For example, if Catalogue 4 has a value, then so must Catalogues 2 and 3. */
/************************************************************************************************/
assign vcCatCodes[2] = t_sFAAssetType.FAAssetTypeCatalogueCode2
vcCatCodes[3] = t_sFAAssetType.FAAssetTypeCatalogueCode3
vcCatCodes[4] = t_sFAAssetType.FAAssetTypeCatalogueCode4
vcCatCodes[5] = t_sFAAssetType.FAAssetTypeCatalogueCode5
vcCatCodes[6] = t_sFAAssetType.FAAssetTypeCatalogueCode6.
LOOP_CATALOGUES:
do viCatCount = 6 to 2 by -1:
if (vcCatCodes[viCatCount] = '')
then next.
do viCatCount = viCatCount - 1 to 2 by -1:
if (vcCatCodes[viCatCount] = '')
then do:
assign vcFAAssetTypeMsg = #T-7'The list of catalogs cannot contain any gaps.':200(1981)T-7#
oiReturnStatus = -1.
<M-6 run SetMessage
(input trim(vcFAAssetTypeMsg) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'QADFIN-2772':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
leave LOOP_CATALOGUES.
end.
end.
end.
/* ================================================================= */
/* Cumulative Depreciation GL Should be a Standard / Balance account */
/* ================================================================= */
<Q-12 run GLByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sFAAssetType.tcCumulativeDeprGLCode, (GLCode)
output dataset tqGLByCode) in BGL >
find tqGLByCode where
tqGLByCode.tcGLCode = t_sFAAssetType.tcCumulativeDeprGLCode
no-lock no-error.
if available tqGLByCode
then do:
if tqGLByCode.tlGLIsBalanceAccount = false
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-14'The cumulative depreciation GL account (&1) must be a balance sheet account.':200(1990)t-14#))
oiReturnStatus = -1.
<M-15 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcCumulativeDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcCumulativeDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3034':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
if tqGLByCode.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}
then do:
assign vcFAAssetTypeMsg = substitute(#T-51'The GL account (&1) requires both cost center and project analysis. This is not valid for GL accounts with fixed asset definition.':200(15152)T-51#,
trim(t_sFAAssetType.tcCumulativeDeprGLCode))
oiReturnStatus = -1.
<M-52 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcCumulativeDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcCumulativeDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3650':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
if tqGLByCode.tcGLTypeCode <> {&GLTYPECODE-STAN}
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-17'The cumulative depreciation GL account (&1) must be a standard account.':200(1991)t-17#, trim(t_sFAAssetType.tcCumulativeDeprGLCode) ))
oiReturnStatus = -1.
<M-18 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcCumulativeDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcCumulativeDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3035':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
end.
/* ================================================================= */
/* Cost Depreciation GL Should be a Standard / Profit & Loss account */
/* ================================================================= */
<Q-19 run GLByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sFAAssetType.tcCostDeprGLCode, (GLCode)
output dataset tqGLByCode) in BGL >
find tqGLByCode where
tqGLByCode.tcGLCode = t_sFAAssetType.tcCostDeprGLCode
no-lock no-error.
if available tqGLByCode
then do:
if tqGLByCode.tlGLIsBalanceAccount = true
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-21'The cost depreciation GL account (&1) must be a profit and loss account.':200(1992)t-21#, trim(t_sFAAssetType.tcCostDeprGLCode) ))
oiReturnStatus = -1.
<M-22 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcCostDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcCostDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3036':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
if tqGLByCode.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}
then do:
assign vcFAAssetTypeMsg = substitute(#T-54'The GL account (&1) requires both cost center and project analysis. This is not valid for GL accounts with fixed asset definition.':200(15152)T-54#,
trim(t_sFAAssetType.tcCostDeprGLCode))
oiReturnStatus = -1.
<M-53 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcCostDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcCostDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3651':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
if tqGLByCode.tcGLTypeCode <> {&GLTYPECODE-STAN}
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-24'The cost depreciation GL account (&1) must be a standard account.':200(1993)t-24#, trim(t_sFAAssetType.tcCostDeprGLCode) ))
oiReturnStatus = -1.
<M-25 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcCostDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcCostDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3037':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
end.
/* ================================================================= */
/* Revaluation GL Should be a Standard / Balance account */
/* ================================================================= */
<Q-26 run GLByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sFAAssetType.tcRevaluationGLCode, (GLCode)
output dataset tqGLByCode) in BGL >
find tqGLByCode where
tqGLByCode.tcGLCode = t_sFAAssetType.tcRevaluationGLCode
no-lock no-error.
if available tqGLByCode
then do:
if tqGLByCode.tlGLIsBalanceAccount = false
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-28'The revaluation GL account (&1) must be a balance sheet account.':200(1994)t-28#, trim(t_sFAAssetType.tcRevaluationGLCode) ))
oiReturnStatus = -1.
<M-29 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcRevaluationGLCode':U (icFieldName),
input t_sFAAssetType.tcRevaluationGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3038':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
if tqGLByCode.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}
then do:
assign vcFAAssetTypeMsg = substitute(#T-56'The GL account (&1) requires both cost center and project analysis. This is not valid for GL accounts with fixed asset definition.':200(15152)T-56#,
trim(t_sFAAssetType.tcRevaluationGLCode))
oiReturnStatus = -1.
<M-55 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcRevaluationGLCode':U (icFieldName),
input t_sFAAssetType.tcRevaluationGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3652':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
if tqGLByCode.tcGLTypeCode <> {&GLTYPECODE-STAN}
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-31'The revaluation GL account (&1) must be a standard account.':200(1995)t-31#, trim(t_sFAAssetType.tcRevaluationGLCode) ))
oiReturnStatus = -1.
<M-32 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcRevaluationGLCode':U (icFieldName),
input t_sFAAssetType.tcRevaluationGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3039':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
end.
/* ================================================================= */
/* Revaluation Depreciation GL Should be a Standard account */
/* ================================================================= */
<Q-33 run GLByCode (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input t_sFAAssetType.tcRevaluationDeprGLCode, (GLCode)
output dataset tqGLByCode) in BGL >
find tqGLByCode where
tqGLByCode.tcGLCode = t_sFAAssetType.tcRevaluationDeprGLCode
no-lock no-error.
if available tqGLByCode
then do:
if tqGLByCode.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}
then do:
assign vcFAAssetTypeMsg = substitute(#T-57'The GL account (&1) requires both cost center and project analysis. This is not valid for GL accounts with fixed asset definition.':200(15152)T-57#,
trim(t_sFAAssetType.tcRevaluationDeprGLCode))
oiReturnStatus = -1.
<M-58 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcRevaluationDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcRevaluationDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3653':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
if tqGLByCode.tcGLTypeCode <> {&GLTYPECODE-STAN}
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-35'The revaluation depreciation GL account (&1) must be a standard account.':200(1996)t-35#, trim(t_sFAAssetType.tcRevaluationDeprGLCode) ))
oiReturnStatus = -1.
<M-36 run SetMessage
(input vcFAAssetTypeMsg (icMessage),
input '':U (icArguments),
input 'tFAAssetType.tcRevaluationDeprGLCode':U (icFieldName),
input t_sFAAssetType.tcRevaluationDeprGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sFAAssetType.tc_Rowid (icRowid),
input 'QADFIN-3040':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
end.
/************************************************************************************************/
/* The Book of the Official Book Type must be linked to the Asset Type and have Sequence 1. */
/************************************************************************************************/
find first t_sFAAssetTypeFABook where
t_sFAAssetTypeFABook.FAAssetType_ID = t_sFAAssetType.FAAssetType_ID and
t_sFAAssetTypeFABook.FAAssetTypeBookSequence = 1 and
t_sFAAssetTypeFABook.tc_Status <> 'D':U
no-lock no-error.
if not available(t_sFAAssetTypeFABook)
then do:
assign vcFAAssetTypeMsg = substitute(#T-8'An official book must be linked to the asset type (&1). It must have sequence number 1.':200(1982)t-8#,
t_sFAAssetType.FAAssetTypeCode)
oiReturnStatus = -1.
<M-1 run SetMessage
(input trim(vcFAAssetTypeMsg) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'QADFIN-2768':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
else do:
<Q-2 run FABookByIDCodeActiveBookType (first) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (BookID)
input t_sFAAssetTypeFABook.tcFABookCode, (BookCode)
input true, (BookIsActive)
input ?, (BookTypeCode)
input ?, (BookTypeID)
output dataset tqFABookByIDCodeActiveBookType) in BFixedAssetBook >
find first tqFABookByIDCodeActiveBookType where
tqFABookByIDCodeActiveBookType.tcFABookCode = t_sFAAssetTypeFABook.tcFABookCode and
tqFABookByIDCodeActiveBookType.tlFABookIsActive = true and
tqFABookByIDCodeActiveBookType.tlFABookTypeIsOfficial = true
no-lock no-error.
if not available(tqFABookByIDCodeActiveBookType)
then do:
assign vcFAAssetTypeMsg = substitute(#T-9'Sequence 1 should be used for the book of the Official book type.':200(1983)T-9#)
oiReturnStatus = -1.
<M-3 run SetMessage
(input trim(vcFAAssetTypeMsg) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'QADFIN-2769':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
end.
/************************************************************************************************/
/* A Book cannot be linked more than once to the same Asset Type. */
/* Check if all books within an Asset Type have different layers. */
/************************************************************************************************/
assign viBookCount = 0
vcLstLayerCode = "".
for each t_sFAAssetTypeFABook where
t_sFAAssetTypeFABook.tc_Status <> 'D':U and
t_sFAAssetTypeFABook.tc_ParentRowid = t_sFAAssetType.tc_Rowid:
viBookCount = viBookCount + 1.
if can-find( first bFAAssetTypeFABook where
bFAAssetTypeFABook.tc_Status <> 'D':U and
bFAAssetTypeFABook.tc_ParentRowid = t_sFAAssetTypeFABook.tc_ParentRowid and
bFAAssetTypeFABook.FABook_ID = t_sFAAssetTypeFABook.FABook_ID and
bFAAssetTypeFABook.tc_Rowid <> t_sFAAssetTypeFABook.tc_Rowid)
then do:
assign vcFAAssetTypeMsg = trim(substitute(#T-10'A book (&1) cannot be linked twice to the same asset type (&2).':200(1984)T-10#,
trim(t_sFAAssetTypeFABook.tcFABookCode), trim(t_sFAAssetType.FAAssetTypeCode)) )
oiReturnStatus = -1.
<M-4 run SetMessage
(input trim(vcFAAssetTypeMsg) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'QADFIN-2770':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
leave.
end.
<Q-44 run FABookByIDCodeActiveBookType (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (BookID)
input t_sFAAssetTypeFABook.tcFABookCode, (BookCode)
input ?, (BookIsActive)
input ?, (BookTypeCode)
input ?, (BookTypeID)
output dataset tqFABookByIDCodeActiveBookType) in BFixedAssetBook >
find first tqFABookByIDCodeActiveBookType where
tqFABookByIDCodeActiveBookType.tcFABookCode = t_sFAAssetTypeFABook.tcFABookCode
no-lock no-error.
if available(tqFABookByIDCodeActiveBookType)
then do:
if lookup(tqFABookByIDCodeActiveBookType.tcLayerCode, vcLstLayerCode, chr(2)) = 0
then assign vcLstLayerCode = vcLstLayerCode + chr(2) + tqFABookByIDCodeActiveBookType.tcLayerCode.
else do:
assign vcFAAssetTypeMsg = trim(substitute(#T-46'All books linked to asset type '&1' must have a different layer (&2).':200(13803)t-46#,
trim(t_sFAAssetType.FAAssetTypeCode), trim(tqFABookByIDCodeActiveBookType.tcLayerCode) ))
oiReturnStatus = -1.
<M-45 run SetMessage
(input trim(vcFAAssetTypeMsg) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'QADFIN-3115':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
leave.
end.
end.
end.
/************************************************************************************************/
/* No more than 5 Books per Asset Type allowed. */
/************************************************************************************************/
if (viBookCount > 5)
then do:
assign vcFAAssetTypeMsg = substitute(#T-11'You can link a maximum of 5 books to an asset type (&1).':200(1985)t-11#,
t_sFAAssetType.FAAssetTypeCode)
oiReturnStatus = -1.
<M-5 run SetMessage
(input trim(vcFAAssetTypeMsg) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'QADFIN-2771':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetAssetType>
end.
end.
/* ============ */
/* Stop queries */
/* ============ */
<Q-39 run GLByCode (Stop) in BGL >
if oiReturnStatus = -98
then assign oiReturnStatus = 0.