project QadFinancials > class BDPaymentSelection > method StoreBankReference


Parameters


icInvoiceReferenceinputcharacter
icBankReferenceinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankImportLine.ProcessBankImpLineConfirm


program code (program1/bdpaymentselection.p)

 /* Try and find the invoice reference in the instance.  If its not there then load the records */
assign vlUpdates = false.
for each tDPaySelPayRef 
     where tDPaySelPayRef.DPaySelPayRefCode = icInvoiceReference:
     
     assign 
            vlUpdates = true
            tDPaySelPayRef.DPaySelPayRefBankRef = icBankReference
            tDPaySelPayRef.tc_Status = "C". 
              
end.
 
if not available tDPaySelPayRef     
then do:
     <Q-4 run DPaySelPayRefByCode (all) (Read) (NoCache)
        (input icInvoiceReference, (Code)
         input ?, (CompanyId)
         output dataset tqDPaySelPayRefByCode) in BDPaymentSelection>
         
    /* Build up a list of pay sel's to update*/                               
    for each tqDPaySelPayRefByCode 
       where tqDPaySelPayRefByCode.tcDPaySelPayRefCode = icInvoiceReference:
        if vcPaySels = ""
        then
            assign vcPaySels = string(tqDPaySelPayRefByCode.tiDPaySel_ID).
        else
            assign vcPaySels = vcPaySels + ',' + string(tqDPaySelPayRefByCode.tiDPaySel_ID).
    end.  

    /* If we could not find the invoice return an error */
    if vcPaySels = ""
    then do:
        assign 
            vcMessage =  #T-39'Could not find Invoice with reference $1 - Bank Reference $2 not updated':255(275560356)T-39#
            oiReturnStatus = -1.
            
        <M-34 run SetMessage
           (input  vcMessage (icMessage), 
            input  icInvoiceReference + chr(2) + icBankReference (icArguments), 
            input  '' (icFieldName), 
            input  '' (icFieldValue), 
            input  'E' (icType), 
            input  3 (iiSeverity), 
            input  '' (icRowid), 
            input  'qadfin-816622':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
         return.
    end.                          
    else do:
    
        <M-20 run DataLoad
           (input  '' (icRowids), 
            input  '' (icPkeys), 
            input  vcPaySels (icObjectIds), 
            input  '' (icFreeform), 
            input  true (ilKeepPrevious), 
            output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
        
        if viFcReturnSuper < 0 
        then do:
            assign 
                vcMessage =  #T-47'Could not find Invoice with reference $1 - Bank Reference $2 not updated':255(275560356)T-47#
                oiReturnStatus = -1.
                
            <M-52 run SetMessage
               (input  vcMessage (icMessage), 
                input  icInvoiceReference + chr(2) + icBankReference (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E' (icType), 
                input  3 (iiSeverity), 
                input  '' (icRowid), 
                input  'qadfin-208573':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
             return.        
       
        end.
               
        /* Assign the bank reference to the corresponding invoice reference */
        
        for each tDPaySelPayRef 
           where tDPaySelPayRef.DPaySelPayRefCode = icInvoiceReference:
           
           assign 
                vlUpdates = true
                tDPaySelPayRef.DPaySelPayRefBankRef = icBankReference
                tDPaySelPayRef.tc_Status = "C".                   
        end.                 
    
    end.
end.

if vlUpdates  
then do:
    <M-59 run ValidateBC  (output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
    if viFcReturnSuper < 0 or oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.
    
    <M-22 run AdditionalUpdates  (output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
    if viFcReturnSuper < 0 or oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.

end.