project QadFinancials > class BDomain > 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.

Validations for Invoice Certification:
- Invoice Certification can only be enabled when base currency and/or statutory currency is EUR.
- Invoice Certification can only be enabled when Consecutive Numbering is enabled.
- Invoice Certification can only be enabled when Daybook Set by site is enabled.
- Invoice Certification can only be enabled when the OpenSSL directory was entered in system modify.
- Warn the user that enabling Invoice Certification can not be undone.
- Error when the user tries to disable Invoice Certification.


Parameters


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bdomain.p)

/* ========================================= */
/* Remove previously used external instances */
/* ========================================= */
<M-32 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BDomain>

/* For the limited sync, we need to fill the StatutoryCurrency_ID (between SP4 - SP5) when it's not filled yet. */
/* Since this is a mandatory field, it needs to be filled in order to save the domain.                          */
for each t_sDomains where
         t_sDomains.tc_Status <> "D":U:
    for each tDomainPropertyRefer where
             tDomainPropertyRefer.Domain_ID            = t_sDomains.Domain_ID and
             tDomainPropertyRefer.tcCurrencyCode      <> ?                    and
             tDomainPropertyRefer.tcCurrencyCode      <> '':U                 and
            (tDomainPropertyRefer.tcStatutoryCurrency = ? or
             tDomainPropertyRefer.tcStatutoryCurrency = '':U):
        assign tDomainPropertyRefer.StatutoryCurrency_ID    = tDomainPropertyRefer.Currency_ID
               tDomainPropertyRefer.tcStatutoryCurrencyCode = tDomainPropertyRefer.tcCurrencyCode.
        if t_sDomains.tc_Status = "":U
        then assign t_sDomains.tc_Status = "C":U.
    end. /* for each t_sDomains where */
end. /* for each tDomainPropertyRefer where */

<ANCESTOR-CODE>
if oiReturnStatus < 0 then return.

assign viLocalReturnStatus = oiReturnStatus
       oiReturnStatus      = -98.
    
for each t_sDomains where 
         t_sDomains.tc_Status <> "D":U:        

    /* Hard-Coded assignment of domain database to qaddb... */
    if t_sDomains.DomainDatabase = ? or t_sDomains.DomainDatabase = "":U then do:
    
        assign t_sDomains.DomainDatabase = ldbname("qaddb":U).

        if t_sDomains.DomainDatabase = ? or t_sDomains.DomainDatabase = "":U then
            assign t_sDomains.DomainDatabase = "QADDB":U.
    end.
     
    /* Check Shared Services Domain license */
    /* First check to see if there is already an active domain defined */
    <Q-21 run DomainsByActive (all) (Read) (NoCache)
       (input true, (DomainIsActive)
        output dataset tqDomainsByActive) in BDomain >
    /* If there is another active domain already defined then check for a SSD license record */
    if can-find (first tqDomainsByActive where tqDomainsByActive.tcDomainCode <> "QAD":U)
       and  t_sDomains.tc_status = "N":U
    then do:
       <Q-18 assign vlFcQueryRecordsAvailable = MfgLicenseForApplication (NoCache)  (input 'SSD', (Application)) in BMfgLicense >

       if vlFcQueryRecordsAvailable = false 
       then do:
          assign viLocalReturnStatus = -1
                 vcMessage           = #T-19'Multiple domains cannot be active without an SSD license.':70(56927)T-19#
               .
          <M-20 run SetMessage
             (input  vcMessage (icMessage), 
              input  '':U (icArguments), 
              input  '':U (icFieldName), 
              input  '':U (icFieldValue), 
              input  'E':U (icType), 
              input  3 (iiSeverity), 
              input  '' (icRowid), 
              input  'QadFin-5806':U (icFcMsgNumber), 
              input  '' (icFcExplanation), 
              input  '' (icFcIdentification), 
              input  '' (icFcContext), 
              output viFcReturnSuper (oiReturnStatus)) in BDomain>
       end.
    end.

    /* Domain can only be made inactive if all linked companies are inactive */
    /* This can only happen for an existing domain... */    
    if t_sDomains.tc_status = "C":U 
    then do:
        /* Find t_iDomains.  */
        find t_iDomains where 
             t_iDomains.tc_rowid = t_sDomains.tc_rowid
             no-error.
        if not available t_iDomains
        then next.

        if t_iDomains.DomainIsActive <>
           t_sDomains.DomainIsActive and t_sDomains.DomainType <> "SYSTEM":U
        then do:
            <I-28 {bFcStartAndOpenInstance
                 &ADD-TO-TRANSACTION = "false"
                 &CLASS              = "BMfgDBConnections"}>
            /* First check to see if this is a multiDB environment */
            /* and all DBs are connected. If not don't continue    */
            <M-30 run IsMultiDB
               (output vlMultiDB (olisMultiDB), 
                output viFcReturnSuper (oiReturnStatus)) in BMfgDBConnections>
            if vlMultiDB then do:   
               <M-25 run CheckDBConnections  (output viFcReturnSuper (oiReturnStatus)) in BMfgDBConnections>
               if viFcReturnSuper < 0 then 
                  assign
                     viLocalReturnStatus = -1.
            end.
            <I-31 {bFcCloseAndStopInstance
                 &CLASS           = "BMfgDBConnections"}>
        end.

        if t_iDomains.DomainIsActive = true and 
           t_sDomains.DomainIsActive = false
        then do:

            /* Find all active linked companies, if there are any... */
            <Q-3 run CompanyByDomain (all) (Read) (NoCache)
               (input '', (CompanyId)
                input t_sDomains.Domain_ID, (DomainId)
                input true, (Active)
                output dataset tqCompanyByDomain) in BCompany >
    
            find first tqCompanyByDomain no-error.
            
            if available tqCompanyByDomain 
            then do:
    
                assign viLocalReturnStatus = -1
                       vcMessage           = #T-1'The domain cannot be made inactive. There are still active linked entities':100(20308)T-1#.
    
                <M-4 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '' (icArguments), 
                    input  'tDomains.DomainIsActive':U (icFieldName), 
                    input  t_sDomains.DomainIsActive (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'QadFin-4745':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>
    
            end. /* if available tqCompanyByDomain */    
        end. /* if t_iDomain.DomainIsActive = false */

    end. /* if t_sDomains.tc_status = "C":U */

    /* Check if Primary company is filled in when domain is flagged as complete */
    find tDomainPropertyRefer where
         tDomainPropertyRefer.Domain_ID = t_sDomains.Domain_ID
         no-lock no-error.
    if not available tDomainPropertyRefer
    then do:
        assign vcMessage           = trim(#T-8'The system cannot find attributes for this domain.':200(32058)T-8#)
               oiReturnStatus = -3.
        <M-9 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  1 (iiSeverity), 
            input  t_sDomains.tc_Rowid (icRowid), 
            input  'QadFin-4945':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDomain>
        return.
    end. /* if not available tDomainPropertyRefer */

    if t_sDomains.tc_status = "N":U           or 
       t_sDomains.tc_status = "C":U           or
       tDomainPropertyRefer.tc_Status = "N":U or
       tDomainPropertyRefer.tc_Status = "C":U
    then do:
        if tDomainPropertyRefer.DomainPropertyIsSetupCompl = true 
        then do:
            /* Check if the primary company is set */      
            if (t_sDomains.tcCompanyCode                       = '':U or
                t_sDomains.tcCompanyCode                       = ?)
            then do:
                assign vcMessage      = trim(#T-10'You must define a primary entity before confirming the setup.':200(56475)T-10#)
                       viLocalReturnStatus = -1.
                <M-11 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'QadFin-4946':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>                                     
            end. /* if (t_sDomains.tcCompanyCode                       = '':U ... */  
        end. /* if tDomainPropertyRefer.DomainPropertyIsSetupCompl = true  */

        /* ================================================= */
        /* Validations when Invoice Certification is enabled */
        /* ================================================= */
        if tDomainPropertyRefer.DomainPropertyIsInvCertific = true            
        then do:
                        
            /* ===================================================== */
            /* Get the original values in case it concerns an update */
            /* ===================================================== */          
            if t_sDomains.tc_Status           = "C" or
               tDomainPropertyRefer.tc_Status = "C"
            then do:            
                find tInitialDomainPropertyRefer where
                     tInitialDomainPropertyRefer.DomainProperty_ID = tDomainPropertyRefer.DomainProperty_ID
                     no-lock no-error.
            end. /* if t_sDomains.tc_Status = "C" or */

            /* ====================================================== */
            /* Base Currency and/or Statutory Currency need to be EUR */
            /* ====================================================== */
            if tDomainPropertyRefer.tcCurrencyCode          <> "EUR" and
               tDomainPropertyRefer.tcStatutoryCurrencyCode <> "EUR"
            then do:
                assign vcMessage           = #T-35'Invoice Certification can only be enabled when the base currency and/or the statutory currency is set to EUR.':255(275663076)T-35#
                       viLocalReturnStatus = -1.
                <M-53 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'qadfin-183232':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>
            end. /* if tDomainPropertyRefer.tcCurrencyCode <> "EUR" and */

            /* ============================================================== */
            /* Domain needs to be set up to use Consecutive Invoice Numbering */
            /* ============================================================== */
            if tDomainPropertyRefer.DomainPropertyIsConsecutNr <> true
            then do:
                assign vcMessage           = #T-97'Consecutive Invoice Numbering needs to be enabled for the domain where you want to use Invoice Certification.':255(655903069)T-97#
                       viLocalReturnStatus = -1.
                <M-61 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'qadfin-241413':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>
            end. /* if tDomainPropertyRefer.DomainPropertyIsConsecutNr <> true */
            
            /* ================================================================================= */
            /* ChronologicalInvoiceNumbering must be true and NonChronErr shoudl be set to Error */
            /* ================================================================================= */
            if tDomainPropertyRefer.DomainPropertyIsChronolNr <> true OR 
               tDomainPropertyRefer.DomainPropertyNonChronErr <> "ERROR":U
            then do:
                assign vcMessage           = trim(substitute(#T-191'Chonological Invoice Numbering needs to be turned on when you want to use Invoice Certification and errors need to be raised in case of violations. Domain: &1':255(767727609)T-191#,tDomainPropertyRefer.DomainPropertyName))
                       viLocalReturnStatus = -1.
                <M-95 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tDomainProperty.DomainPropertyNonChronErr':U (icFieldName), 
                    input  string(tDomainPropertyRefer.DomainPropertyNonChronErr) (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'qadfin-958001':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>
            end. /* if tDomainPropertyRefer.DomainPropertyIsChronolNr <> true OR */
            
            /* ================================== */
            /* Daybook Set by site should be used */
            /* ================================== */
            <Q-59 run SOAccountingControlByDomain (all) (Read) (NoCache)
               (input t_sDomains.DomainCode, (Domain)
                output dataset tqSOAccountingControlByDomain) in BMfgSOAccountingControl>
            if not can-find(first tqSOAccountingControlByDomain where
                                  tqSOAccountingControlByDomain.tlsoc_dybkset_by_site = true)
            then do:
                assign vcMessage           = #T-81'The Daybook Set By Site needs to be enabled before the Invoice Certification can be enabled.':255(331587119)T-81#
                       viLocalReturnStatus = -1.
                <M-44 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'qadfin-318708':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>                
            end. /* if not can-find(first tqSOAccountingControlByDomain where */

            /* ==================================================== */
            /* Shipping Number Sequences should be set up correctly */
            /* ==================================================== */
            if viPMfgProNrmApiID = ? or
               viPMfgProNrmApiID = 0
            then do:
                <I-69 {bFcStartAndOpenInstance
                     &ADD-TO-TRANSACTION   = "false"
                     &CLASS                = "PMfgProNrmApi"}>
            end.
            else do: /* if viPMfgProNrmApiID = ? or */
                <I-83 {bFcOpenInstance
                     &CLASS           = "PMfgProNrmApi"}>
            end. /* else do: */

            <M-96 run ValidateShippingNumbers
               (input  t_sDomains.DomainCode (icDomainCode), 
                output viFcReturnSuper (oiReturnStatus)) in PMfgProNrmApi>
             if viFcReturnSuper < 0 or 
               (viFcReturnSuper > 0 and oiReturnStatus = 0)
             then assign oiReturnStatus = viFcReturnSuper.
             
             <I-46 {bFcCloseInstance
                  &CLASS           = "PMfgProNrmApi"}>
            
            /* ====================================================================== */
            /* The Open SSL directory needs to be filled in in case we aren't on UNIX */
            /* ====================================================================== */
            if OPSYS <> "UNIX":U
            then do :
                <Q-71 run SystemPropertyByAll (all) (Read) (NoCache)  (output dataset tqSystemPropertyByAll) in BSystemProperty>
                find tqSystemPropertyByAll no-lock no-error.            
                if available tqSystemPropertyByAll and
                  (tqSystemPropertyByAll.tcSysPropertyInvCertOpenSSLDir = "" or
                   tqSystemPropertyByAll.tcSysPropertyInvCertOpenSSLDir = ?)
                then do:
                    assign vcMessage           = #T-42'The Open SSL Directory on System needs to be filled before the Invoice Certification can be enabled.':255(909335094)T-42#
                           viLocalReturnStatus = -1.
                    <M-47 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  '':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sDomains.tc_Rowid (icRowid), 
                        input  'qadfin-459232':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDomain>                
                end. /* if available tqSystemPropertyByAll and */
            end. /* if OPSYS <> "UNIX":U */
            
            
            /* ============================================================================ */
            /* Check if the Portugese License is installed                                  */
            /* ============================================================================ */
            /* Don't have to check for started instances for proxy classes */
            <I-92 {bFcStartAndOpenInstance
                 &ADD-TO-TRANSACTION   = "false"
                 &CLASS                = "PLicense"}>
            
            assign vcLicenseBankCharge = {&LICENSEDOMAINDECREE363}.
            <M-58 run ValidateProgramLicense
               (input  vcLicenseBankCharge (icProgramName), 
                output viFcReturnSuper (oiReturnStatus)) in PLicense>
            if viFcReturnSuper < 0 or 
              (viFcReturnSuper > 0 and viLocalReturnStatus = 0)
            then assign viLocalReturnStatus = viFcReturnSuper.
            
            <I-17 {bFcCloseAndStopInstance
                 &CLASS           = "PLicense"}>

            /* ============================================================================ */
            /* Warn that the Invoice Certification can not be disabled anymore after saving */
            /* ============================================================================ */
            if (available tInitialDomainPropertyRefer and
                tInitialDomainPropertyRefer.DomainPropertyIsInvCertific <> true) or
                t_sDomains.tc_Status = "N"
            then do:
                assign vcMessage           = #T-82'It won't be possible to disable Invoice Certification for a domain once it has been enabled.  Are you sure you want to enable Invoice Certification for this domain?':255(256512175)T-82#
                       viLocalReturnStatus = (if viLocalReturnStatus = 0 then 1 else viLocalReturnStatus).
                <M-57 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'W':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'qadfin-401682':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>
            end. /* if tInitialDomainPropertyRefer.DomainPropertyIsInvCertific <> true */
            
        end. /* if tDomainPropertyRefer.DomainPropertyIsInvCertific = true */
        
        /* ================================================= */
        /* Invoice Certification can not be disabled anymore */
        /* ================================================= */
        if tDomainPropertyRefer.DomainPropertyIsInvCertific        <> true and
           available tInitialDomainPropertyRefer                           and
           tInitialDomainPropertyRefer.DomainPropertyIsInvCertific  = true
        then do:
            assign vcMessage           = #T-78'Once Invoice Certification was enabled, it can not be disabled anymore.':255(960580335)T-78#
                   viLocalReturnStatus = -1.
            <M-67 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDomains.tc_Rowid (icRowid), 
                input  'qadfin-207702':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDomain>
        end. /* if tDomainPropertyRefer.DomainPropertyIsInvCertific <> true and */
        
    end. /* if t_sDomains.tc_status = ... */
    
    /* If the user changes a shared set for COA Mask, this change is applied next time user logs in */
    if t_sDomains.tc_Status <> "D":U
    then do:
        for each t_sDomainSharedSet where 
                 t_sDomainSharedSet.tc_ParentRowid = t_sDomains.tc_Rowid and
                 t_sDomainSharedSet.tc_Status      = "C":U:
            
            if can-find(first t_iDomainSharedSet where
                              t_iDomainSharedSet.tc_Rowid      = t_sDomainSharedSet.tc_Rowid   and
                              t_iDomainSharedSet.SharedSet_ID <> t_sDomainSharedSet.SharedSet_ID)
            then do:
                <M-33 run SetMessage
                   (input  #T-24'Changes of Shared Sets in Domain definition will be applied next time you login.':255(73426178)T-24# (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'W':U (icType), 
                    input  4 (iiSeverity), 
                    input  t_sDomains.tc_Rowid (icRowid), 
                    input  'QadFin-9470':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDomain>
                if viLocalReturnStatus = 0 then assign viLocalReturnStatus = 1.
                leave.
            end.
        end. /* for each t_sDomainSharedSet where  */
    end. /* if t_sDomains.tc_Status = "C":U */

    if not <M-12 ValidPathInfo  (input  t_sDomains.DomainPropath (icPath)) in BDomain> then do:
        assign vcMessage = trim(#T-13'The propath specified for domain ($1) is not valid.':200(56473)T-13#)
            viLocalReturnStatus = -1.
         <M-14 run SetMessage
            (input  vcMessage (icMessage), 
             input  t_sDomains.DomainCode (icArguments), 
             input  'DomainsPropath':U (icFieldName), 
             input  t_sDomains.DomainPropath (icFieldValue), 
             input  'E':U (icType), 
             input  3 (iiSeverity), 
             input  t_sDomains.tc_Rowid (icRowid), 
             input  'QadFin-5710':U (icFcMsgNumber), 
             input  '':U (icFcExplanation), 
             input  '':U (icFcIdentification), 
             input  '':U (icFcContext), 
             output viFcReturnSuper (oiReturnStatus)) in BDomain>
    end.

    if not <M-22 ValidateDuplicatePath  (input  t_sDomains.DomainPropath (icPath)) in BDomain>
    then do:
       assign
          viLocalReturnStatus = -1
          vcMessage = #T-23'The propath contains a duplicate directory.':200(56928)T-23#
          .
       <M-24 run SetMessage
          (input  vcMessage (icMessage), 
           input  '':U (icArguments), 
           input  'DomainPropath':U (icFieldName), 
           input  t_sDomains.DomainPropath (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sDomains.tc_Rowid (icRowid), 
           input  'QadFin-5807':U (icFcMsgNumber), 
           input  '':U (icFcExplanation), 
           input  '':U (icFcIdentification), 
           input  '':U (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDomain>
   end.

    /* WHT Due moment can only be changed when there are no supplier payments left with status "For Collection" */
    if (t_sDomains.tc_Status           = "C" or
        tDomainPropertyRefer.tc_Status = "C")   and
        not available tInitialDomainPropertyRefer
    then do:            
        find tInitialDomainPropertyRefer where
             tInitialDomainPropertyRefer.DomainProperty_ID = tDomainPropertyRefer.DomainProperty_ID
             no-lock no-error.
    end. /* if t_sDomains.tc_Status = "C" or */    
    if tDomainPropertyRefer.DomainPropertyWHTDueMoment = "" or tDomainPropertyRefer.DomainPropertyWHTDueMoment = ?
    then assign tDomainPropertyRefer.DomainPropertyWHTDueMoment = {&DOCUMENTSTATUS-PAID}.
    if (t_sDomains.tc_Status                     = "C" or
        tDomainPropertyRefer.tc_Status           = "C")     and
       ((tDomainPropertyRefer.DomainPropertyWHTDueMoment        = {&DOCUMENTSTATUS-INCASSO} and
        tInitialDomainPropertyRefer.DomainPropertyWHTDueMoment = {&DOCUMENTSTATUS-PAID}       ) or
       (tDomainPropertyRefer.DomainPropertyWHTDueMoment        = {&DOCUMENTSTATUS-PAID}    and
        tInitialDomainPropertyRefer.DomainPropertyWHTDueMoment = {&DOCUMENTSTATUS-INCASSO}    ) or
       (tDomainPropertyRefer.DomainPropertyWHTDueMoment        = {&DOCUMENTSTATUS-INCASSO} and
        (tInitialDomainPropertyRefer.DomainPropertyWHTDueMoment = "" or tInitialDomainPropertyRefer.DomainPropertyWHTDueMoment = ?)))
    then do:
        assign vcDocumentStatusIncasso = {&DOCUMENTSTATUS-INCASSO}.
        <Q-86 assign vlFcQueryRecordsAvailable = DomainForCDocumentByStatus (NoCache)
           (input t_sDomains.DomainCode, (DomainCode)
            input vcDocumentStatusIncasso, (DocumentStatus)
            input ?, (CompanyId)) in BDomain>
        if vlFcQueryRecordsAvailable <> false
        then do:
       assign viLocalReturnStatus = -1
              vcMessage = #T-45'The WHT Due moment can only be modified when none of the supplier payments for this domain have status For Collection.':200(714647985)T-45# + chr(10) +
                          #T-51'This in order to prevent duplicate or missing WHT records and WHT postings.':255(218359003)T-51# + chr(10) +
                          #T-68'List all Supplier Payments with status For Collection, move them to status Accepted and set them to For Collection again after changing the WHT Due Moment setting.':255(468286828)T-68#.          
       <M-80 run SetMessage
          (input  vcMessage (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sDomains.tc_Rowid (icRowid), 
           input  'qadfin-529234':U (icFcMsgNumber), 
           input  '':U (icFcExplanation), 
           input  '':U (icFcIdentification), 
           input  '':U (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDomain>
        end. /* if vlFcQueryRecordsAvailable <> false */
    end. /* if t_sDomains.tc_Status                     = "C"  and */
end. /* for each t_sDomains ... */

/* Validate SharedSet Change */
<M-7 run ValidateComponentSharedSetChange  (output viFcReturnSuper (oiReturnStatus)) in BDomain>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0 
then assign viLocalReturnStatus = viFcReturnSuper.
        
assign oiReturnStatus = viLocalReturnStatus.