project QadFinancials > class BCompany > method PreValidateComponent

Description

Validations for company that are run before the ancestor code of the validatecomponent.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method BCompany.ValidateComponent


program code (program/bcompany.p)

for each t_sCompany where
        t_sCompany.tc_Status = "D":U:
        assign oiReturnStatus = -1
            vcMessage = #T-38'You cannot delete an entity.':100(31959)t-38#.
        <M-36 run SetMessage (input  vcMessage (icMessage), 
                      input  '':U (icArguments), 
                      input  '':U (icFieldName), 
                      input  '':U (icFieldValue), 
                      input  'E':U (icType), 
                      input  1 (iiSeverity), 
                      input  t_sCompany.tc_rowid (icRowid), 
                      input  'QadFin-4922':U (icFcMsgNumber), 
                      input  '' (icFcExplanation), 
                      input  '' (icFcIdentification), 
                      input  '' (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BCompany> 
        return.
    end.
    
    for each t_sCompany where
        t_sCompany.tc_Status = "N":U or 
        t_sCompany.tc_Status = "C":U:
        if t_sCompany.tcDomainCode = "":U or
            t_sCompany.tcDomainCode = ?
        then do:     
            assign oiReturnStatus = -1
                vcMessage = #T-40'You must specify a domain for entity ($1).':200(49195)t-40#.
            <M-39 run SetMessage (input  vcMessage (icMessage), 
                      input  t_sCompany.CompanyCode (icArguments), 
                      input  '':U (icFieldName), 
                      input  '':U (icFieldValue), 
                      input  'E':U (icType), 
                      input  1 (iiSeverity), 
                      input  t_sCompany.tc_rowid (icRowid), 
                      input  'QadFin-5375':U (icFcMsgNumber), 
                      input  '' (icFcExplanation), 
                      input  '' (icFcIdentification), 
                      input  '' (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BCompany>
            return. 
        end.    
    end.

    
    /* =============================== */
    /* Actions for the CompanyProperty */
    /* =============================== */
    for each t_sCompanyPropertyRef where
             t_sCompanyPropertyRef.tc_status = "N":U or
             t_sCompanyPropertyRef.tc_status = "C":U:
        if t_sCompanyPropertyRef.tcBusinessRelationCode <> "":U and
           t_sCompanyPropertyRef.tcBusinessRelationCode <> ?    and
           t_sCompanyPropertyRef.tcBusinessRelationCode <> "?":U
        then do:
            /* check whether the entered code is valid */
            <Q-5 run BusinessRelationPrim (all) (Read) (NoCache)
          (input ?, (BusinessRelationId)
           input t_sCompanyPropertyRef.tcBusinessRelationCode, (BusinessRelationCode)
           output dataset tqBusinessRelationPrim) in BBusinessRelation >
            find first tqBusinessRelationPrim no-error.
            if available tqBusinessRelationPrim
            then assign t_sCompanyPropertyRef.BusinessRelation_ID = tqBusinessRelationPrim.tiBusinessRelation_ID.
            else do:
                <M-6 run SetMessage
          (input  #T-9'The specified business relation code is not defined in the system.':100(1292)t-9# (icMessage), 
           input  '':U (icArguments), 
           input  'tCompanyPropertyRef.tcBusinessRelationCode':U (icFieldName), 
           input  t_sCompanyPropertyRef.tcBusinessRelationCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sCompanyPropertyRef.tc_rowid (icRowid), 
           input  'QADFIN-244':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BCompany>    
                assign oiReturnStatus = -1.
            end.
        end.
    end. /* for each t_sCompanyPropertyRef where */
                       
    <M-26 run ValidateComponentSSChange (output viFcReturnSuper (oiReturnStatus)) in BCompany>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.  

    <ANCESTOR-CODE>

    /* ===================================================================================== */
    /* Addtional Validation :                                                                */
    /* In case CompanyProperty.tcActCostPostingJournalCode is specified, then it will be used to state       */
    /* CompanyProperty.Journal_ID in BCompanyProperty using the RKBF-mechanism. Within       */
    /* this mechanism, the SharedSet that is used in combination with JournalCode to         */
    /* state the Journal_ID is the SharedSet (of type JOURNAL) of the company where          */
    /* the user is logged in.                                                                */
    /* To state the correct Journal_ID, the SharedSet of the new company that is created     */
    /* should be used instead of the SharedSet of the company where the user is logged in.   */
    /* Solution:                                                                             */
    /* The JournalCode may only be passed in case the Jrnl-SharedSet of the new company      */
    /* that is created equals the Jrnl-SharedSet of the company where the user is logged in. */
    /* ===================================================================================== */
    assign vcCurrentJournalSharedSetCode = "":U.
    for each t_sCompany where 
             t_sCompany.tc_Status <> "D":U no-lock,
        each tCompanyPropertyRef where 
             tCompanyPropertyRef.tc_ParentRowid  = t_sCompany.tc_Rowid and 
             tCompanyPropertyRef.tcActCostPostingJournalCode  <> "":U              and 
             tCompanyPropertyRef.tcActCostPostingJournalCode  <> ? no-lock, 
        each t_sCompanySharedSet where 
             t_sCompanySharedSet.tc_ParentRowid      = t_sCompany.tc_Rowid and 
             t_sCompanySharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-JOURNAL} no-lock :
        /* Get the SS of the current company */
        if vcCurrentJournalSharedSetCode = "":U
        then do :
            <Q-7 run CompanySSByCompanyIDCodeSSType (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input {&SHAREDSETTYPECODE-JOURNAL}, (SharedSetType)
           input '':U, (CompanyCode)
           output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany >
            find first tqCompanySSByCompanyIDCodeSSType no-lock no-error.
            if available tqCompanySSByCompanyIDCodeSSType
            then assign vcCurrentJournalSharedSetCode = tqCompanySSByCompanyIDCodeSSType.tcSharedSetCode
                        vcCurrentCompanyCode          = tqCompanySSByCompanyIDCodeSSType.tcCompanyCode.
            else assign vcCurrentJournalSharedSetCode = "?":U.
        end. /* if vcCurrentJournalSharedSetCode = "":U */
        /* Check */
        find first t_iCompanySharedSet where
                   t_iCompanySharedSet.tc_Rowid = t_sCompanySharedSet.tc_Rowid
                   no-error.
        if (t_sCompany.tc_Status = "N":U or
            (available t_iCompanySharedSet and
             t_iCompanySharedSet.tcSharedSetCode <> t_sCompanySharedSet.tcSharedSetCode) ) and
          (t_sCompanySharedSet.tcSharedSetCode <> vcCurrentJournalSharedSetCode )
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(substitute(#T-12'You can only specify the daybook (&1) for the current entity.':255(1295)t-12#,tCompanyPropertyRef.tcActCostPostingJournalCode)) + chr(10) + 
                                    trim(substitute(#T-13'The daybook can be modified while you are logged in entity '&1'.':255(1296)T-13#,t_sCompany.CompanyCode)) + chr(10) +
                                    trim(substitute(#T-14'Current entity: &1.':255(1297)T-14#,vcCurrentCompanyCode)) + chr(10) + 
                                    trim(substitute(#T-15'Current entity (daybook shared set): &1.':255(1298)T-15#,vcCurrentJournalSharedSetCode)) + chr(10) + 
                                    trim(substitute(#T-16'Changing entity: &1.':255(1299)T-16#,t_sCompany.CompanyCode)) + chr(10) + 
                                    trim(substitute(#T-17'Changing entity (daybook shared set): &1.':255(1300)T-17#,t_sCompanySharedSet.tcSharedSetCode)).
            <M-8 run SetMessage (input  vcMessage (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  tCompanyPropertyRef.tcActCostPostingJournalCode (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  t_sCompany.tc_rowid (icRowid), 
                     input  'QADFIN-2876':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BCompany>  
        end. /* if t_sCompanySharedSet.tcSharedSetCode <> vcCurrentJournalSharedSetCode */
    end. /* for each t_sCompany */
    
    <M-23 run ValidateComponentCheckSecurity (output viFcReturnSuper (oiReturnStatus)) in BCompany>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.