project QadFinancials > class BDCollectionReport > method DCollectionReport

report procedure


Parameters


icLanguageCodeinputcharacter
tFilterinputtemp-table
dcrDCollectionReportoutputdataset
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bdcollectionreport.p)

empty temp-table tqDCollectionReport.
empty temp-table tqDetailAttributes.

/*empty temp-table tqHeader.*/
/* ========================================================== */ 
/* Assign the filter-data-items based on the tFilter records  */
/* ========================================================== */ 
<M-7 run GetReportLabels (input  'DCollectionReport':U (icReportName), 
                          input  icLanguageCode (icLanguageCode), 
                          input  tFilter (tFilter), 
                          output tqHeader (tqHeader), 
                          output tqFilter (tqFilter), 
                          output tqText (tqText), 
                          output oiReturnStatus (oiReturnStatus)) in BDCollectionReport>

if oiReturnStatus <> 0
then return.

<M-8 run SetDataItemsBasesOnFilterTT (output oiReturnStatus (oiReturnStatus)) in BDCollectionReport>

                                 
<Q-19 run DCollectionByReference (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input vdFilterDColFromAmount, (FromAmount)
    input vdFilterDColTillAmount, (TillAmount)
    input vtFilterDColFromCreationDate, (FromCreationDate)
    input vtFilterDColTillCreationDate, (TillCreationDate)
    input viFilterDColFromCreationTime, (FromCreationTime)
    input viFilterDColTillCreationTime, (TillCreationTime)
    input vcFilterDCollectionNumber, (Reference)
    input vcFilterDColUser, (User)
    input vcFilterDColIncSelCode, (IncSelCode)
    input vlFilterDColIsExecuted, (IsExecuted)
    input vlFilterDColIsAutomatic, (IsAutomatic)
    input vcFilterDColGLCode, (GLCode)
    input ?, (BankFileFormat)
    output dataset tqDCollectionByReference) in BDCollectionReport >                                 

<Q-10 run DCollectionOwnBankNumber (Start) in BDCollectionReport >
for each tqDCollectionByReference:
  create tqDCollectionReport.
  buffer-copy tqDCollectionByReference to tqDCollectionReport.
  assign tqDCollectionReport.tiDCollRepNumber           = tqDCollectionByReference.tiDCollectionNumber
         tqDCollectionReport.tiDCollRepYear             = tqDCollectionByReference.tiDCollectionYear
         tqDCollectionReport.tcDCollRepReference        = tqDCollectionByReference.tcDCollectionReference
         tqDCollectionReport.ttDCollRepLastModDate      = tqDCollectionByReference.ttLastModifiedDate
         tqDCollectionReport.tcDCollRepLastModUser      = tqDCollectionByReference.tcLastModifiedUser
         tqDCollectionReport.ttDCollRepCreationDate     = tqDCollectionByReference.ttDDocumentCreationDate
         tqDCollectionReport.tcDCollRepCreationTime     = STRING(tqDCollectionByReference.tiDCollectionCreationTime,"hh:mm:ss")
         tqDCollectionReport.tcDCollRepCreationUser     = tqDCollectionByReference.tcUsrName
         tqDCollectionReport.tcDCollRepBankFileFormat   = tqDCollectionByReference.tcDCollectionBankFileFormat
         tqDCollectionReport.tlDCollRepIsAutomatic      = tqDCollectionByReference.tlDCollectionIsAutomatic
         tqDCollectionReport.tlDCollectionIsExexuted    = tqDCollectionByReference.tlDCollectionIsExecuted
         tqDCollectionReport.tiDCollRepGLID             = tqDCollectionByReference.tiDCollectionGL_ID
         tqDCollectionReport.tdDCollRepBalanceTC        = tqDCollectionByReference.tdDCollectionBalanceTC
         tqDCollectionReport.tcDCollRepGLCode           = tqDCollectionByReference.tcGLCode
         tqDCollectionReport.tcDCollRepBRCode           = tqDCollectionByReference.tcBusinessRelationCode
         tqDCollectionReport.tcDCollRepBRName1          = tqDCollectionByReference.tcBusinessRelationName1
         tqDCollectionReport.tcDCollRepBRName2          = tqDCollectionByReference.tcBusinessRelationName2
         tqDCollectionReport.tcDCollRepDDocType         = tqDCollectionByReference.tcDDocumentType
         tqDCollectionReport.tiDCollRepDDocYear         = tqDCollectionByReference.tiDDocumentYear
         tqDCollectionReport.tiDCollRepDDocNumber       = tqDCollectionByReference.tiDDocumentNumber
         tqDCollectionReport.tcDCollRepDDocStatus       = tqDCollectionByReference.tcDDocumentStatus
         tqDCollectionReport.tcDCollRepDDocReference    = tqDCollectionByReference.tcDDocumentReference
         tqDCollectionReport.ttDCollRepDDocDueDate      = tqDCollectionByReference.ttDDocumentDueDate
         tqDCollectionReport.tiDCollRepDDocValueDays    = tqDCollectionByReference.tiDDocumentValueDays
         tqDCollectionReport.tdDCollRepDDocAmountTC     = tqDCollectionByReference.tdDDocumentOriginalDebitTC - tqDCollectionByReference.tdDDocumentOriginalCreditTC
         tqDCollectionReport.tcDCollRepCurrency         = tqDCollectionByReference.tcCurrencyCode
         tqDCollectionReport.tdDCollRepDDocAmountLC     = tqDCollectionByReference.tdDDocumentOriginalDebitLC - tqDCollectionByReference.tdDDocumentOriginalCreditLC
         tqDCollectionReport.ttDCollRepDDocCreationDate = tqDCollectionByReference.ttDDocumentCreationDate
         tqDCollectionReport.ttDCollRepLastPrintedDate  = tqDCollectionByReference.ttDDocumentLastPrintDate
         tqDCollectionReport.tiDCollRepDDocTimesPrinted = tqDCollectionByReference.tiDDocumentTimesPrinted
         tqDCollectionReport.tcDCollRepIncSelCode       = tqDCollectionByReference.tcDDocumentIncassoSelectCode
         tqDCollectionReport.tiDCollRepDocumentID       = tqDCollectionByReference.tiDDocument_ID
         tqDCollectionReport.tiDCollRepBankNumberID     = tqDCollectionByReference.tiBankNumber_ID.
/*         tqDCollectionReport.tiDCollRepInvoiceID        = tqDCollectionByReference.tiDInvoice_ID. */

        /* Find first DInvoice for payment.  All invoices for */
        /* a payment will have the same payment attributes    */
        <Q-20 run DDocuInvoiceXrefbyIdAllInfo (all) (Read) (NoCache)
           (input ?, (CompanyID)
            input tqDCollectionByReference.tiDDocument_ID, (DocumentID)
            output dataset tqDDocuInvoiceXrefbyIdAllInfo) in BDDocument >
        for first tqDDocuInvoiceXrefByIdAllInfo where
            tqDDocuInvoiceXrefbyIdAllInfo.tiDDocument_ID = tqDCollectionByReference.tiDDocument_ID:
            tqDCollectionReport.tiDCollRepInvoiceID = tqDDocuInvoiceXrefbyIdAllInfo.tiDInvoice_ID.
        end.

        case tqDCollectionByReference.tcDDocumentStatus:
            when {&DOCUMENTSTATUS-INCASSO}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-INCASSO-TR}.
            when {&DOCUMENTSTATUS-ACCEPT}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-ACCEPT-TR}. 
            when {&DOCUMENTSTATUS-BOUNCED}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-BOUNCED-TR}. 
            when {&DOCUMENTSTATUS-DISCONT}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-DISCONT-TR}. 
            when {&DOCUMENTSTATUS-INIT}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-INIT-TR}. 
            when {&DOCUMENTSTATUS-PAID}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-PAID-TR}. 
            when {&DOCUMENTSTATUS-PAIDCON}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-PAIDCON-TR}. 
            when {&DOCUMENTSTATUS-PORTFOLIO}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-PORTFOLIO-TR}. 
            when {&DOCUMENTSTATUS-VOID}
            then tqDCollectionReport.tcDCollRepDDocStatus = {&DOCUMENTSTATUS-VOID-TR}.         
        end.         
    /* Determnine own bank based on customer's bank */
    <Q-21 run BankNumberOwnBankGLByID (all) (Read) (NoCache)
        (input tqDCollectionReport.tiDCollRepBankNumberID, (BankNumber_ID)
         input ?, (CompanyId)
         output dataset tqBankNumberOwnBankGLByID) in BBankNumber >
    for first tqBankNumberOwnBankGLByID:
        assign tqDCollectionReport.tcDCollRepBankNumber   = tqBankNumberOwnBankGLByID.tcOwnBankNumber
               tqDCollectionReport.tcPayFormatTypeCode    = tqBankNumberOwnBankGLByID.tcPayFormatTypeCode
               tqDCollectionReport.tcDCollRepBankCurrency = tqBankNumberOwnBankGLByID.tcCurrencyCode.
    end.

 /*BKW* This chooses an arbitrary own bank, which is incorrect
  <Q-12 run DCollectionOwnBankNumber (all) (Read) (NoCache)
     (input tqDCollectionByReference.tiDCollectionGL_ID, (ParentObjectID)
      input 'GL', (ParentType)
      output dataset tqDCollectionOwnBankNumber) in BDCollectionReport >                                     
  
  find first tqDCollectionOwnBankNumber no-lock no-error.
  if available tqDCollectionOwnBankNumber then do:
        assign tqDCollectionReport.tcDCollRepBankNumber   = tqDCollectionOwnBankNumber.tcBankNumber
               tqDCollectionReport.tcPayFormatTypeCode    = tqDCollectionOwnBankNumber.tcPayFormatTypeCode
               tqDCollectionReport.tcDCollRepBankCurrency = tqDCollectionOwnBankNumber.tcCurrencyCode.
  end.
  *BKW*/
end.

<Q-11 run DCollectionOwnBankNumber (Stop) in BDCollectionReport >

FOR EACH tqDCollectionReport WHERE 
         tqDCollectionReport.tiDCollRepDocumentID <> 0 AND 
         tqDCollectionReport.tiDCollRepDocumentID <> ? 
         BREAK BY tqDCollectionReport.tiDCollRepDocumentID:
    IF FIRST-OF(tqDCollectionReport.tiDCollRepDocumentID) 
    THEN DO:
        <Q-13 run DInvoiceBankPayCodeByDIBankID (all) (Read) (NoCache)
             (input 'Payment', (PayFormatGroupLevel)
              input tqDCollectionReport.tiDCollRepInvoiceID, (DInvoiceId)
              input tqDCollectionReport.tiDCollRepBankNumberID, (BankNumberId)
              output dataset tqDInvoiceBankPayCodeByDIBankID) in BDInvoice >
        FOR EACH tqDInvoiceBankPayCodeByDIBankID WHERE 
                 tqDInvoiceBankPayCodeByDIBankID.tcPayFormatGroupCode <> "" AND
                 tqDInvoiceBankPayCodeByDIBankID.tcPayFormatGroupCode <> ? AND
                 tqDInvoiceBankPayCodeByDIBankID.tiDInvoice_ID = tqDCollectionReport.tiDCollRepInvoiceID
                 BREAK BY tqDInvoiceBankPayCodeByDIBankID.tcPayFormatGroupCode:

            create tqDetailAttributes.
            assign
                tqDetailAttributes.tiDocumentID = tqDCollectionReport.tiDCollRepDocumentID
                tqDetailAttributes.tcAttributeName = tqDInvoiceBankPayCodeByDIBankID.tcPayFormatGroupCode.

            IF tqDInvoiceBankPayCodeByDIBankID.tiPayFormatCode_ID <> ? AND tqDInvoiceBankPayCodeByDIBankID.tiPayFormatCode_ID <> 0 
            THEN DO:
                <Q-14 run PayFormatCodeByID (all) (Read) (NoCache)
                     (input tqDInvoiceBankPayCodeByDIBankID.tiPayFormatCode_ID, (PayFormatCodeID)
                      output dataset tqPayFormatCodeByID) in BPaymentFormat >
                for first tqPayFormatCodeByID where tqPayFormatCodeByID.tiPayFormatCode_ID = tqDInvoiceBankPayCodeByDIBankID.tiPayFormatCode_ID:
                    assign tqDetailAttributes.tcAttributeValue = tqPayFormatCodeByID.tcPayFormatCode.
                end.
            END. /* IF tqDInvoiceBankPayCodeByDIBankID.tiPayFormatCode_ID <> ?... */
            ELSE do:
                assign tqDetailAttributes.tcAttributeValue = tqDInvoiceBankPayCodeByDIBankID.tcDInvoiceBankPayCodeValue.
            END. /* ELSE do: */
        END.  /* FOR EACH tqDInvoiceBankPayCodeByDIBankID */        
    END. /* FIRST-OF(tqDCollectionReport.tiDCollRepDocumentID)  */          
END.   /* FOR EACH tqDCollectionReport */