project QadFinancials > class BPaymentSelection > method FillProdataSetPaymentBankNumber


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.FillProDataSetPayment


program code (program7/bpaymentselection.p)

for each tPayment:
         <Q-21 run BankNumberByIDAllInfo (all) (Read) (NoCache)
            (input tPayment.BankNumber_ID, (BankNumber_ID)
             input ?, (BankNumberIsDefault)
             output dataset tqBankNumberByIDAllInfo) in BBankNumber >
        find first tqBankNumberByIDAllInfo no-error.
        if not available tqBankNumberByIDAllInfo 
        then do:
            <M-2 run SetMessage
               (input  #T-17'No bank number record is available.':50(999890608)T-17# (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'D':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-6466':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
        end. /* end of if not available tqBankNumberByIDAllInfo */
        else do:
            assign
                  vhBufferForProDataSet = dataset tqBankNumberByIDAllInfo:get-buffer-handle(1).
            for first tqBankNumberByIDAllInfo:
                find first tPaymentBankNumber where tPaymentBankNumber.BankNumber_ID = tqBankNumberByIDAllInfo.tiBankNumber_ID no-error.
                if not available tPaymentBankNumber 
                then do:
                    create tPaymentBankNumber.
                    <M-3 run BufferCopy
                       (input  vhBufferForProDataSet (ihFrom), 
                        input  buffer tPaymentBankNumber:handle (ihTo), 
                        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                    if viFcReturnSuper <> 0 
                    then assign oiReturnStatus = viFcReturnSuper.
                    if viFcReturnSuper < 0
                    then return. 

                    <Q-25 run BankAccFormatPrim (all) (Read) (Cache)
                       (input tPaymentBankNumber.BankAccFormat_ID, (BankAcctFormatId)
                        input ?, (BankAcctFormatCode)
                        output dataset tqBankAccFormatPrim) in BBankAccountFormat >
                    find first tqBankAccFormatPrim no-error.
                    if available tqBankAccFormatPrim then 
                        tPaymentBankNumber.tcBankAccFormatCode = tqBankAccFormatPrim.tcBankAccFormatCode.

                    if tPaymentBankNumber.BankBusinessRelation_ID <> 0
                    then do:
                        if tPaymentBankNumber.BankNumberBranch <> ? and tPaymentBankNumber.BankNumberBranch <> "":U
                        then do:                            
                            <Q-439 run BankBranchByUnqIdx (all) (Read) (NoCache)
                               (input tPaymentBankNumber.BankBusinessRelation_ID, (BusinessRelation_ID)
                                input tPaymentBankNumber.BankNumberBranch, (BankBranchCode)
                                output dataset tqBankBranchByUnqIdx) in BBankBranch>
                            find first tqBankBranchByUnqIdx no-error.
                            if available tqBankBranchByUnqIdx then do:
                                assign tPaymentBankNumber.tcBankBranchName1 = tqBankBranchByUnqIdx.tcBankBranchName1
                                       tPaymentBankNumber.tcBankBranchName2 = tqBankBranchByUnqIdx.tcBankBranchName2.
                            end. 
                        end.

                        <Q-4 run BusinessRelationByIDAllInfo (all) (Read) (NoCache)
                           (input tPaymentBankNumber.BankBusinessRelation_ID, (BusinessRelation_ID)
                            output dataset tqBusinessRelationByIDAllInfo) in BBusinessRelation >
                        find first tqBusinessRelationByIDAllInfo no-error.
                        if not available tqBusinessRelationByIDAllInfo
                        then do:
                            <M-5 run SetMessage
                               (input  #T-18'No business relation record is available.':50(49134)T-18# (icMessage), 
                                input  '':U (icArguments), 
                                input  '':U (icFieldName), 
                                input  '':U (icFieldValue), 
                                input  'D':U (icType), 
                                input  3 (iiSeverity), 
                                input  '':U (icRowid), 
                                input  'QadFin-6467':U (icFcMsgNumber), 
                                input  '':U (icFcExplanation), 
                                input  '':U (icFcIdentification), 
                                input  '':U (icFcContext), 
                                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                         
                            assign
                                oiReturnStatus = -1.
                            return.                        
                        end. /* end of if not available tqBusinessRelationByIDAllInfo */
                        else do:
                            assign
                                vhBufferForBusinessRelation = dataset tqBusinessRelationByIDAllInfo:get-buffer-handle(1).
                        
                            for first tqBusinessRelationByIDAllINfo:
                               find first tPaymentBankBusRel 
                                  where tPaymentBankBusRel.BusinessRelation_ID = tqBusinessRelationByIDAllInfo.tiBusinessRelation_ID no-error. 
                               if not available tPaymentBankBusRel
                               then do: /* to avoid duplicate key issue */
                                create tPaymentBankBusRel.
                                <M-6 run BufferCopy
                                   (input  vhBufferForBusinessRelation (ihFrom), 
                                    input  buffer tPaymentBankBusRel:handle (ihTo), 
                                    output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>                            
                                if viFcReturnSuper <> 0 
                                then assign oiReturnStatus = viFcReturnSuper.
                                if viFcReturnSuper < 0
                                then return. 
                               end. /* if not available tPaymentBankBusRel */

                          
                                <Q-7 run ContactByIDAllInfo (all) (Read) (NoCache)
                                   (input tPaymentBankBusRel.BusinessRelation_ID, (BusinessRelation_ID)
                                    output dataset tqContactByIDAllInfo) in BBusinessRelation >
                                assign
                                    vhBufferForContact = dataset tqContactByIDAllInfo:get-buffer-handle(1).
                                for each tqContactByIDAllInfo:
                                  find first tPaymentBankContact where tPaymentBankContact.Contact_ID = tqContactByIDAllInfo.tiContact_ID no-error.
                                  if not available tPaymentBankContact
                                  then do: /* to avoid duplicate key issue */
                                    create tPaymentBankContact.
                                    <M-8 run BufferCopy
                                       (input  vhBufferForContact (ihFrom), 
                                        input  buffer tPaymentBankContact:handle (ihTo), 
                                        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                    if viFcReturnSuper <> 0 
                                    then assign oiReturnStatus = viFcReturnSuper.
                                    if viFcReturnSuper < 0
                                    then return.  
                                  end.
                                end. /*for each tqContactByIDAllInfo*/
                          
                                <Q-9 run AddressByIDsAllInfo (all) (Read) (NoCache)
                                   (input tPaymentBankBusRel.BusinessRelation_ID, (BusinessRelation_ID)
                                    input viAddressType_ID, (AddressType_ID)
                                    output dataset tqAddressByIDsAllInfo) in BBusinessRelation >
                                find first tqAddressByIDsAllInfo no-error.
                                if not available tqAddressByIDsAllInfo 
                                then do:
                                    <M-22 run SetMessage
                                       (input  #T-21'No address record is available for the bank.':255(999890609)T-21# (icMessage), 
                                        input  '':U (icArguments), 
                                        input  '':U (icFieldName), 
                                        input  '':U (icFieldValue), 
                                        input  'D':U (icType), 
                                        input  3 (iiSeverity), 
                                        input  '':U (icRowid), 
                                        input  'QadFin-6897':U (icFcMsgNumber), 
                                        input  '':U (icFcExplanation), 
                                        input  '':U (icFcIdentification), 
                                        input  '':U (icFcContext), 
                                        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
    
                                    assign
                                        oiReturnStatus = -1.
                                    return.
                                end. /* end of if not available tqAddressByIDsAllInfo */
                                else do:
                                    assign
                                    vhBufferForAddress = dataset tqAddressByIDsAllInfo:get-buffer-handle(1).
                                    for first tqAddressByIDsAllInfo:
                                      find first tPaymentBankAddress where tPaymentBankAddress.Address_ID = tqAddressByIDsAllInfo.tiAddress_ID no-error.
                                      if not available tPaymentBankAddress
                                      then do: /* to avoid duplicate key issue */
                                        create tPaymentBankAddress.
                                        <M-11 run BufferCopy
                                       (input  vhBufferForAddress (ihFrom), 
                                        input  buffer tPaymentBankAddress:handle (ihTo), 
                                        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                        if viFcReturnSuper <> 0 
                                        then assign oiReturnStatus = viFcReturnSuper.
                                        if viFcReturnSuper < 0
                                        then return.
                                      end.
    
                                      find first tPaymentBankCountry where tPaymentBankCountry.Country_ID = tPaymentBankAddress.Country_ID no-error.
                                      if not available tPaymentBankCountry and tPaymentBankAddress.Country_ID <>0 
                                      then do:
                                        <Q-12 run CountryByIDAllInfo (all) (Read) (NoCache)
                                           (input tPaymentBankAddress.Country_ID, (Country_ID)
                                            output dataset tqCountryByIDAllInfo) in BCountry >
                                        find first tqCountryByIDAllInfo no-error.
                                        if not available tqCountryByIDAllInfo 
                                        then do:
                                             <M-23 run SetMessage
                                                (input  #T-22'No country record found for this bank.':200(999890610)T-22# (icMessage), 
                                                 input  '':U (icArguments), 
                                                 input  '':U (icFieldName), 
                                                 input  '':U (icFieldValue), 
                                                 input  'D':U (icType), 
                                                 input  3 (iiSeverity), 
                                                 input  '':U (icRowid), 
                                                 input  'QadFin-6898':U (icFcMsgNumber), 
                                                 input  '':U (icFcExplanation), 
                                                 input  '':U (icFcIdentification), 
                                                 input  '':U (icFcContext), 
                                                 output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                            assign
                                                oiReturnStatus = -1.
                                            return.
                                        end. /* end of if not available tqCountryByIDAllInfo */
                                        else do:
                                            assign
                                                vhBufferForCountry = dataset tqCountryByIDAllInfo:get-buffer-handle(1).
                                            for first tqCountryByIDAllInfo:
                                              find first tPaymentBankCountry where tPaymentBankCountry.Country_ID = tqCountryByIDAllInfo.tiCountry_ID no-error.
                                              if not available tPaymentBankCountry
                                              then do: /* to avoid duplicate key issue */
                                                create tPaymentBankCountry.
                                                <M-14 run BufferCopy
                                                   (input  vhBufferForCountry (ihFrom), 
                                                    input  buffer tPaymentBankCountry:handle (ihTo), 
                                                    output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                                if viFcReturnSuper <> 0 
                                                then assign oiReturnStatus = viFcReturnSuper.
                                                if viFcReturnSuper < 0
                                                then return.  
                                              end. /* to avoid duplicate key issue */
                                            end. /* for each tqCountryByIDAllInfo*/
                                        end. /* tqCountryAllInfo else do */
                                    end. /* if tPaymentBankAddress.Country_ID <>0 */
                                    find first tPaymentBankState where tPaymentBankState.State_ID = tPaymentBankAddress.State_ID no-error.
                                    if not available tPaymentBankState and tPaymentBankAddress.State_ID<>0
                                    then do:
                                        <Q-15 run StateByIDAllInfo (all) (Read) (NoCache)
                                           (input tPaymentBankAddress.State_ID, (State_ID)
                                            output dataset tqStateByIDAllInfo) in BState >
                                        assign
                                            vhBufferForState = dataset tqStateByIDAllInfo:get-buffer-handle(1).
                                        for each tqStateByIDAllInfo:
                                          find first tPaymentBankState where tPaymentBankState.State_ID = tqStateByIDAllInfo.tiState_ID no-error.
                                          if not available tPaymentBankState
                                          then do: /* to avoid duplicate key issue */
                                            create tPaymentBankState.
                                            <M-16 run BufferCopy
                                               (input  vhBufferForState (ihFrom), 
                                                input  buffer tPaymentBankState:handle (ihTo), 
                                                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
                                            if viFcReturnSuper <> 0      
                                            then assign oiReturnStatus = viFcReturnSuper.                                            
                                          end. /* to avoid dupliate key issue */
                                        end. /* for each tqStataByIDAllInfo */
                                    end. /* if tBankAddress.State_ID<>0 */
                                end. /* for each tqAddressByIDAllInfo */
                            end. /* tqAddressAllInfo else do */
                        end. /* for each tqBusinessRelationByIDAllInfo */
                    end. /* tqBusinessRelationByIDAllInfo else do */
                end. /*  if tPaymentBankNumber.BankBusinessRelation_ID <> 0*/    
                vdBankNumberSum = vdBankNumberSum + decimal(tPaymentBankNumber.BankNumber) no-error.
                end. /* if not available tPaymentBankNumber */
            end. /* for first tqBankNumberByParentAllInfo */
        end. /* if not available tqBankNumberByParentAllInfo else do*/
    end. /* for each tPaymentCreditor */
for each tPaymentPaySel:
        tPaymentPaySel.tcBankNumberSum = string(vdBankNumberSum).
end.