project QadFinancials > class BFixedAssetBookType > method ValidateComponent

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


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bfixedassetbooktype.p)

<ANCESTOR-CODE>

for each t_sFABookType where
         t_sFABookType.tc_Status <> 'D':U:
/*
    /********************************************************************************************/
    /* Verify that only one Official booktype exists.                                           */
    /********************************************************************************************/
    if (t_sFABookType.FABookTypeIsOfficial = true)
    then do:
        <Q-7 run FABookTypeByIDCodeActOff (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input ?, (FABookTypeID)
            input ?, (FABookTypeCode)
            input ?, (FABookTypeIsActive)
            input true, (FABookTypeIsOfficial)
            output dataset tqFABookTypeByIDCodeActOff) in BFixedAssetBookType >

        if can-find (first tqFABookTypeByIDCodeActOff where
                           tqFABookTypeByIDCodeActOff.tlFABookTypeIsOfficial and
                           tqFABookTypeByIDCodeActOff.tiFABookType_ID <> t_sFABookType.FABookType_ID)
        then do:
            assign vcFABookTypeMsg = #T-11'Only one book type can be official.':200(1997)t-11#
                   oiReturnStatus = -1.
            <M-8 run SetMessage
               (input  trim(VcFABookTypeMsg) (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  ? (icRowid), 
                input  'QADFIN-2663':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BFixedAssetBookType>
            next.
        end.
    end.
*/
    /********************************************************************************************/
    /* Depreciation Journal must match BookType's LayerCode.                                    */
    /********************************************************************************************/
    <Q-13 run JournalByJournalIDCodeType (first) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input ?, (JournalID)
        input t_sFABookType.tcDepreciationJournalCode, (JournalCode)
        input ?, (JournalTypeCode)
        output dataset tqJournalByJournalIDCodeType) in BJournal >
    find first tqJournalByJournalIDCodeType where
               tqJournalByJournalIDCodeType.tcJournalCode = t_sFABookType.tcDepreciationJournalCode
               no-lock no-error.
    if available(tqJournalByJournalIDCodeType)
    then do:
        if (tqJournalByJournalIDCodeType.tiLayer_ID <> t_sFABookType.Layer_ID)
        then do:
            assign vcFABookTypeMsg = trim(substitute(#T-14'The depreciation daybook does not match the specified layer.':200(13730)T-14#))
                   oiReturnStatus  = -1.
            <M-15 run SetMessage
               (input  vcFABookTypeMsg (icMessage), 
                input  '':U (icArguments), 
                input  'tFABookType.tcDepreciationJournalCode':U (icFieldName), 
                input  t_sFABookType.tcDepreciationJournalCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sFABookType.tc_Rowid (icRowid), 
                input  'QADFIN-3052':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BFixedAssetBookType>
        end.
    end.


    /********************************************************************************************/
    /* Revaluation Journal must match BookType's LayerCode.                                     */
    /********************************************************************************************/
    <Q-16 run JournalByJournalIDCodeType (first) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input ?, (JournalID)
        input t_sFABookType.tcRevaluationJournalCode, (JournalCode)
        input ?, (JournalTypeCode)
        output dataset tqJournalByJournalIDCodeType) in BJournal >
    find first tqJournalByJournalIDCodeType where
               tqJournalByJournalIDCodeType.tcJournalCode = t_sFABookType.tcRevaluationJournalCode
               no-lock no-error.
    if available(tqJournalByJournalIDCodeType)
    then do:
        if (tqJournalByJournalIDCodeType.tiLayer_ID <> t_sFABookType.Layer_ID)
        then do:
            assign vcFABookTypeMsg = trim(substitute(#T-18'The revaluation daybook does not match the specified layer.':200(13741)T-18#))
                   oiReturnStatus  = -1.
            <M-19 run SetMessage
               (input  vcFABookTypeMsg (icMessage), 
                input  '':U (icArguments), 
                input  'tFABookType.tcRevaluationJournalCode':U (icFieldName), 
                input  t_sFABookType.tcRevaluationJournalCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sFABookType.tc_Rowid (icRowid), 
                input  'QADFIN-3053':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BFixedAssetBookType>
        end.
    end.


    /********************************************************************************************/
    /* Disposal Journal must match BookType's LayerCode.                                        */
    /********************************************************************************************/
    <Q-20 run JournalByJournalIDCodeType (first) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input ?, (JournalID)
        input t_sFABookType.tcDisposalJournalCode, (JournalCode)
        input ?, (JournalTypeCode)
        output dataset tqJournalByJournalIDCodeType) in BJournal >
    find first tqJournalByJournalIDCodeType where
               tqJournalByJournalIDCodeType.tcJournalCode = t_sFABookType.tcDisposalJournalCode
               no-lock no-error.
    if available(tqJournalByJournalIDCodeType)
    then do:
        if (tqJournalByJournalIDCodeType.tiLayer_ID <> t_sFABookType.Layer_ID)
        then do:
            assign vcFABookTypeMsg = trim(substitute(#T-22'The disposal daybook does not match the specified layer.':200(13742)T-22#))
                   oiReturnStatus  = -1.
            <M-23 run SetMessage
               (input  vcFABookTypeMsg (icMessage), 
                input  '':U (icArguments), 
                input  'tFABookType.tcDisposalJournalCode':U (icFieldName), 
                input  t_sFABookType.tcDisposalJournalCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sFABookType.tc_Rowid (icRowid), 
                input  'QADFIN-3054':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BFixedAssetBookType>
        end.
    end.


    /********************************************************************************************/
    /* The Layer of an official BookType should be of the official LayerType.                   */
    /* The Layer of an non-official BookType should be of a non-official LayerType.             */
    /********************************************************************************************/
    <Q-24 run LayerById (all) (Read) (NoCache)
       (input t_sFABookType.Layer_ID, (LayerId)
        output dataset tqLayerById) in BLayer >
    find first tqLayerById where
               tqLayerById.tiLayer_ID = t_sFABookType.Layer_ID
               no-lock no-error.
    if available(tqLayerById)
    then do:
        if t_sFABookType.FABookTypeIsOfficial = true 
        then do:

            if tqLayerById.tcLayerTypeCode <> {&LAYERTYPECODE-OFFICIAL}
            then do:
                assign vcFABookTypeMsg = substitute(#T-28'An official book type must have an official layer type.':200(13749)t-28#)
                       oiReturnStatus  = -1.
                <M-29 run SetMessage
                   (input  trim(vcfaBookTypeMsg) (icMessage), 
                    input  '':U (icArguments), 
                    input  'tFABookType.tcLayerCode':U (icFieldName), 
                    input  t_sFABookType.tcLayerCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sFABookType.tc_Rowid (icRowid), 
                    input  'QADFIN-3057':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BFixedAssetBookType>
            end.
        end.
        else do:
            if tqLayerById.tcLayerTypeCode = {&LAYERTYPECODE-OFFICIAL}
            then do:
                assign vcFABookTypeMsg = substitute(#T-31'A non-official book type must have a non-official layer type.':200(13762)t-31#)
                       oiReturnStatus  = -1.
                <M-32 run SetMessage
                   (input  trim(vcfaBookTypeMsg) (icMessage), 
                    input  '':U (icArguments), 
                    input  'tFABookType.tcLayerCode':U (icFieldName), 
                    input  t_sFABookType.tcLayerCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sFABookType.tc_Rowid (icRowid), 
                    input  'QADFIN-3058':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BFixedAssetBookType>
            end.
        end.
    end.


    /********************************************************************************************/
    /* Verify that the official status hasn't changed for book types that are already being     */
    /* used in a book.                                                                          */
    /********************************************************************************************/
    find first t_iFABookType where
               t_iFABookType.FABookTypeCode = t_sFABookType.FABookTypeCode
               no-lock no-error.
    if available(t_iFABookType) and
       t_iFABookType.FABookTypeIsOfficial <> t_sFABookType.FABookTypeIsOfficial
    then do:
        <Q-9 assign vlFcQueryRecordsAvailable = FABookByIDCodeActiveBookType (NoCache)
           (input viCompanyId, (CompanyId)
            input ?, (BookID)
            input ?, (BookCode)
            input ?, (BookIsActive)
            input t_sFABookType.FABookTypeCode, (BookTypeCode)
            input ?, (BookTypeID)) in BFixedAssetBook >
        if (vlFcQueryRecordsAvailable <> false)
        then do:
            assign vcFABookTypeMsg = substitute(#T-12'Cannot modify the official status for this book type (&1) because it is already used in a book.':200(1998)t-12#,
                                                t_sFABookType.FABookTypeCode)
                   oiReturnStatus = -1.
            <M-10 run SetMessage
               (input  trim(vcfABookTypeMsg) (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  ? (icRowid), 
                input  'QADFIN-2664':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BFixedAssetBookType>
            next.
        end.
    end.
end.