project QadFinancials > class BCompanyProperty > method ValidateComponentModify

Description

Validations whether or not some fields can still be updated.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCompanyProperty.ValidateComponent


program code (program3/bcompanyproperty.p)

/* modification of currency cannot be applied if it is being used */
for each t_sCompanyProperty WHERE
         t_sCompanyProperty.tc_Status = "C":U:
    find first t_iCompanyProperty where
               t_iCompanyProperty.tc_Rowid = t_sCompanyProperty.tc_Rowid
               no-error.
    if not available t_iCompanyProperty
    then next.

    if t_iCompanyProperty.tcCurrencyCode <> t_sCompanyProperty.tcCurrencyCode
    then do:
         <Q-3 assign vlFcQueryRecordsAvailable = ConsolidDumpByCompany (NoCache)  (input t_sCompanyProperty.Company_ID, (CompanyId)) in BConsolidDump >
         
         if vlFcQueryRecordsAvailable <> false then do:
         
            assign vcMessage      = substitute(
                trim(#T-1'Currency cannot be changed. Records exist in the &1 table for entity &2':100(31315)T-1#),
                 #T-4'Consolidation Export':30(31314)T-4#)
                   oiReturnStatus = -1.
         end.
         else do:
             <Q-6 assign vlFcQueryRecordsAvailable = SelectFACapital (NoCache)  (input t_sCompanyProperty.Company_ID, (CompanyId)) in BFixedAssetCapital >
             
             if vlFcQueryRecordsAvailable <> false then do:
         
                assign vcMessage      = substitute(
                    trim(#T-11'Currency cannot be changed. Records exist in the &1 table for entity &2':100(31315)T-11#),
                     #T-8'Fixed Asset Capitalization':40(31316)T-8#)
                       oiReturnStatus = -1.
             end.
         end.             
    end.
    
    if oiReturnStatus < 0 then do:
        <Q-9 run CompanyPrim (all) (Read) (NoCache)
          (input t_sCompanyProperty.Company_ID, (LookupCompanyId)
           input '':U, (CompanyCode)
           output dataset tqCompanyPrim) in BCompany >
        find tqCompanyPrim where tqCompanyPrim.tiCompany_ID = t_sCompanyProperty.Company_ID. 
        if available tqCompanyPrim 
        then assign vcMessage = substitute(vcMessage, tqCompanyPrim.tcCompanyCode).
         
        <M-10 run SetMessage (input  vcMessage (icMessage), 
             input  '':U (icArguments), 
             input  'tCompanyProperty.tcCurrencyCode':U (icFieldName), 
             input  t_sCompanyProperty.tcCurrencyCode (icFieldValue), 
             input  'E':U (icType), 
             input  3 (iiSeverity), 
             input  t_sCompanyProperty.tc_Rowid (icRowid), 
             input  'QadFin-4845':U (icFcMsgNumber), 
             input  '' (icFcExplanation), 
             input  '' (icFcIdentification), 
             input  '' (icFcContext), 
             output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
             
        return.
    end.

    /* Validation of If CompanyPropertyMirrorSetup was changed from COMPANY or DOMAIN to NONE, we need to check in the DayBook and Default Daybook setup */
    if t_iCompanyProperty.CompanyPropertyMirrorSetup <> {&COMPANYPROPERTYMIRRORSETUP-NONE} and
         t_sCompanyProperty.CompanyPropertyMirrorSetup = {&COMPANYPROPERTYMIRRORSETUP-NONE}
    then do:
        <Q-22 assign vlFcQueryRecordsAvailable = JournalByMfgDaybookSet (NoCache)
            (input t_sCompanyProperty.Company_ID, (CompanyId)
             input {&LAYERTYPECODE-MANAGEMENT}, (LayerType)
             input t_sCompanyProperty.tcDomainCode, (domainCode)) in BJournal >
        if vlFcQueryRecordsAvailable <> false
        then do:
            assign vcMessage      = #T-20'You cannot change the Mirror Setup to None because mangement layer daybooks are used in the daybook set.':255(69150)t-20#
                   oiReturnStatus = -1.
            <M-19 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCompanyProperty.CompanyPropertyMirrorSetup' (icFieldName), 
                input  t_sCompanyProperty.CompanyPropertyMirrorSetup (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCompanyProperty.tc_Rowid (icRowid), 
                input  'QadFin-7866':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
            return.
        end. /*  if vlFcQueryRecordsAvailable <> false */
        
        <Q-12 assign vlFcQueryRecordsAvailable = JournalByMfgDaybook (NoCache)
             (input t_sCompanyProperty.Company_ID, (CompanyId)
              input t_sCompanyProperty.tcDomainCode, (DomainCode)
              input {&LAYERTYPECODE-MANAGEMENT}, (LayerType)) in BJournal >
        if vlFcQueryRecordsAvailable <> false 
        then do:
            assign vcMessage      = #T-13'You cannot change the Mirror Setup to None because mangement layer daybooks are used in the Default Daybook setup.':255(69151)t-13#
                   oiReturnStatus = -1.
            <M-14 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCompanyProperty.CompanyPropertyMirrorSetup' (icFieldName), 
                input  t_sCompanyProperty.CompanyPropertyMirrorSetup (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCompanyProperty.tc_Rowid (icRowid), 
                input  'QadFin-7667':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
            return.
        end. /* if vlFcQueryRecordsAvailable <> false  */
    end. /* if t_iCompanyProperty.CompanyPropertyMirrorSetup... */
end. /* for each t_sCompanyProperty WHERE */