project QadFinancials > class BDebtor > method PreValidateComponent


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDebtor.ValidateComponent


program code (program1/bdebtor.p)

for each t_sDebtor:
    if   t_sDebtor.tc_Status <> "D":U and
        (t_sDebtor.DebtorCode <> ?    and
         t_sDebtor.DebtorCode <> "":U)
    then assign  t_sDebtor.DebtorCode = trim(t_sDebtor.DebtorCode).

    /* ====================================================================== */
    /* Backwards compatibility : fill new mandatory field when not filled yet */
    /* ====================================================================== */
    if t_sDebtor.DebtorIsPrintBillWithItemDet = ? 
    then assign t_sDebtor.DebtorIsPrintBillWithItemDet = false.
    
    /* ====================================================================== */
    /* Synchronize tc_Status between tDebtor and tBankNumberRefDebtor.        */
    /* ====================================================================== */
    case t_sDebtor.tc_Status:
        when 'D':U
        then do:
            for each tBankNumberRefDebtor where 
                     tBankNumberRefDebtor.BankNumberParentType = {&BANKNUMBERPARENTTYPE-DEBTOR} and
                     tBankNumberRefDebtor.ParentObject_ID      = t_sDebtor.Debtor_ID:
                 assign tBankNumberRefDebtor.tc_Status = "D":U.
            end.
        end.

        when '':U
        then do:
            if can-find(first tBankNumberRefDebtor where
                              tBankNumberRefDebtor.BankNumberParentType =  {&BANKNUMBERPARENTTYPE-DEBTOR} and
                              tBankNumberRefDebtor.ParentObject_ID      =  t_sDebtor.Debtor_ID            and
                              tBankNumberRefDebtor.tc_Status            <> '':U)
            then assign t_sDebtor.tc_Status = 'C':U.
        end.
        
        when 'N':U
        then do:
            /* Check for an automatic number for debtor */
            if t_sDebtor.DebtorCode = '':U or
               t_sDebtor.DebtorCode = ?
            then do:
                assign vhFcComponent = ?.
                <M-1 run GetAutoNumber
                   (input  t_sDebtor.tc_Rowid (icRowid), 
                    output t_sDebtor.DebtorCode (ocDebtorCode), 
                    output viFcReturnSuper (oiReturnStatus)) in BDebtor>
                if viFcReturnSuper <> 0
                then assign oiReturnStatus = viFcReturnSuper.
                if viFcReturnSuper < 0
                then return.
            end.
        end.
        
    end. /* case t_sDebtor.tc_Status: */ 
    
    if t_sDebtor.DebtorIsOverruleSOCredLim <> true  and
        t_sDebtor.tc_Status <> "D":U
    then do:
        assign oiReturnStatus = -1
        vcMessage = substitute(trim(#T-2'Overrule Allowed for order entry should be checked for customer &1':255(27350774)T-2#),t_sDebtor.DebtorCode) .
        
        <M-7 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tDebtor.DebtorIsOverruleSOCredLim':U (icFieldName), 
            input  t_sDebtor.DebtorIsOverruleSOCredLim (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sDebtor.tc_Rowid (icRowid), 
            input  'qadfin-645745':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDebtor>
    end.

end. /* for each t_sDebtor: */