project QadFinancials > class BDebtor > method PostValidateComponent

Description

PostValidateComponent


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDebtor.ValidateComponent


program code (program1/bdebtor.p)

assign vlQueryStartedBusRelByIDAllInfo = false.

/*Validates all New and Changed Debtors*/
for each t_sDebtor:
 
    if t_sDebtor.tc_Status = "N":U or
       t_sDebtor.tc_Status = "C":U
    then do:
        if vlQueryStartedBusRelByIDAllInfo = false
        then do:
            <Q-35 run BusinessRelationByIDAllInfo  (Start) in BBusinessRelation >
            assign vlQueryStartedBusRelByIDAllInfo = true.
        end.

        /* Check if the business relation of this debtor should be systemwide or belong to this domain */
        <Q-31 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
           (input t_sDebtor.BusinessRelation_ID, (BusinessRelation_ID)
            output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >
        if can-find(tqBusinessRelationByIdAllInfo where
                    tqBusinessRelationByIdAllInfo.tiBusinessRelation_ID        = t_sDebtor.BusinessRelation_ID and
                    tqBusinessRelationByIDAllInfo.tlBusinessRelationIsDomRestr = true                          and
                    tqBusinessRelationByIDAllInfo.tiDomain_ID                 <> viDomainID)
        then do:
            assign vcMessage      = trim(#T-33'The selected business relation cannot be used in this domain.':255(69676)t-33#) + chr(10) +
                                    trim(#T-34'The business relation was defined as domain specific in another domain.':255(69677)t-34#)
                   oiReturnStatus = -1.
            <M-32 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tDebtor.tcBusinessRelationCode':U (icFieldName), 
                input  t_sDebtor.tcBusinessRelationCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDebtor.tc_Rowid (icRowid), 
                input  'QadFin-8254':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        end.

        /* shared set for debtor can not be used in several domains when business relation is domain specific */
        if can-find(tqBusinessRelationByIDAllInfo where
                    tqBusinessRelationByIDAllInfo.tiBusinessRelation_ID        = t_sDebtor.BusinessRelation_ID and
                    tqBusinessRelationByIDAllInfo.tlBusinessRelationIsDomRestr = true)
        then do:
            /* If more then one domain found for this shared set --> Business Relation can't be domain specific */
            <Q-37 assign vlFcQueryRecordsAvailable = DomainBySharedSetDomain (NoCache)
               (input t_sDebtor.SharedSet_ID, (SharedSetId)
                input 0, (DomainID)
                input '':U, (DomainCode)) in BDomain >
            if vlFcQueryRecordsAvailable = ?
            then do:
                assign vcMessage      = trim(#T-39'The customer shared set is used in several domains. You cannot use a domain-specific business relation for this customer.':255(69710)t-39#)
                       oiReturnStatus = -1.
                <M-38 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tDebtor.tcBusinessRelationCode':U (icFieldName), 
                    input  t_sDebtor.tcBusinessRelationCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDebtor.tc_Rowid (icRowid), 
                    input  'QadFin-8264':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDebtor>
            end. /* if vlFcQueryRecordsAvailable = ? */
        end.

        <M-27 run ValBankNumberandPayCodeRef (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.
    end.

    if t_sDebtor.tc_Status <> "N":U and
       t_sDebtor.tc_Status <> "C":U and
       not can-find(first t_sDebtorSafDefault where
                          t_sDebtorSafDefault.tc_ParentRowid = t_sDebtor.tc_Rowid and
                         (t_sDebtorSafDefault.tc_Status = 'N':U or
                          t_sDebtorSafDefault.tc_Status = 'C':U))
    then next.
    
    if t_sDebtor.tc_Status = "N":U or
       t_sDebtor.tc_Status = "C":U
    then do:
        /*BusinessRelation*/      
        <M-1 run ValBusinessRelation (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*Currency*/
        <M-2 run ValCurrency (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValDivisionProfile*/
        <M-3 run ValDivisionProfile (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
       
        /*ValInvControlGLProfile*/
        <M-4 run ValInvControlGLProfile (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValCnControlGLProfile*/
        <M-5 run ValCnControlGLProfile (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValPrePayControlGLProfile*/
        <M-29 run ValPrePayControlGLProfile  (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValDeductionControlGLProfile*/
        <M-65 run ValDeductionCtrlGLProfile  (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValSalesAccountGLProfile*/
        <M-24 run ValSalesAccountGLProfile (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValNormalPaymentCondition*/
        <M-6 run ValNormalPaymentCondition (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValReasonCode*/
        <M-9 run ValReasonCode (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /*ValBLWIGroup*/
        <M-11 run ValBLWIGroup (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /* Credit Limit */
        <M-21 run ValCreditLimit (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.
        /* Bill To */
        <M-26 run ValDebtorBillTo (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.

        /* Validate Federal Tax */
        <M-56 run ValFederalTax  (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.

         /* Validate State Tax */
        <M-28 run ValStateTax
           (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper.  

        /* Validate Finance Charge Profile */
        <M-30 run ValFinanceChargeProfile  (output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = if (oiReturnStatus  > 0 and 
                                    viFcReturnSuper = 0) or 
                                    oiReturnStatus  < 0
                                then oiReturnStatus
                                else viFcReturnSuper. 

    end.

    /* Saf Code vs Saf Concept */
    if can-find(first t_sDebtorSafDefault where
                      t_sDebtorSafDefault.tc_ParentRowid = t_sDebtor.tc_Rowid and
                     (t_sDebtorSafDefault.tc_Status = 'N':U or
                      t_sDebtorSafDefault.tc_Status = 'C':U))
    then do:
        <Q-15 run SafPrim (Start) in BSaf >
        
        for each t_sDebtorSafDefault where
                 t_sDebtorSafDefault.tc_ParentRowid = t_sDebtor.tc_Rowid and
                (t_sDebtorSafDefault.tc_Status = 'N':U or
                 t_sDebtorSafDefault.tc_Status = 'C':U):
        
            if t_sDebtorSafDefault.Saf_ID = -1
            then assign t_sDebtorSafDefault.Saf_ID = ?.
        
            if t_sDebtorSafDefault.Saf_ID <> 0 and
               t_sDebtorSafDefault.Saf_ID <> ?
            then do:
                <Q-16 run SafPrim (all) (Read) (Cache)
                   (input t_sDebtorSafDefault.Saf_ID, (SafID)
                    input t_sDebtorSafDefault.tcSafCode, (SafCode)
                    input ?, (SafConceptCode)
                    output dataset tqSafPrim) in BSaf >
                find first tqSafPrim where
                           tqSafPrim.tcSafCode        = t_sDebtorSafDefault.tcSafCode and
                           tqSafPrim.tcSafConceptCode = t_sDebtorSafDefault.tcSafConceptCode
                           no-error.
                if not available tqSafPrim
                then do:
                    assign vcMessage = trim(substitute(#T-20'The SAF value &3 does not belong to SAF concept &2 for customer &1.':200(1676)t-20#, trim(t_sDebtor.DebtorCode), trim(string(t_sDebtorSafDefault.tcSafConceptCode)), trim(string(t_sDebtorSafDefault.tcSafCode)))).
                    <M-19 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tDebtorSafDefault.tcSafCode':U (icFieldName),
                     input  string(t_sDebtorSafDefault.tcSafCode) (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  t_sDebtor.tc_Rowid (icRowid),
                     input  'QADFIN-2201':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BDebtor>       
                    assign oiReturnStatus = -1.
                end.
            end.
        end.
        
        <Q-18 run SafPrim (Stop) in BSaf >
    end.                            
end.

if vlQueryStartedBusRelByIDAllInfo = true
then do:
    <Q-36 run BusinessRelationByIDAllInfo  (Stop) in BBusinessRelation >
    assign vlQueryStartedBusRelByIDAllInfo = false.
end.

/* =========================================================================== *
 * Stop Format validation component                                            *
 * =========================================================================== */
if valid-handle(vhBFormatSetBDebInst)
then do:
    <I-727 {bFcCloseAndStopInstance
         &CLASS           = "BFormatSet"}>
end.
else if viBFormatSetBDebID <> ? and
        viBFormatSetBDebID <> 0
then do:
    <I-96 {bFcStopInstance
         &CLASS           = "BFormatSet"}>
end.