project QadFinancials > class BDDocument > method ValidateComponentPreDebtor

validation procedure


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDDocument.ValidateComponentPre


program code (program4/bddocument.p)

/* =================================================================================================== */
/* Method      : ValidateComponentPreDebtor                                                            */
/* Desc        : This method does additional updates on customer Bank Number                           */
/* --------------------------------------------------------------------------------------------------- */
/* Params:       none                                                                                  */
/* =================================================================================================== */
<Q-1 run BankNumberForParentObject  (Start) in BBankNumber >        
<Q-2 run BankNumberByID  (Start) in BBankNumber >
<Q-27 run DebtorPrim  (Start) in BDebtor >
<Q-4 run BankNumberPrim  (Start) in BBankNumber >
<Q-5 run BankNumberForCreditorDebtor  (Start) in BBankNumber >
for each t_sDDocument where
         t_sDDocument.tc_Status <> "D":U and
         t_sDDocument.tc_Status <> "":U:
    for each t_sDDocumentInvoiceXref where
             t_sDDocumentInvoiceXref.DDocument_ID = t_sDDocument.DDocument_ID and
             t_sDDocumentInvoiceXref.tc_Status <> "D":U and
             t_sDDocumentInvoiceXref.tc_Status <> "":U and
             t_sDDocumentInvoiceXref.tcDInvoiceType = {&INVOICETYPE-PREPAYMENT}:
        /* Get the customer id from the customer code */
        <Q-28 run DebtorPrim (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input t_sDDocument.tcDebtorCode, (DebtorCode)
            input ?, (Debtor_ID)
            output dataset tqDebtorPrim) in BDebtor >
        find first tqDebtorPrim
            where tqDebtorPrim.tcDebtorCode = t_sDDocument.tcDebtorCode no-error.
        if available tqDebtorPrim
        then do:
            assign t_sDDocument.Debtor_ID = tqDebtorPrim.tiDebtor_ID.
        end.
        else do:
            assign vcMsg          = #T-24'Customer does not exist (ID: $1).':255(71309)T-24#
                   oiReturnStatus = -1.
            <M-7 run SetMessage
               (input  vcMsg (icMessage), 
                input  string(t_sDDocument.tcDebtorCode) (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDDocument.tc_Rowid (icRowid), 
                input  'QadFin-8683':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDDocument>
            return.
        end.
    
        /* Check whether the bank number chosen has the same customer as the current customer */    
        <Q-8 run BankNumberForParentObject (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input t_sDDocument.Debtor_ID, (ParentObjectID)
            input t_sDDocument.BankNumber_ID, (BankNumber)
            input ?, (OwnBankNumber)
            input ?, (PayFormatTypeCode)
            output dataset tqBankNumberForParentObject) in BBankNumber >
        find first tqBankNumberForParentObject where
                   tqBankNumberForParentObject.tiBankNumber_ID = t_sDDocument.BankNumber_ID and
                   tqBankNumberForParentObject.tiParentObject_ID = t_sDDocument.Debtor_ID no-error.
        if not available tqBankNumberForParentObject
        then do:
            /* Get the Bank Number Infomation via Bank Number Id */
            <Q-9 run BankNumberPrim (all) (Read) (NoCache)
               (input t_sDDocument.BankNumber_ID, (BankNumberId)
                input ?, (ParentObjectId)
                input ?, (BankNumber)
                input ?, (BankNumberExtension)
                input ?, (BankPayFormatID)
                output dataset tqBankNumberPrim) in BBankNumber >
            find first tqBankNumberPrim 
                where tqBankNumberPrim.tiBankNumber_ID = t_sDDocument.BankNumber_ID no-error.
            if available tqBankNumberPrim
            then do:
                assign viBankPayFormatId      = tqBankNumberPrim.tiBankPayFormat_ID
                       vcBankNumberExtension  = tqBankNumberPrim.tcBankNumberExtension
                       vcBankNUmberValidation = tqBankNumberPrim.tcBankNumberValidation.
            end.
            else do:
                assign vcMsg          = #T-25'Bank Number does not exist (ID: $1).':255(71296)T-25#
                       oiReturnStatus = -1.
                <M-10 run SetMessage
                   (input  vcMsg (icMessage), 
                    input  string(t_sDDocument.BankNumber_ID) (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sDDocument.tc_Rowid (icRowid), 
                    input  'QadFin-8684':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BDDocument>
                return.
            end.
            /* Check whether the bank number has been defined before */
            <Q-11 run BankNumberForCreditorDebtor (all) (Read) (NoCache)
               (input t_sDDocument.Debtor_ID, (ParentObjectId)
                input t_sDDocument.tcDebtorBankNumber, (BankNumber)
                input vcBankNumberExtension, (BankNumberExtension)
                input viBankPayFormatId, (BankPayFormatID)
                input vcBankNumberValidation, (BankNumberValidation)
                output dataset tqBankNumberForCreditorDebtor) in BBankNumber >
            find first tqBankNumberForCreditorDebtor no-error.
            if not available tqBankNumberForCreditorDebtor
            then do:
                /* Create the bank number for customer if it does not exist before */
                <Q-12 run BankNumberByID (all) (Read) (NoCache)
                   (input t_sDDocument.BankNumber_ID, (BankNumber_ID)
                    input viCompanyId, (CompanyId)
                    output dataset tqBankNumberByID) in BBankNumber >
                find first tqBankNumberByID where
                           tqBankNumberByID.tiBankNumber_ID = t_sDDocument.BankNumber_ID no-error.
                if not available tqBankNumberByID
                then do:
                    assign vcMsg          = #T-26'The bank number specified is not defined in the system (ID: $1).':255(70311)t-26#
                           oiReturnStatus = -1.
                    <M-13 run SetMessage
                       (input  vcMsg (icMessage), 
                        input  string(t_sDDocument.BankNumber_ID) (icArguments), 
                        input  '':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sDDocument.tc_Rowid (icRowid), 
                        input  'QadFin-8685':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDDocument>
                    return.
                end. /* if not available tqBankNumberByID */
        
                /* start to create bank number copy for Customer */
                if viBBankNumber2ID = 0 or viBBankNumber2ID = ?
                    then do:
                        <I-14 {bFcStartAndOpenInstance
                             &ADD-TO-TRANSACTION = "true"
                             &CLASS              = "BBankNumber"}>
                    end.
                else do:
                    <I-15 {bFcOpenInstance
                         &CLASS           = "BBankNumber"}>
                end.
                /*
                <M-16 run CreateCDBankNumberAsCopy
                   (input  t_sDDocument.BankNumber_ID (iiOriginalBankNumberID), 
                    input  viBankPayFormatId (iiNewPayFormatID), 
                    output viDummy (oiNewBankNumberID), 
                    output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
                    */
                <M-17 run CreateBankNumberAsCopyCreditorDebtor
                   (input  t_sDDocument.BankNumber_ID (iiOriginalBankNumberID), 
                    input  viBankPayFormatId (iiNewPayFormatID), 
                    output viDummy (oiNewBankNumberID), 
                    input  t_sDDocument.tcDebtorBankNumber (icCreditorDebtorBankNumber), 
                    input  t_sDDocument.Debtor_ID (iiNewParentObjectId), 
                    output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
                if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
                if viFcReturnSuper < 0
                then do:
                    <I-18 {bFcCloseInstance
                         &CLASS           = "BBankNumber"}>
                    return.
                end.
                assign t_sDDocument.BankNumber_ID = viDummy.
            end.        
            else do:
                assign t_sDDocument.BankNumber_ID = tqBankNumberForCreditorDebtor.tiBankNumber_ID.
            end. /* if not available tqBankNumberForCreditorDebtor */
        end. /* end of if not tqBankNumberForParentObject */
    end. /* for each t_sDDocumentInvoiceXref */
end. /* for each t_sDDocument */
<Q-19 run BankNumberForCreditorDebtor  (Stop) in BBankNumber >
<Q-20 run BankNumberPrim  (Stop) in BBankNumber >
<Q-29 run DebtorPrim  (Stop) in BDebtor >
<Q-22 run BankNumberByID  (Stop) in BBankNumber >
<Q-23 run BankNumberForParentObject  (Stop) in BBankNumber >