project QadFinancials > class BDInvoice > method ValidateComponentAll

Description

This method is a submethod of ValidateComponent.

This method includes the validations that are done after the ancestor code of the ValidateComponent.
This method includes the validation of the debtor invoice and his sub-tables.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.ValidateComponent


program code (program5/bdinvoice.p)

<Q-107 run AddressTypePrim (all) (Read) (NoCache)
   (input ?, (AddressTypeId)
    input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
    output dataset tqAddressTypePrim) in BAddressType >
find first tqAddressTypePrim where
           tqAddressTypePrim.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-HEADOFFICE}
           no-lock no-error.
assign viHOAddressTypeID = if available tqAddressTypePrim
                           then tqAddressTypePrim.tiAddressType_ID
                           else ?.

/* some extra validations */
for each t_sDInvoice where
         t_sDInvoice.tc_Status <> "D":U:

    if t_sDInvoice.tc_Status <> "N":U
    then do :
        find t_iDInvoice where 
             t_iDInvoice.tc_Rowid = t_sDInvoice.tc_Rowid
             no-lock no-error.
        if not available t_iDInvoice
        then next.
    end. /* if t_sDInvoice.tc_Status <> "N":U */
    
    /* Specific validations for stage-payment-conditions */
    <M-55 run ValidateComponentAllStages  (output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.
    
    if t_sDInvoice.tc_status = "N":U
    then do:      
  
    
        /* Validate bast + vat amount are the same like invoice amount */
        <M-94 run ValidateComponentAllVatAmount  (output viFcReturnSuper (oiReturnStatus)) in BDInvoice> 
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.  

        if t_sDinvoice.tc_status = "C":U and t_sDInvoice.tcNormalPaymentConditionCode <>  t_iDInvoice.tcNormalPaymentConditionCode
        then do:
          <Q-95 assign vlFcQueryRecordsAvailable = DInvoiceMovementByDITypeSimple (NoCache)
             (input ?, (CompanyId)
              input t_sDInvoice.DInvoice_ID, (DInvoiceId)
              input {&MOVEMENTTYPE-MOVEMENT}, (DinvoiceMovementType)) in BDInvoice >
          if vlFcQueryRecordsAvailable <> false
          then do:
              assign vcMessage      = #T-83'You cannot modify credit terms $1 for invoice $2 because payments exist.':85(57360)T-83#
                     oiReturnStatus = -1.
              <M-82 run SetMessage
                 (input  vcMessage (icMessage), 
                  input  t_iDinvoice.tcNormalPaymentConditionCode + chr(2)  + string(t_iDInvoice.DInvoiceVoucher) (icArguments), 
                  input  '' (icFieldName), 
                  input  '' (icFieldValue), 
                  input  'E':U (icType), 
                  input  3 (iiSeverity), 
                  input  '' (icRowid), 
                  input  'QadFin-7437':U (icFcMsgNumber), 
                  input  '' (icFcExplanation), 
                  input  '' (icFcIdentification), 
                  input  '' (icFcContext), 
                  output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
             end.
        end.
        
        /* validate link to invoice */
        <M-65 run ValidateComponentAllLinkedInvoices
           (input-output vlStart1 (blStart1), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.    

        /* validate payment allowed, only applicable for credit notes */
        if t_sDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} and t_sDInvoice.DInvoiceIsPaymentAllowed = ?
        then do:
            assign vcMessage      = trim(#T-29'You must specify a value in the Payment Allowed field for credit notes.':150(1785)T-29#) + chr(10) +
                                    trim(substitute(#T-30'GL Calendar Year = &1; GL Period = &2; Daybook = &3; Voucher = &4.':255(969)T-30#,string(t_sDInvoice.DInvoicePostingYear),string(t_sDInvoice.DInvoicePostingPeriod), t_sDInvoice.tcJournalCode, string(t_sDInvoice.DInvoiceVoucher)))
                   oiReturnStatus = -1.
            <M-15 run SetMessage (input  vcMessage (icMessage), 
                         input  '':U (icArguments), 
                         input  'tDInvoice.DInvoiceType':U (icFieldName), 
                         input  t_sDInvoice.DInvoiceType (icFieldValue), 
                         input  'E':U (icType), 
                         input  3 (iiSeverity), 
                         input  t_sDInvoice.tc_Rowid (icRowid), 
                         input  'QADFIN-4457':U (icFcMsgNumber), 
                         input  '' (icFcExplanation), 
                         input  '' (icFcIdentification), 
                         input  '' (icFcContext), 
                         output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        end.

        /* if an invoice or credit note with the same amount, same invoice date, same debtor already exists, give warning */
        <M-16 run ValidateComponentAllCheckAmountDateDebt (input  t_sDInvoice.DInvoiceType (icDInvoiceType), 
                                                       input  t_sDInvoice.tdDInvoiceOriginalTC (idDInvoiceOriginalTC), 
                                                       input  t_sDInvoice.DInvoiceDate (itDInvoiceDate), 
                                                       input  t_sDInvoice.Debtor_ID (iiDebtorId), 
                                                       input  if t_sDInvoice.debtor_ID = 0 then t_sDInvoice.tcdebtorCode else '':U (icDebtorCode), 
                                                       input  t_sDInvoice.DInvoiceCurrency_ID (iiCurrencyId), 
                                                       input  if t_sDInvoice.DInvoiceCurrency_iD = 0 then t_sDInvoice.tcCurrencyCode else '':U (icCurrencyCode), 
                                                       input  t_sDInvoice.tc_Rowid (icRowId), 
                                                       input  t_sDInvoice.DInvoice_ID (iiDInvoiceId), 
                                                       output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.  

        /* CEE VAT Currency ================================================================= */
        /* If Vat currency = DInvoice currency, exchange rate must be 1                       */
        /* ================================================================================== */
        if t_sDInvoice.VatCurrency_ID            = t_sDInvoice.DInvoiceCurrency_ID and
           (t_sDInvoice.DInvoiceVatExchangeRate <> 1  or
            t_sDInvoice.DInvoiceVatRateScale    <> 1)
        then do:
            assign vcMessage      = #T-33'If the tax declaration currency matches the transactional currency, the tax exchange rate must be 1 (exchange rate: &1, scale factor: &2).':255(17000)T-33#
                   vcMessage      = trim(substitute(vcMessage, t_sDInvoice.DInvoiceVatExchangeRate, t_sDInvoice.DInvoiceVatRateScale))
                   oiReturnStatus = -1.
            <M-18 run SetMessage (input  vcMessage (icMessage), 
                          input  '':U (icArguments), 
                          input  'DInvoice.DInvoiceVatExchangeRate':U (icFieldName), 
                          input  t_sDInvoice.DInvoiceVatExchangeRate (icFieldValue), 
                          input  'E':U (icType), 
                          input  3 (iiSeverity), 
                          input  t_sDInvoice.tc_Rowid (icRowid), 
                          input  'QADFIN-4459':U (icFcMsgNumber), 
                          input  '' (icFcExplanation), 
                          input  '' (icFcIdentification), 
                          input  '' (icFcContext), 
                          output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        end.

        /* CEE VAT Currency If Vat currency = local currency, exchange rate must be the same as on the invoice */
        if t_sDInvoice.VatCurrency_ID             = viCompanyLCId                    and
           (t_sDInvoice.DInvoiceVatExchangeRate  <> t_sDInvoice.DInvoiceExchangeRate or
            t_sDInvoice.DInvoiceVatRateScale     <> t_sDInvoice.DInvoiceRateScale)
        then do:
            assign vcMessage      = #T-34'If the tax declaration currency matches the base currency, the tax exchange rate must be the same as the customer invoice exchange rate (customer invoice ex rate: &1, customer invoice scale: &2, Tax ex rate: &3, Tax scale: &4).':255(16999)T-34#
                   vcMessage      = trim(substitute(vcMessage, t_sDInvoice.DInvoiceExchangeRate, t_sDInvoice.DInvoiceRateScale, t_sDInvoice.DInvoiceVatExchangeRate, t_sDInvoice.DInvoiceVatRateScale))
                   oiReturnStatus = -1.
            <M-19 run SetMessage (input  vcMessage (icMessage), 
                          input  '':U (icArguments), 
                          input  'DInvoice.DInvoiceVatExchangeRate':U (icFieldName), 
                          input  t_sDInvoice.DInvoiceVatExchangeRate (icFieldValue), 
                          input  'E':U (icType), 
                          input  3 (iiSeverity), 
                          input  t_sDInvoice.tc_Rowid (icRowid), 
                          input  'QADFIN-4460':U (icFcMsgNumber), 
                          input  '' (icFcExplanation), 
                          input  '' (icFcIdentification), 
                          input  '' (icFcContext), 
                          output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        end.
    end. /* status = "N" */

    if t_sDInvoice.tc_Status = "N":U or t_sDInvoice.tc_Status = "C":U 
    then do:
        if vlStart2 = false
        then do:
           <Q-96 run DebtorByIDAllInfo  (Start) in BDebtor >
            assign vlStart2 = true.
        end.

        <Q-97 run DebtorByIDAllInfo (all) (Read) (NoCache)
           (input ?, (CompanyId)
            input t_sDInvoice.Debtor_ID, (DebtorID)
            output dataset tqDebtorByIDAllInfo) in BDebtor >
        find first tqDebtorByIDAllInfo where
                   tqDebtorByIDAllInfo.tiDebtor_ID = t_sDInvoice.Debtor_ID
                   no-error.
        if available tqDebtorByIDAllInfo 
        then do:
            assign viPrepayControlGLProfileID = tqDebtorByIDAllInfo.tiPrePayControlGLProfile_ID.

            /* check if division is filled when debtor control account is defined with divisions   Verify the analysis type on the customer control account and that the required fields are set */
            if ((t_sDInvoice.tc_Status      = "N":U                     or
                 t_sDInvoice.tc_Status      = "C":U                     and
                (t_sDInvoice.ControlGL_ID  <> t_iDInvoice.ControlGL_ID  or
                 t_sDInvoice.Division_ID   <> t_iDInvoice.Division_ID)) and
                (t_sDInvoice.Division_ID    = 0                         or
                 t_sDInvoice.Division_ID    = ?))                       or
                (t_sDInvoice.tc_Status      = "N":U                     or
                 t_sDInvoice.tc_Status      = "C":U                     and
                (t_sDInvoice.ControlGL_ID  <> t_iDInvoice.ControlGL_ID  or
                 t_sDInvoice.Project_ID    <> t_iDInvoice.Project_ID    or
                 t_sDInvoice.CostCentre_ID <> t_iDInvoice.CostCentre_ID))
            then do:                           
                <M-53 run ValidateComponentAllAnalysis
                   (input  t_sDInvoice.CostCentre_ID (iiCostCentreID), 
                    input  t_sDInvoice.tcCostCentreCode (icCostCentreCode), 
                    input  t_sDInvoice.Project_ID (iiProjectID), 
                    input  t_sDInvoice.tcDivisionCode (icDivisionCode), 
                    input  t_sDInvoice.ControlGL_ID (iiControlGLID), 
                    input-output vlstartGLForInvoice (blstartGLForInvoiceVal), 
                    input-output vlstartCostCentreWithSafs (blstartCostCentreForInvoice), 
                    input-output vlstartProjectWithSafs (blstartProjectForInvoice), 
                    output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
                if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
                then assign oiReturnStatus = viFcReturnSuper.   
            end.

            /* Check credit limit if the invoice is created initially. */
            /* Don't check credit limit if the invoice has operational data. */
            if t_sDInvoice.DInvoiceOriginalDebitTC <> 0 and
               t_sDInvoice.DInvoiceOriginalDebitTC <> ? and
               tqDebtorByIDAllInfo.tlDebtorIsCheckAftDICredLim and
               can-find(first t_sDInvoiceMovement where
                              t_sDInvoiceMovement.DInvoice_ID          = t_sDInvoice.DInvoice_ID and
                              t_sDInvoiceMovement.DInvoiceMovementType = {&MOVEMENTTYPE-INITIAL} and
                              t_sDInvoiceMovement.tc_Status            = 'N':U) and
               (not can-find(first t_sDInvoiceOpInfo where 
                                   t_sDInvoiceOpInfo.DInvoice_ID       = t_sDInvoice.DInvoice_ID))
            then do:
                if t_sDInvoice.tc_Status = "C":U
                then find t_iDInvoice where
                          t_iDInvoice.tc_Rowid = t_sDInvoice.tc_Rowid
                          no-error.
        
                assign vdOldAmount = if t_sDInvoice.tc_Status     = "N":U or
                                        t_sDInvoice.tcDebtorCode <> t_iDInvoice.tcDebtorCode
                                     then 0
                                     else t_iDInvoice.DInvoiceOriginalDebitTC.

                /* In some occasions, the Credit Limit check will lock the debtor. This needs to be done immediately in a separate transaction. */
                <I-57 {bFcStartAndOpenInstance
                     &ADD-TO-TRANSACTION = "false"
                     &CLASS              = "BDebtor"}>
                <M-24 run ApiCheckCreditLimit
                   (input  t_sDInvoice.Debtor_ID (iiDebtorId), 
                    input  t_sDInvoice.tcDebtorCode (icDebtorCode), 
                    input  t_sDInvoice.DInvoiceOriginalDebitTC (idCurrentAmount), 
                    input  vdOldAmount (idOldAmount), 
                    input  t_sDInvoice.tcCurrencyCode (icCurrencyCode), 
                    input  {&DEBTORCREDITLIMIT-AFTERDI} (icContext), 
                    input  t_sDInvoice.DInvoicePostingDate (itExchangeRateDate), 
                    output viExternalReturnStatus (oiReturnStatus)) in BDebtor>
                <I-56 {bFcCloseAndStopInstance
                     &CLASS           = "BDebtor"}>
                if viExternalReturnStatus < 0 or
                   oiReturnStatus  = 0
                then assign oiReturnStatus = viExternalReturnStatus.
            end.
        end.

        /* The sum of the payment bank account lines must be equal to the Invoice Amount TC */            
        if t_sDInvoice.DInvoiceType <> {&INVOICETYPE-PREPAYMENT} and
           t_sDInvoice.DInvoiceType <> {&INVOICETYPE-DEDUCTION} and
           can-find(first t_sDInvoiceBank where
                          t_sDInvoiceBank.tc_ParentRowid = t_sDInvoice.tc_Rowid and
                          t_sDInvoiceBank.tc_status      <> "D":U)
        then do:
            /* The sum of the payment bank account lines must be equal to the Invoice Amount TC */    
            for each t_sDInvoiceBank where
                     t_sDInvoiceBank.tc_ParentRowid = t_sDInvoice.tc_Rowid and
                     t_sDInvoiceBank.tc_Status      <> "D":U :
                    accumulate t_sDInvoiceBank.DInvoiceBankToPayTC (TOTAL).
            end. /* for each t_sCInvoiceBank */
            if (t_sDInvoice.DInvoiceBalanceDebitTC  <> 0 and t_sDInvoice.DInvoiceBalanceDebitTC  <> ? and (accum total t_sDInvoiceBank.DInvoiceBankToPayTC) <> t_sDInvoice.DInvoiceBalanceDebitTC ) or 
               (t_sDInvoice.DInvoiceBalanceCreditTC <> 0 and t_sDInvoice.DInvoiceBalanceCreditTC <> ? and (accum total t_sDInvoiceBank.DInvoiceBankToPayTC) <> t_sDInvoice.DInvoiceBalanceCreditTC)
            then do:
                assign vcMessage      = trim(substitute(#T-35'The sum of all payment bank account lines must be equal to the TC invoice amount (&1).':150(1194)T-35#,string(t_sDInvoice.tdDInvoiceOriginalTC))) + chr(10) +
                                        trim(substitute(#T-36'The credit balance amount of the customer invoice is &1.':255(65337)T-36#,string(t_sDInvoice.DInvoiceBalanceCreditTC)))  + chr(10) +
                                        trim(substitute(#T-37'The debit balance amount of the customer invoice is &1.':255(65338)T-37#,string(t_sDInvoice.DInvoiceBalanceDebitTC)))  + chr(10) +
                                        trim(substitute(#T-38'The accumulated bank lines amount is &1.':255(1197)T-38#,string((accum total t_sDInvoiceBank.DInvoiceBankToPayTC))))  + chr(10) +
                                        trim(substitute(#T-39'GL Calendar Year = &1; GL Period = &2; Daybook = &3; Voucher = &4.':255(969)T-39#,string(t_sDInvoice.DInvoicePostingYear),string(t_sDInvoice.DInvoicePostingPeriod), t_sDInvoice.tcJournalCode, string(t_sDInvoice.DInvoiceVoucher)))
                       oiReturnStatus = -1.
                <M-25 run SetMessage (input  vcMessage (icMessage), 
                          input  '':U (icArguments), 
                          input  'tDInvoice.tdDInvoiceOriginalTC':U (icFieldName), 
                          input  String(t_sDInvoice.tdDInvoiceOriginalTC) (icFieldValue), 
                          input  'E':U (icType), 
                          input  3 (iiSeverity), 
                          input  t_sDInvoice.tc_Rowid (icRowid), 
                          input  'QADFIN-4461':U (icFcMsgNumber), 
                          input  '' (icFcExplanation), 
                          input  '' (icFcIdentification), 
                          input  '' (icFcContext), 
                          output viFcReturnSuper (oiReturnStatus)) in BDInvoice>            
            end. /* if */
        end. /* sum of bank accounts */

        if t_sDInvoice.DInvoiceType <> {&INVOICETYPE-ADJUSTMENT} and
           t_sDInvoice.DInvoiceType <> {&INVOICETYPE-PREPAYMENT} and
           t_sDInvoice.DInvoiceType <> {&INVOICETYPE-DEDUCTION} and
           (t_sDInvoice.tcShipFromBusinessRelationCode = "":U or
           t_sDInvoice.tcShipToBusinessRelationCode   = "":U)
        then do:
            assign vcMessage      = #T-51'You must specify a ship-from address and ship-to address if the invoice type is &1, &2, &3, &4.while its impossible to post an Invoice to an Entity with an Inactive Business Relation':255(583923764)T-51#
                   vcMessage      = trim(substitute(vcMessage, {&INVOICETYPE-INVOICE-TR}, {&INVOICETYPE-CREDITNOTE-TR}, {&INVOICETYPE-INVOICECORRECTION-TR}, {&INVOICETYPE-CREDITNOTECORRECTION-TR}))
                   oiReturnStatus = -1.
            <M-50 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'DInvoice.DInvoiceType':U (icFieldName), 
                input  t_sDInvoice.DInvoiceType (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDInvoice.tc_Rowid (icRowid), 
                input  'QadFin-5496':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        end.

        <M-76 run ValidateComponentAllPost
           (input  viHOAddressTypeId (iiHOAddressTypeId), 
            input-output vlstartVatPeriodByStartEndDate (blstartVatPeriodByStartEndDate), 
            input-output vlstartJrnlByJrnIDCodeType (blStartJrnlByJrnlIDCodeType), 
            input-output vlstartPerByPerStartEndDate (blstartPerByPerStartEndDate), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>  
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.    
    end. /* tc_status = "N" or "C" */

    /* Bank */
    <M-47 run ValidateComponentAllBank
       (input-output vlStartPayFormatCodeByGroupID (blStartPayFormatCodeByGroupID), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.

    /* Movement */
    if can-find(first t_sDInvoiceMovement where
                  t_sDInvoiceMovement.DInvoice_ID          = t_sDInvoice.DInvoice_ID and
                  t_sDInvoiceMovement.DInvoiceMovementType = {&MOVEMENTTYPE-MOVEMENT} and
                  t_sDInvoiceMovement.tc_Status            = "N":U)
    then do:
        <M-113 run ValidateComponentAllMovement  (output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.
    end. /* if can-find(first t_sDInvoiceMovement where */

    if t_sDinvoice.tc_status = "C":U
    then do:
        /* Modification on Payment Account and TSM Number */
        <M-48 run ValidateComponentAllModify (output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.         
    end.
      
    <M-52 run ValidateComponentAllTax
       (input-output vlStartMfgTaxCodeByTaxCode (blStartMfgTaxCodeByTaxCode), 
        input-output vlStartCompPropBySuspDelTax (blStartCompPropBySuspDelTax), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.    

    if not ((t_sDInvoice.DInvoiceSlsPsn1 = '':U or t_sDInvoice.DInvoiceSlsPsn1 = ?) and
            (t_sDInvoice.DInvoiceSlsPsn2 = '':U or t_sDInvoice.DInvoiceSlsPsn2 = ?) and
            (t_sDInvoice.DInvoiceSlsPsn3 = '':U or t_sDInvoice.DInvoiceSlsPsn3 = ?) and
            (t_sDInvoice.DInvoiceSlsPsn4 = '':U or t_sDInvoice.DInvoiceSlsPsn4 = ?))
    then do:
        <M-92 run ValidateComponentAllSlspsn  (output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.
    end.

    if t_sDInvoice.DInvoiceShipToCode <> ? and t_sDInvoice.DInvoiceShipToCode <> "":U
    then do:
        <M-93 run ValidateComponentAllShipTo
           (input-output vlStartDebtorShipToPrim (blStartDebtorShipToPrim), 
            input-output vlStartLsMstrByAddrDomainType (blStartLsMstrByAddrDomainType), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.
    end.
end. /* for each */

<M-106 run ValidateComponentAllStopQueries
   (input  vlStart1 (ilStart1), 
    input  vlstart2 (ilStart2), 
    input  vlstartDebtorByDebtorCountry (ilStartDebtorByDebtorCountry), 
    input  vlstartGLForInvoice (ilStartGLForInvoice), 
    input  vlstartCostCentreWithSafs (ilStartCostCentreWithSafs), 
    input  vlstartProjectWithSafs (ilStartProjectWithSafs), 
    input  vlStartPayFormatCodeByGroupID (ilStartPayFormatCodeByGroupID), 
    input  vlStartDebtorShipToPrim (ilStartDebtorShipToPrim), 
    input  vlStartLsMstrByAddrDomainType (ilStartLsMstrByAddrDomainType), 
    input  vlStartMfgTaxCodeByTaxCode (ilStartMfgTaxCodeByTaxCode), 
    input  vlStartCompPropBySuspDelTax (ilStartCompPropBySuspDelTax), 
    output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.    

<M-58 run ValidateComponentAllJournal
   (input-output vlstartJrnlByJrnIDCodeType (blstartJrnlByJrnlIDCodeType), 
    output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.   

<M-327 run ValidateComponentAllBill  (output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.

if vcActivityCode = "Modify":U
then do:
    <M-9 run ValidateComponentAllDInvoiceOpInfo  (output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.
end. /* if vcActivityCode = "Modify":U */

if vlstartJrnlByJrnIDCodeType = true
then do:
    <Q-100 run JournalByJournalIDCodeType  (Stop) in BJournal >
end.