project QadFinancials > class BCInvoice > method DefaultWHTDataBasedOnCInvoice

Description

This method can be run for several invoices at the same time, that’s why we work with input-output temp-table. As input, the supplier invoice id will always be filled, and based on that, all other fields will be filled.


Parameters


tDefaultWHTDatainput-outputtemp-tableReturn WHT data based on the CInvoice ID that is passed in the temp-table. During Input, only CInvoiceID needs to be filled. During output, the WHT data will be filled.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankEntry.GetPossibleAllocationsCInvoice
method BCDocument.CalculateAllWhtGetData
method BCDocument.GetPossibleAllocationsByBank
method BOpenItemAdjustment.OIAdjApplyFilterCreditor
method BPaymentSelection.CalculatePaySelLineWhtGetData
method BPaymentSelection.GetToPayObjectsForCInvoice


program code (program6/bcinvoice.p)

    
    /* ================================================================================= */
    /* This method has an input-output temp-table where the callers have to only specify */
    /* field tiCInvoiceID and this method fills in all other fields in the temp-table    */
    /* ================================================================================= */
    
    
    WHTBLOCK: 
    DO on error undo, throw :
        
        /* ========================================= */
        /* Check if the input temp-table has records */
        /* ========================================= */
        if not can-find(first tDefaultWHTData)
        then do:
            assign vcMessage      = #T-62'The Input temp-table has no records.':255(36017282)T-62#
                   oiReturnStatus = -3.
            <M-71 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'S' (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'qadfin-914313':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
            leave WHTBLOCK.       
        end. /* if not can-find(first tDefaultWHTData) */
        
        /* ====================================== */
        /* Go through the input-output temp-table */
        /* ====================================== */
        for each tDefaultWHTData :
            
            /* ========================================== */
            /* Initialise output fields in the temp-table */
            /* ========================================== */
            assign tDefaultWHTData.tdCInvoiceTotalWHTTaxFeeTC = 0
                   tDefaultWHTData.tdCInvoiceTotalWHTAmountTC = 0
                   tDefaultWHTData.tdWHTAmountTC              = 0
                   tDefaultWHTData.tdWHTAmountLC              = 0
                   tDefaultWHTData.tdWHTAmountCC              = 0
                   tDefaultWHTData.tdUnpaidWHTAmountTC        = 0
                   tDefaultWHTData.tdWHTTCLCExchangeRate      = 0
                   tDefaultWHTData.tdWHTTCLCRateScale         = 0
                   tDefaultWHTData.tdWHTTCCCExchangeRate      = 0
                   tDefaultWHTData.tdWHTTCCCRateScale         = 0
                   tDefaultWHTData.tlUpdateTaxIsAllowed       = ?.                                         
            if tDefaultWHTData.ttPaymentDate = ?
            then assign tDefaultWHTData.ttPaymentDate = today.
            
            /* ======================================================== */
            /* Check CInvoiceID is filled in the temp-table             */
            /* ======================================================== */
            if tDefaultWHTData.tiCInvoiceID = 0 or 
               tDefaultWHTData.tiCInvoiceID = ?
            then do:
                assign vcMessage     = #T-27'The Supplier Invoice ID is not filled for one of the input temp-table records.':255(539933234)T-27#
                      oiReturnStatus = -3.
                <M-72 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tDefaultWHTData.tiCInvoiceId' (icFieldName), 
                    input  tDefaultWHTData.tiCInvoiceId (icFieldValue), 
                    input  'S' (icType), 
                    input  3 (iiSeverity), 
                    input  '' (icRowid), 
                    input  'qadfin-365995':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
                leave WHTBLOCK.                
            end. /* if tDefaultWHTData.tiCInvoiceId = 0 or */
            
            /* ========================================================================================= */
            /* Retrieve the invoice and related WHT-data based on the CInvoiceID of the input table      */
            /* Note the query-esult-set is indexed on CInvoice_ID                                        */
            /* Do not continue with this invoice in case is has no WHT (nothing in the result-set)       */
            /* ========================================================================================= */
            /* Get domain of the invoice */
            <Q-89 run CInvoiceForDomain (all) (Read) (NoCache)
               (input ?, (CompanyId)
                input tDefaultWHTData.tiCInvoiceID, (CInvoiceID)
                output dataset tqCInvoiceForDomain) in BCInvoice>
            
            find tqCInvoiceForDomain where
                 tqCInvoiceForDomain.tiCInvoice_Id = tDefaultWHTData.tiCInvoiceID
                 no-error.
            if not available tqCInvoiceForDomain
            then do:
                assign vcMessage =  #T-49'Cannot find mandatory records in resulting dataset.':255(16669284)T-49#
                       vcContext = "tDefaultWHTData.tiCInvoiceID=&1":U
                       vcContext = substitute(vcContext, tDefaultWHTData.tiCInvoiceID).
                <M-1 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'S':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'qadfin-933020':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  vcContext (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
                assign oiReturnStatus = -1.
                leave WHTBLOCK.
            end.
            
            <Q-91 run CInvoiceForWHTDefaulting (all) (Read) (NoCache)
               (input ?, (CompanyId)
                input tDefaultWHTData.tiCInvoiceID, (CInvoiceID)
                input true, (CInvoiceIsWHT)
                input tqCInvoiceForDomain.tcDomainCode, (DomainCode)
                output dataset tqCInvoiceForWHTDefaulting) in BCInvoice>
            
            /* =================================================================== */
            /* Cycle through the query-result-set - see notes above the query-call */
            /* =================================================================== */
            For each tqCInvoiceForWHTDefaulting 
                     no-lock
                     break by tqCInvoiceForWHTDefaulting.tiCInvoice_ID :
                     
                /* ======================================================================= */
                /* Basic data assignment                                                   */
                /* ======================================================================= */
                assign tDefaultWHTData.tiCInvoiceCompanyID = tqCInvoiceForWHTDefaulting.tiCompany_ID.     
                       
                /* ======================================================================= */
                /* Actions for the first entry of an invoice in tqCInvoiceForWHTDefaulting */
                /* ======================================================================= */
                if first-of (tqCInvoiceForWHTDefaulting.tiCInvoice_ID)
                then do :
                    
                    /* ==================================================================================================== */
                    /* Find-out the domain to which the invoice belongs and store it in tDefaultWHTData.tcInvoiceDomainCode */                                       
                    /* We need to know this as tqCInvoiceForWHTDefaulting can hold multiple records for different domains   */
                    /* and we only want to handle those of the same  domain as the invoice itself                           */
                    /* ==================================================================================================== */
                    if tqCInvoiceForWHTDefaulting.tiCompany_ID = viCompanyId
                    then assign tDefaultWHTData.tcCInvoiceDomainCode = vcDomainCode.
                    else do:
                        <Q-80 run DomainsForCompanies (all) (Read) (Cache)
                           (input ?, (DomainId)
                            input ?, (DomainCode)
                            input tqCInvoiceForWHTDefaulting.tiCompany_ID, (CompanyId)
                            output dataset tqDomainsForCompanies) in BDomain>
                        find tqDomainsForCompanies where
                             tqDomainsForCompanies.tiCompany_ID = tqCInvoiceForWHTDefaulting.tiCompany_ID
                             no-lock no-error.
                        if not available tqDomainsForCompanies
                        then do:
                            assign vcMessage      = substitute(#T-85'No Domain could be found for company with ID &1.':255(961386262)T-85#, string(tqCInvoiceForWHTDefaulting.tiCompany_ID))
                                   oiReturnStatus = -3.
                            <M-7 run SetMessage
                               (input  vcMessage (icMessage), 
                                input  '':U (icArguments), 
                                input  '':U (icFieldName), 
                                input  '':U (icFieldValue), 
                                input  'E':U (icType), 
                                input  3 (iiSeverity), 
                                input  '':U (icRowid), 
                                input  'qadfin-771532':U (icFcMsgNumber), 
                                input  '':U (icFcExplanation), 
                                input  '':U (icFcIdentification), 
                                input  '':U (icFcContext), 
                                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
                            leave WHTBLOCK.       
                        end. /* if not available tqDomainsForCompanies */
                        else assign tDefaultWHTData.tcCInvoiceDomainCode = tqDomainsForCompanies.tcDomainCode.                
                    end. /* not if tqCInvoiceForWHTDefaulting.tiCompany_ID = viCompanyId */
                
                end. /* if first-of (tqCInvoiceForWHTDefaulting.tiCInvoice_ID) */
                
                /* ========================================================================================== */
                /* Skip all further actions in case the domain in tqCInvoiceForWHTDefaulting does not equal   */
                /* the domain of the invoice that is stored in vcInvoiceDomainCode)                           */
                /* It would make more sense to have the query only return the records of this domain but this */
                /* is not possible as table Vat holds a DomainID and table Tx2_mstr holds a DomainCode        */
                /* ========================================================================================== */
                if tqCInvoiceForWHTDefaulting.tctx2_domain = ? or 
                   tqCInvoiceForWHTDefaulting.tctx2_domain <> tDefaultWHTData.tcCInvoiceDomainCode
                then next.
                
                /* ============================================================================================================================ */
                /* For every record in tqCInvoiceForWHTDefaulting for a single invoice we check check if all CInvoiceWHT-records of the invoice */
                /* If they all have the update tax flag on true, then we can update, otherwise not                                              */
                /* ============================================================================================================================ */
                if tDefaultWHTData.tlUpdateTaxIsAllowed        <> false and /* it is set to ? in the beginning */
                   tqCInvoiceForWHTDefaulting.tltx2_update_tax  = false and 
                   tqCInvoiceForWHTDefaulting.tcVatCode        <> "":U  and 
                   tqCInvoiceForWHTDefaulting.tcVatCode        <> ?
                then tDefaultWHTData.tlUpdateTaxIsAllowed = false.

                /* ======================================================================= */
                /* Actions for the last entry of an invoice in tqCInvoiceForWHTDefaulting  */
                /* ======================================================================= */
                if last-of (tqCInvoiceForWHTDefaulting.tiCInvoice_ID)
                then do :
                
                    /* ============================================= */
                    /* Set the rates between invoice currency and LC */
                    /* ============================================= */
                    if tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID = viCompanyLCId
                    then assign tDefaultWHTData.tdWHTTCLCExchangeRate = 1
                                tDefaultWHTData.tdWHTTCLCRateScale    = 1.
                    else do:
                        /* The exchange rates to be used will be cached in the temp-table tExchangeRateStore.     */
                        /* If a cached exchange rate exists, then that exchange rate will be used for the         */
                        /* calculation. Otherwise, a method call will be made to GetExchangeRate                  */
                        /* in order to find the correct exchange rate to use.                                     */
                        find first tExchangeRateStore where
                                   tExchangeRateStore.tcExchangeRateType = {&EXCHANGERATETYPE-VAT}                          and
                                   tExchangeRateStore.tlIsStatutory      = false                                            and
                                   tExchangeRateStore.ttDate             = tDefaultWHTData.ttPaymentDate                    and
                                   tExchangeRateStore.tiFromCurrency_ID  = tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID and
                                   tExchangeRateStore.tiToCurrency_ID    = viCompanyLCId
                                   no-lock no-error.
                        if available tExchangeRateStore
                        then assign tDefaultWHTData.tdWHTTCLCExchangeRate = tExchangeRateStore.tdExchangerate
                                    tDefaultWHTData.tdWHTTCLCRateScale    = tExchangeRateStore.tdRateScale.
                        else do:
                            <M-5 run GetExchangeRate
                               (input  viCompanyId (iiCompanyID), 
                                input  tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID (iiFromCurrencyID), 
                                input  ? (icFromCurrencyCode), 
                                input  viCompanyLCId (iiToCurrencyID), 
                                input  ? (icToCurrencyCode), 
                                input  ? (iiExchangeRateTypeID), 
                                input  {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode), 
                                input  tDefaultWHTData.ttPaymentDate (itValidityDate), 
                                output tDefaultWHTData.tdWHTTCLCExchangeRate (odExchangeRate), 
                                output tDefaultWHTData.tdWHTTCLCRateScale (odExchangeScaleFactor), 
                                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
                            if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
                            if viFcReturnSuper <  0 then leave WHTBLOCK.
                            create tExchangeRateStore.
                            assign tExchangeRateStore.tcExchangeRateType = {&EXCHANGERATETYPE-VAT}
                                   tExchangeRateStore.tcFromCurrencyCode = '':U
                                   tExchangeRateStore.tcToCurrencyCode   = '':U
                                   tExchangeRateStore.tdExchangerate     = tDefaultWHTData.tdWHTTCLCExchangeRate
                                   tExchangeRateStore.tdRateScale        = tDefaultWHTData.tdWHTTCLCRateScale
                                   tExchangeRateStore.tiFromCurrency_ID  = tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID
                                   tExchangeRateStore.tiToCurrency_ID    = viCompanyLCId
                                   tExchangeRateStore.tlIsStatutory      = false
                                   tExchangeRateStore.ttDate             = tDefaultWHTData.ttPaymentDate.
                        end. /* NOT if available tExchangeRateStore */
                    end. /* else if tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID = viCompanyLCId */
            
                    /* ============================================= */
                    /* Set the rates between invoice currency and CC */
                    /* ============================================= */
                    if tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID = viCompanyCCId
                    then assign tDefaultWHTData.tdWHTTCCCExchangeRate = 1
                                tDefaultWHTData.tdWHTTCCCRateScale    = 1.
                    else do:
                        /* The exchange rates to be used will be cached in the temp-table tExchangeRateStore.     */
                        /* If a cached exchange rate exists, then that exchange rate will be used for the         */
                        /* calculation. Otherwise, a method call will be made to GetExchangeRate                  */
                        /* in order to find the correct exchange rate to use.                                     */
                        find first tExchangeRateStore where
                                   tExchangeRateStore.tcExchangeRateType = {&EXCHANGERATETYPE-VAT}                          and
                                   tExchangeRateStore.tlIsStatutory      = true                                             and
                                   tExchangeRateStore.ttDate             = tDefaultWHTData.ttPaymentDate                    and
                                   tExchangeRateStore.tiFromCurrency_ID  = tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID and
                                   tExchangeRateStore.tiToCurrency_ID    = viCompanyCCId
                                   no-lock no-error.
                        if available tExchangeRateStore
                        then assign tDefaultWHTData.tdWHTTCCCExchangeRate = tExchangeRateStore.tdExchangerate
                                    tDefaultWHTData.tdWHTTCCCRateScale    = tExchangeRateStore.tdRateScale.
                        else do:
                            <M-9 run GetExchangeRate
                               (input  viCompanyId (iiCompanyID), 
                                input  tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID (iiFromCurrencyID), 
                                input  ? (icFromCurrencyCode), 
                                input  viCompanyCCId (iiToCurrencyID), 
                                input  ? (icToCurrencyCode), 
                                input  ? (iiExchangeRateTypeID), 
                                input  {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode), 
                                input  tDefaultWHTData.ttPaymentDate (itValidityDate), 
                                output tDefaultWHTData.tdWHTTCCCExchangeRate (odExchangeRate), 
                                output tDefaultWHTData.tdWHTTCCCRateScale (odExchangeScaleFactor), 
                                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
                            if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
                            if viFcReturnSuper <  0 then leave WHTBLOCK.
                            create tExchangeRateStore.
                            assign tExchangeRateStore.tcExchangeRateType = {&EXCHANGERATETYPE-VAT}
                                   tExchangeRateStore.tcFromCurrencyCode = '':U
                                   tExchangeRateStore.tcToCurrencyCode   = '':U
                                   tExchangeRateStore.tdExchangerate     = tDefaultWHTData.tdWHTTCCCExchangeRate
                                   tExchangeRateStore.tdRateScale        = tDefaultWHTData.tdWHTTCCCRateScale
                                   tExchangeRateStore.tiFromCurrency_ID  = tqCInvoiceForWHTDefaulting.tiCInvoiceCurrency_ID
                                   tExchangeRateStore.tiToCurrency_ID    = viCompanyCCId
                                   tExchangeRateStore.tlIsStatutory      = true
                                   tExchangeRateStore.ttDate             = tDefaultWHTData.ttPaymentDate.
                        end.  /* NOT if available tExchangeRateStore */
                    end. /* else do: */ 
                    
                    /* ========================================================== */
                    /* Read all existing WHT-records associated with this invoice */
                    /* ========================================================== */
                    <Q-26 run WHTByCInvoice (all) (Read) (NoCache)
                       (input tqCInvoiceForWHTDefaulting.tiCompany_ID, (CompanyId)
                        input tDefaultWHTData.tiCInvoiceID, (CInvoiceId)
                        input ?, (WHTStatusDiffersFrom)
                        input ?, (WHTStatus)
                        output dataset tqWHTByCInvoice) in BWithholdingTax>  
            
                    /* ================================================================================ */
                    /* the unpaid wht amount is the sum of the wht amounts where status is initial      */
                    /* for example regarding payment, the ones that are for collection but not paid yet */
                    /* ================================================================================ */ 
                    assign tDefaultWHTData.tdUnpaidWHTAmountTC  = abs(tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtDebitTC - tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtCreditTC)
                           vdWHTAmountTC                        = 0
                           vdWHTAmountLC                        = 0
                           vdWHTAmountCC                        = 0.           
                    for each tqWHTByCInvoice where
                             tqWHTByCInvoice.tiCInvoice_ID = tDefaultWHTData.tiCInvoiceID :
                        if tqWHTByCInvoice.tcWHTStatus   <> {&WHTSTATUS-VOID} 
                        then assign vdWHTAmountTC = vdWHTAmountTC + abs(tqWHTByCInvoice.tdWHTAmtDebitTC - tqWHTByCInvoice.tdWHTAmtCreditTC)
                                    vdWHTAmountLC = vdWHTAmountLC + abs(tqWHTByCInvoice.tdWHTAmtDebitLC - tqWHTByCInvoice.tdWHTAmtCreditLC)
                                    vdWHTAmountCC = vdWHTAmountCC + abs(tqWHTByCInvoice.tdWHTAmtDebitCC - tqWHTByCInvoice.tdWHTAmtCreditCC).
                        if tqWHTByCInvoice.tcWHTStatus = {&WHTSTATUS-INIT}
                        then assign tDefaultWHTData.tdInitiallyAllocatedWHTAmountTC = tDefaultWHTData.tdInitiallyAllocatedWHTAmountTC + 
                                                                                      abs(tqWHTByCInvoice.tdWHTAmtDebitTC - tqWHTByCInvoice.tdWHTAmtCreditTC).
                        
                        if tqWHTByCInvoice.tcWHTStatus = {&WHTSTATUS-DUE} 
                        then assign tDefaultWHTData.tdUnpaidWHTAmountTC = tDefaultWHTData.tdUnpaidWHTAmountTC - abs(tqWHTByCInvoice.tdWHTAmtCreditTC - tqWHTByCInvoice.tdWHTAmtDebitTC). 
                    end. /* for each tqWHTByCInvoice where */
                                                                         
                    /* ======================================================================================================== */
                    /* Assign the Open-WHT amount of the invoice : so everything of the invoice minus what is already allocated */
                    /* ======================================================================================================== */
                    assign tDefaultWHTData.tdWHTAmountTC = abs(tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtDebitTC - tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtCreditTC) - vdWHTAmountTC 
                           tDefaultWHTData.tdWHTAmountLC = abs(tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtDebitLC - tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtCreditLC) - vdWHTAmountLC
                           tDefaultWHTData.tdWHTAmountCC = abs(tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtDebitCC - tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtCreditCC) - vdWHTAmountCC .
                    
                    /* =========================================================================== */
                    /* Total-WHT fields are needed on ui, default it is equal to the WHT amount TC */
                    /* =========================================================================== */
                    assign tDefaultWHTData.tdCInvoiceTotalWHTAmountTC = abs(tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtDebitTC - tqCInvoiceForWHTDefaulting.tdCInvoiceWHTTotAmtCreditTC)
                           tDefaultWHTData.tdCInvoiceTotalWHTTaxFeeTC = abs(tqCInvoiceForWHTDefaulting.tdCInvoiceWHTBaseAmtDebitTC - tqCInvoiceForWHTDefaulting.tdCInvoiceWHTBaseAmtCreditTC).
                    
                    /* =========================================================================== */
                    /* Invert teh sign of some fields in case it is about a Correction             */
                    /* =========================================================================== */
                    if tqCInvoiceForWHTDefaulting.tcCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION} or
                       tqCInvoiceForWHTDefaulting.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                    then assign tDefaultWHTData.tdWHTAmountTC                   = - tDefaultWHTData.tdWHTAmountTC
                                tDefaultWHTData.tdWHTAmountLC                   = - tDefaultWHTData.tdWHTAmountLC
                                tDefaultWHTData.tdWHTAmountCC                   = - tDefaultWHTData.tdWHTAmountCC
                                tDefaultWHTData.tdCInvoiceTotalWHTAmountTC      = - tDefaultWHTData.tdCInvoiceTotalWHTAmountTC
                                tDefaultWHTData.tdCInvoiceTotalWHTTaxFeeTC      = - tDefaultWHTData.tdCInvoiceTotalWHTTaxFeeTC
                                tDefaultWHTData.tdInitiallyAllocatedWHTAmountTC = - tDefaultWHTData.tdInitiallyAllocatedWHTAmountTC
                                tDefaultWHTData.tdUnpaidWHTAmountTC             = - tdUnpaidWHTAmountTC.
                    
                    /* ============================================================================================================= */
                    /* If tDefaultWHTData.tlUpdateTaxIsAllowed still has the unknown-value (that is its default)then this means none */
                    /* of the previous tqCInvoiceForWHTDefaulting-records of this invoice had the update-allowed flag set to false.  */
                    /* So in that case we can not set this field to true                                                             */
                    /* ============================================================================================================= */
                    if tDefaultWHTData.tlUpdateTaxIsAllowed = ? 
                    then assign tDefaultWHTData.tlUpdateTaxIsAllowed = true.

                    /* =============================================================================================================================== */
                    /* Call a submethod in the same segment; Specifc program-code can be written there (or in the Non-intruisive customisation of the  */
                    /* method) and so the 'standard' values of the input-output temp-table tDefaultWHTData that were caluclated above can be adapted.  */
                    /* All required data that might be needed to do so is available in the submethod                                                  */
                    /* =============================================================================================================================== */
                    <M-45 run DefaultWHTDataBasedOnCInvoiceSpecific  (output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
                    if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
                    if viFcReturnSuper <  0 then leave WHTBLOCK.
                
                end. /* if last-of (tqCInvoiceForWHTDefaulting.tiCInvoice_ID) */
                
            end. /* For each tqCInvoiceForWHTDefaulting break by tqCInvoiceForWHTDefaulting.tiCInvoice_ID no-lock */ 
            /* ==================================================================================================== */
            /* If tDefaultWHTData.tlUpdateTaxIsAllowed still has the unknown-value (that is ?) then this means no   */
            /* CInvoiceWHT-record exist of this invoice but CInvoiceIsWHT is not updated to false.                  */
            /* So in that case we set this field to false                                                           */
            /* ==================================================================================================== */
            if tDefaultWHTData.tlUpdateTaxIsAllowed = ? 
            then assign tDefaultWHTData.tlUpdateTaxIsAllowed = false.
        end. /* for each tDefaultWHTData: */
                                                                         
    END. /* WHTBLOCK */