project QadFinancials > class BCompany > method ValidateComponentSSChange

Description

This method will check whether or not shared sets for a certain company can be changed or not.
This is part of the validations that is done before the ancestor code of ValidateComponent.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCompany.PreValidateComponent


program code (program1/bcompany.p)

for each t_sCompany:
    find t_iCompany where 
         t_iCompany.Company_ID = t_sCompany.Company_ID 
         no-error.    
    if available t_iCompany and 
       t_iCompany.Domain_ID <> t_sCompany.Domain_ID 
    then do:

        /* Validate whether the journal shared set can be changed */
        for each t_sCompanySharedSet where
                 t_sCompanySharedSet.Company_ID = t_sCompany.Company_ID and
                 t_sCompanySharedSet.tc_Status = "C":U:
            
            /* Skip those that haven't been changed... */
            find t_iCompanySharedSet where 
                 t_iCompanySharedSet.tc_Rowid = t_sCompanySharedSet.tc_Rowid.
            if t_sCompanySharedSet.SharedSet_ID = t_iCompanySharedSet.SharedSet_ID 
            then next.
            
            case(t_sCompanySharedSet.tcSharedSetTypeCode):
                            
                when {&SHAREDSETTYPECODE-JOURNAL} 
                then do:
                    /* Check Allocation Table */
                    <Q-38 assign vlFcQueryRecordsAvailable = AllocationPrim (NoCache)
                       (input t_sCompany.Company_ID, (CompanyId)
                        input ?, (AllocationId)
                        input ?, (AllocationCode)) in BAllocation >
                
                    /* The query returns false if there are no records, true is there is no record and ? is there are multiple records */
                    /* So if the query returns <> false, it means that there are 1 or more records */
                    if vlFcQueryRecordsAvailable <> false 
                    then do:
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-1'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-1#,
                                                      #T-2'Daybook':10(14857)T-2#,
                                                      #T-3'Allocation':20(13236)T-3#,
                                                      t_sCompany.CompanyCode).
                    
                        <M-39 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4831':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end. /* if vlFcQueryRecordsAvailable <> false */
            
                    /* Check CDocumentStatus Table */
                    <Q-82 assign vlFcQueryRecordsAvailable = CDocumentStatusPrim (NoCache)
                       (input '':U, (CDocumentStatusID)
                        input '':U, (CDocumentStatusStatus)
                        input '':U, (CDocumentStatusDocumentType)
                        input t_sCompany.Company_ID, (CompanyId)
                        input '':U, (BankGLCode)) in BCDocumentStatus >                    
                                                     
                    if vlFcQueryRecordsAvailable <> false 
                    then do:
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                                vcMessage     = substitute(#T-4'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-4#,
                                                           #T-5'Daybook':10(14857)T-5#,
                                                           #T-6'Supplier Payment Status':30(5131)T-6#,
                                                           t_sCompany.CompanyCode).
                        
                        <M-41 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4832':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>                    
                    end. /* if vlFcQueryRecordsAvailable <> false */
            
            
                    /* Check DDocumentStatus Table */
                    <Q-81 assign vlFcQueryRecordsAvailable = DDocumentStatusPrim (NoCache)
                       (input ?, (DDocumentStatusID)
                        input ?, (DDocumentStatusStatus)
                        input ?, (DDocumentStatusDocumentType)
                        input ?, (BankGLCode)
                        input t_sCompany.Company_ID, (CompanyId)) in BDDocumentStatus >

                    if vlFcQueryRecordsAvailable <> false 
                    then do:                    
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-7'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-7#,
                                                      #T-8'Daybook':10(14857)T-8#,
                                                      #T-9'Customer Payment Status':27(5130)T-9#,
                                                      t_sCompany.CompanyCode).
                    
                        <M-43 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4833':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end. /* if vlFcQueryRecordsAvailable <> false */
            
                    /* Check RecEntry Table */
                    <Q-80 assign vlFcQueryRecordsAvailable = RecEntryPrim (NoCache)
                       (input t_sCompany.Company_ID, (CompanyId)
                        input ?, (RecEntryCode)
                        input ?, (RecEntryID)) in BRecurringEntry >
                    if vlFcQueryRecordsAvailable <> false 
                    then do:                    
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-10'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-10#,
                                                      #T-11'Daybook':10(14857)T-11#,
                                                      #T-12'Recurring Entries':30(17516)T-12#,
                                                      t_sCompany.CompanyCode).
                    
                        <M-45 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4834':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end. /* if vlFcQueryRecordsAvailable <> false */
            
                    /* Check FABookType Table */
                    <Q-83 assign vlFcQueryRecordsAvailable = FAAssetTypePrim (NoCache)
                       (input t_sCompany.Company_ID, (CompanyId)
                        input 0, (FAAssetTypeID)
                        input '':U, (FAAssetTypeCode)) in BFixedAssetAssetType >                    
                    if vlFcQueryRecordsAvailable <> false 
                    then do:                    
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-13'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-13#,
                                                      #T-14'Daybook':10(14857)T-14#,
                                                      #T-15'Fixed Asset Book Type':100(31358)T-15#,
                                                      t_sCompany.CompanyCode).
                    
                        <M-47 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4835':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>                    
                    end. /* if vlFcQueryRecordsAvailable <> false */
                end. /* when {&SHAREDSETTYPECODE-JOURNAL}*/
            
                /* Validate whether the account shared set can be changed */
                when {&SHAREDSETTYPECODE-GL} 
                then do:                                                  
                    /* Check FAAssetType Table */
                    <Q-50 assign vlFcQueryRecordsAvailable = FAAssetTypeFABookByType (NoCache)
                       (input t_sCompany.Company_ID, (CompanyId)
                        input ?, (FAAssetTypeID)
                        input '':U, (FAAssetTypeCode)) in BFixedAssetAssetType >
                                       
                    if vlFcQueryRecordsAvailable <> false 
                    then do:                    
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-19'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-19#,
                                                      #T-20'Account':20(20115)T-20#,
                                                      #T-21'Fixed Assets Asset Type':50(31377)T-21#,
                                                      t_sCompany.CompanyCode).            
                        <M-51 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4837':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end. /* if vlFcQueryRecordsAvailable <> false */
                  
                    /* Check FACapital Table */
                    <Q-52 assign vlFcQueryRecordsAvailable = FACapitalByFACapitalID (NoCache)
                       (input t_sCompany.Company_ID, (CompanyId)
                        input ?, (FACapital_ID)
                        input ?, (PostingLine_ID)
                        input ?, (AccYear)
                        input ?, (AccPeriod)
                        input '':U, (JournalCode)
                        input ?, (Voucher)
                        input ?, (Sequence)) in BFixedAssetCapital >
                                                                             
                    if vlFcQueryRecordsAvailable <> false 
                    then do:
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-22'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-22#,
                                                      #T-23'Account':20(20115)T-23#,
                                                      #T-24'Fixed Asset Capitalization':40(31316)T-24#,
                                                      t_sCompany.CompanyCode).
                        <M-54 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4839':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end. /* if vlFcQueryRecordsAvailable <> false */
                end. /* when {&SHAREDSETTYPECODE-GL} */
                
                /* Validate whether the Cost Center shared set can be changed */
                when {&SHAREDSETTYPECODE-COSTCENTRE} or
                when {&SHAREDSETTYPECODE-PROJECT} 
                then do:
                    /* Check ConsolidCycle Table */
                    <Q-84 assign vlFcQueryRecordsAvailable = ConsolidCycleByCompanyID (NoCache)
                       (input t_sCompany.Company_ID, (CompanyId)) in BConsolidCycle >                    
                    
                    if vlFcQueryRecordsAvailable <> false 
                    then do:
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-28'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-28#,
                                                      if(t_sCompanySharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-COSTCENTRE}) then (#T-29'Cost Center':40(20365)T-29#)
                                                      else (#T-66'Project':20(8836)T-66#),
                                                      #T-30'Consolidation Cycle':30(5136)T-30#,
                                                      t_sCompany.CompanyCode).
                        <M-57 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4841':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end. /* if vlFcQueryRecordsAvailable <> false */  
                end. /* when {&SHAREDSETTYPECODE-COSTCENTRE} */
        
                /* Validate whether the Creditor shared set can be changed */
                when {&SHAREDSETTYPECODE-CREDITOR} 
                then do:
                    /* Check Employee Table */
                     <Q-61 assign vlFcQueryRecordsAvailable = EmployeePrim (NoCache)
                        (input ?, (EmployeeId)
                         input '':U, (EmployeeCode)
                         input t_sCompany.Company_ID, (CompanyId)) in BEmployee >
            
                    if vlFcQueryRecordsAvailable <> false 
                    then do:                    
                        assign oiReturnStatus = -1 when oiReturnStatus > -1
                               vcMessage = substitute(#T-31'&1 shared set cannot be modified. There are existing records in the &2 table for the entity &3.':100(31357)t-31#,
                                                      #T-32'Supplier':40(20551)T-32#,
                                                      #T-33'Employee':20(5063)T-33#,
                                                      t_sCompany.CompanyCode).
                        <M-58 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4842':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end. /* if vlFcQueryRecordsAvailable <> false */
                end. /* when {&SHAREDSETTYPECODE-CREDITOR} */
        
                /* Validate whether the Project shared set can be changed */
                when {&SHAREDSETTYPECODE-GL} 
                then do:
                     <Q-77 assign vlFcQueryRecordsAvailable = DomainPropertyForInterCo (NoCache)
                        (input t_sCompany.Domain_ID, (Domain_ID)) in BDomainProperty >
                     
                     if vlFcQueryRecordsAvailable 
                     then do:
                         assign oiReturnStatus = -1 when oiReturnStatus > -1
                                vcMessage = substitute(#T-79'You cannot modify the &1 shared set. Intercompany accounts are set up on the domain for entity &2.':100(59493)t-79#,
                                                       (#T-74'Account':20(20115)T-74#),
                                                       t_sCompany.CompanyCode).
                        <M-71 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tCompanySharedSet.tcSharedSetCode':U (icFieldName), 
                            input  t_sCompanySharedSet.tcSharedSetCode (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sCompanySharedSet.tc_Rowid (icRowid), 
                            input  'QadFin-4847':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BCompany>
                    end.
                end. /* when {&SHAREDSETTYPECODE-COSTCENTRE} or */
            end case.
        end. /* for each t_sCompanySharedSet */      
    end. /* if available t_iCompany */
end. /* for each t_sCompany */