project QadFinancials > class BDDocument > method PayOrBounceDDocuments

Description

This method receives a temp-table with documents that need to be paid (conditionally) or bounced.


Parameters


tDDocumentsToPayOrBounceinputtemp-tableDocuments that need to be paid (conditionally) or bounced
iiBJournalEntryIdinputintegerinstance ID of BJournalEntry
iiBDInvoiceIdinputintegerinstance of BDInvoice
ilClearDatainputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankEntry.AdditionalUpdatesInvDocuments


program code (program3/bddocument.p)

if ilClearData
then do:
    <M-3 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BDDocument>

    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.

    if oiReturnStatus < 0
    then return.
end.

assign vcPKeys               = "":U
       viBDInvoiceDDocID     = iiBDInvoiceId
       viBJournalEntryDDocID = iiBJournalEntryId.

for each tDDocumentsToPayOrBounce where
         tDDocumentsToPayOrBounce.tiDDocumentId <> 0 and
         tDDocumentsToPayOrBounce.tiDDocumentId <> ?:
    if vcPKeys <> "":U
    then assign vcPKeys = vcPKeys + chr(4).

    assign vcPKeys = vcPKeys + string(tDDocumentsToPayOrBounce.tiDDocumentId).
end.

if vcPKeys = "":U
then return.

<M-1 run DataLoad (input  '':U (icRowids), 
                   input  vcPKeys (icPkeys), 
                   input  '':U (icObjectIds), 
                   input  '':U (icFreeform), 
                   input  not ilClearData (ilKeepPrevious), 
                   output viFcReturnSuper (oiReturnStatus)) in BDDocument>

if viFcReturnSuper < 0 or
   oiReturnStatus  = 0
then assign oiReturnStatus = viFcReturnSuper.

if oiReturnStatus < 0
then return.

for each tDDocumentsToPayOrBounce where
         tDDocumentsToPayOrBounce.tiDDocumentId <> 0 and
         tDDocumentsToPayOrBounce.tiDDocumentId <> ?:
    find tDDocument where
         tDDocument.DDocument_ID = tDDocumentsToPayOrBounce.tiDDocumentId
         no-error.

    if not available tDDocument
    then do:
        <M-2 run SetMessage
          (input  trim(#T-5'The previously loaded customer payment (ID: $1) could not be found.':250(1661)t-5#) (icMessage), 
           input  string(tDDocumentsToPayOrBounce.tiDDocumentId) (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-2482':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDDocument>

        assign oiReturnStatus = -1.
        return.
    end.

    assign tDDocument.DDocumentStatus = if tDDocumentsToPayOrBounce.tlDDocumentIsBounced
                                        then {&DOCUMENTSTATUS-BOUNCED}
                                        else
                                        if tDDocument.DDocumentStatus = {&DOCUMENTSTATUS-INCASSO}
                                        then {&DOCUMENTSTATUS-PAID}
                                        else {&DOCUMENTSTATUS-PAIDCON}
           tDDocument.ttPostingDate   = tDDocumentsToPayOrBounce.ttPostingDate
           tDDocument.tc_Status       = "C":U
           tDDocument.tcPostingRowId  = tDDocumentsToPayOrBounce.tcPostingRowidDDoc
           tDDocument.tcExternalUniqueIdentifier = tDDocumentsToPayorBounce.tcBankImpLineRowID.
end.