project QadFinancials > class BDebtorReport > method DebtorRemindersOverview

report procedure

Description

This method is used to display all debtor open items + state of reminders assigned to all items.


Parameters


icLanguageCodeinputcharacter
tFilterinputtemp-table
dcrDebtorRemindersOverviewoutputdataset
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bdebtorreport.p)

empty temp-table tqDebtorRemindersOverview.
empty temp-table tqDebtorReminderOverByDInvoice.

<M-3 run GetReportLabels
   (input  'DebtorRemindersOverview':U (icReportName), 
    input  icLanguageCode (icLanguageCode), 
    input  tFilter (tFilter), 
    output tqHeader (tqHeader), 
    output tqFilter (tqFilter), 
    output tqText (tqText), 
    output oiReturnStatus (oiReturnStatus)) in BDebtorReport>
if oiReturnStatus <> 0
then return.

/*assign tFilter*/
<M-4 run SetDataItemsBasedOnFilterTT (output  viFcReturnSuper (oiReturnStatus)) in BDebtorReport>

assign vtDInvoiceDueDate = if vlDueInvoicesOnly
                           then today
                           else ?.
if vcIncludedTypes <> "":U
then assign vcIncludedTypes = substring(vcIncludedTypes,2,length(vcIncludedTypes,"CHARACTER":U),"CHARACTER":U). /*remove first , */ 

/*if we are working with rangevalues, we have to test if the from-value and to-value */
/*of the maintable in the query is the same so we can use equal mathes instead of range */
/*if vcFromDebtorCodeFilter = vcToDebtorCodeFilter
then assign vcDebtorCodeFilter     = vcFromDebtorCodeFilter
            vcFromDebtorCodeFilter = ?
            vcToDebtorCodeFilter   = ?.
else assign vcDebtorCodeFilter     = ?.  
if vtDInvoiceDateFromFilter = vtDInvoiceDateToFilter
then assign vtDInvoiceDateFilter     = vtDInvoiceDateFromFilter
            vtDInvoiceDateFromFilter = ?
            vtDInvoiceDateToFilter   = ?. 
else assign vtDInvoiceDateFilter     = ?. */
if vtDueDateBeforeFilter = ?
then assign vtDueDateBeforeFilter = today.

/* Get only the BankStateNumber of the new Invoices made by the bank (=PrePayments) */
/* assign vcCanDoBankStateAllocType = {&BANKSTATEALLOCTYPE-NDINV}.  */

/* Cross-company Iteration */
do viDRCompanyIterator = 1 to viDRCompanyEntries:
    <M-9 run CrossCompanyValues
       (input  viDRCompanyIterator (iiEntryNumber), 
        output viFcReturnSuper (oiReturnStatus)) in BDebtorReport>
    
   /* dealing with error */
   if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
   then assign oiReturnStatus = viFcReturnSuper.
   if oiReturnStatus < 0 then return.
          
/* check which query we have to use depending on the filled values */
if (vcFromDebtorCodeFilter = ? or vcFromDebtorCodeFilter = "":U) and
   (vcToDebtorCodeFilter = ? or vcToDebtorCodeFilter = "":U) and
   (vcDebtorCodeFilter = ? or vcDebtorCodeFilter = "":U) /* BTS 4641*/
then do: /* start the query with main table DInvocie */
    <Q-23 run DebtorReminderOverByDIStage (all) (Read) (NoCache)
       (input viDRCurrentCompany_ID, (CompanyId)
        input vcToBRCodeFilter, (BusRelCodeTo)
        input ?, (DInvoiceDateFrom)
        input vcFromDivisionCodeFilter, (DivisionCodeFrom)
        input vcToDivisionCodeFilter, (DivisionCodeTo)
        input ?, (DInvoiceDateTo)
        input vtDueDateBeforeFilter, (DInvoiceDueDate)
        input vcFromDebtorCodeFilter, (DebtorCodeFrom)
        input vcToDebtorCodeFilter, (DebtorCodeTo)
        input vcFromBRCodeFilter, (BusRelCodeFrom)
        input ?, (DInvoiceDate)
        input vcCandoDebtorCodeFilter, (DebtorCode)
        input vcCanDoBankStateAllocType, (CanDoBankStateAllocType)
        output dataset tqDebtorReminderOverByDIStage) in BDebtorReport >

    <Q-15 run DebtorReminderOverByDInvoice (all) (Read) (NoCache)
       (input viDRCurrentCompany_ID, (CompanyId)
        input vcToBRCodeFilter, (BusRelCodeTo)
        input ?, (DInvoiceDateFrom)
        input vcFromDivisionCodeFilter, (DivisionCodeFrom)
        input vcToDivisionCodeFilter, (DivisionCodeTo)
        input ?, (DInvoiceDateTo)
        input vtDueDateBeforeFilter, (DInvoiceDueDate)
        input vcFromDebtorCodeFilter, (DebtorCodeFrom)
        input vcToDebtorCodeFilter, (DebtorCodeTo)
        input vcFromBRCodeFilter, (BusRelCodeFrom)
        input ?, (DInvoiceDate)
        input vcCandoDebtorCodeFilter, (DebtorCode)
        input vcCanDoBankStateAllocType, (CanDoBankStateAllocType)
        output dataset tqDebtorReminderOverByDInvoice) in BDebtorReport >
end.
else do: /* start the query with main table Debtor */
    <Q-24 run DebtorReminderOverByDBStage (all) (Read) (NoCache)
          (input viDRCurrentCompany_ID, (CompanyId)
           input vtDueDateBeforeFilter, (DInvoiceDueDate)
           input vcToBRCodeFilter, (BusRelCodeTo)
           input ?, (DInvoiceDateFrom)
           input vcFromDivisionCodeFilter, (DivisionCodeFrom)
           input vcToDivisionCodeFilter, (DivisionCodeTo)
           input ?, (DInvoiceDateTo)
           input vcFromDebtorCodeFilter, (DebtorCodeFrom)
           input vcToDebtorCodeFilter, (DebtorCodeTo)
           input vcFromBRCodeFilter, (BusRelCodeFrom)
           input ?, (DInvoiceDate)
           input vcCandoDebtorCodeFilter, (DebtorCode)
           input vcCanDoBankStateAllocType, (CanDoBankStateAllocType)
           output dataset tqDebtorReminderOverByDBStage) in BDebtorReport >
    
    <Q-16 run DebtorReminderOverByDebtor (all) (Read) (NoCache)
       (input viDRCurrentCompany_ID, (CompanyId)
        input vtDueDateBeforeFilter, (DInvoiceDueDate)
        input vcToBRCodeFilter, (BusRelCodeTo)
        input ?, (DInvoiceDateFrom)
        input vcFromDivisionCodeFilter, (DivisionCodeFrom)
        input vcToDivisionCodeFilter, (DivisionCodeTo)
        input ?, (DInvoiceDateTo)
        input vcFromDebtorCodeFilter, (DebtorCodeFrom)
        input vcToDebtorCodeFilter, (DebtorCodeTo)
        input vcFromBRCodeFilter, (BusRelCodeFrom)
        input ?, (DInvoiceDate)
        input vcCandoDebtorCodeFilter, (DebtorCode)
        input vcCanDoBankStateAllocType, (CanDoBankStateAllocType)
        output dataset tqDebtorReminderOverByDebtor) in BDebtorReport >
end.

/* assign the values to the temptable used for reporting */
if (vcFromDebtorCodeFilter = ? or vcFromDebtorCodeFilter = "":U) and
   (vcToDebtorCodeFilter = ? or vcToDebtorCodeFilter = "":U) and
   (vcDebtorCodeFilter = ? or vcDebtorCodeFilter = "":U) /* BTS 4641*/
then do:
    for each tqDebtorReminderOverByDIStage:
        if tqDebtorReminderOverByDIStage.tdDInvoiceStageAmountTC <> tqDebtorReminderOverByDIStage.tdDInvoiceStageAmtAppliedTC
        then do:
            create tqDebtorRemindersOverview.
            buffer-copy tqDebtorReminderOverByDIStage to tqDebtorRemindersOverview.
            assign tqDebtorRemindersOverview.tdDInvoiceBalanceTC       = tqDebtorReminderOverByDIStage.tdDInvoiceStageAmountTC - tqDebtorReminderOverByDIStage.tdDInvoiceStageAmtAppliedTC
                   tqDebtorRemindersOverview.tdDInvoiceOriginalDebitTC = tqDebtorReminderOverByDIStage.tdDInvoiceStageAmountTC
                   tqDebtorRemindersOverview.tdDInvoiceOriginalDebitLC = tqDebtorReminderOverByDIStage.tdDInvoiceStageAmountLC
                   tqDebtorRemindersOverview.tdDInvoiceOriginalDebitCC = tqDebtorReminderOverByDIStage.tdDInvoiceStageAmountCC
                   tqDebtorRemindersOverview.ttDInvoiceDueDate         = tqDebtorReminderOverByDIStage.ttDInvoiceStageDueDate
                   tqDebtorRemindersOverview.ttDInvoiceDiscountDueDate = tqDebtorReminderOverByDIStage.ttDInvoiceStageDiscDate.
        end. /* if tqDebtorReminderOverByDIStage.tdDInvoiceStageAmountTC <> tqDebtorReminderOverByDIStage.tdDInvoiceStageAmtAppliedTC */
    end.
    for each tqDebtorReminderOverByDInvoice:
        find first tqDebtorReminderOverByDIStage where tqDebtorReminderOverByDIStage.tiDInvoice_ID = tqDebtorReminderOverByDInvoice.tiDInvoice_ID no-error.
        if not available tqDebtorReminderOverByDIStage
        then do:
            create tqDebtorRemindersOverview.
            buffer-copy tqDebtorReminderOverByDInvoice to tqDebtorRemindersOverview.
        end. /* if not available tqDebtorReminderOverByDIStage */
    end.
end.
else do:
    for each tqDebtorReminderOverByDBStage:
        if tqDebtorReminderOverByDBStage.tdDInvoiceStageAmountTC <> tqDebtorReminderOverByDBStage.tdDInvoiceStageAmtAppliedTC
        then do:
            create tqDebtorRemindersOverview.
            buffer-copy tqDebtorReminderOverByDBStage to tqDebtorRemindersOverview.
            assign tqDebtorRemindersOverview.tdDInvoiceBalanceTC       = tqDebtorReminderOverByDBStage.tdDInvoiceStageAmountTC - tqDebtorReminderOverByDIStage.tdDInvoiceStageAmtAppliedTC
                   tqDebtorRemindersOverview.tdDInvoiceOriginalDebitTC = tqDebtorReminderOverByDBStage.tdDInvoiceStageAmountTC
                   tqDebtorRemindersOverview.tdDInvoiceOriginalDebitLC = tqDebtorReminderOverByDBStage.tdDInvoiceStageAmountLC
                   tqDebtorRemindersOverview.tdDInvoiceOriginalDebitCC = tqDebtorReminderOverByDBStage.tdDInvoiceStageAmountCC
                   tqDebtorRemindersOverview.ttDInvoiceDueDate         = tqDebtorReminderOverByDBStage.ttDInvoiceStageDueDate
                   tqDebtorRemindersOverview.ttDInvoiceDiscountDueDate = tqDebtorReminderOverByDBStage.ttDInvoiceStageDiscDate.
        end.
    end. /* if tqDebtorReminderOverByDebtorStage.tdDInvoiceBalanceTC <> tqDebtorReminderOverByDebtorStage.tdDInvoiceOriginalDebitTC */
    for each tqDebtorReminderOverByDebtor:
        find first tqDebtorReminderOverByDBStage where tqDebtorReminderOverByDBStage.tiDInvoice_ID = tqDebtorReminderOverByDebtor.tiDInvoice_ID no-error.
        if not available tqDebtorReminderOverByDBStage
        then do:
            create tqDebtorRemindersOverview.
            buffer-copy tqDebtorReminderOverByDebtor to tqDebtorRemindersOverview.
        end. /* if not available tqDebtorReminderOverByDebtorStage */
    end.
end.

    for each tqDebtorRemindersOverview break by tqDebtorRemindersOverview.tcDebtorCode:
        /*Calculates Address information for the BusinessRelation_ID*/ 
        assign vhFcComponent = ?
               vcPhone       = ?
               vcFax         = ?
               vcContactName = ?
               vcEmail       = ?
               vcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-REMINDER}.
        if first-of (tqDebtorRemindersOverview.tcDebtorCode)
        then do:
            <Q-12 run GetRemindersOverAddress (all) (Read) (NoCache)
               (input tqDebtorRemindersOverview.tiBusinessRelation_ID, (BusinessRelationId)
                input tqDebtorRemindersOverview.tcBusinessRelationCode, (BusinessRelationCode)
                input vcAddressTypeCode, (AddressType)
                output dataset tqGetRemindersOverAddress) in BDebtorReport >  
        end.
        find first tqGetRemindersOverAddress no-error.
        if available tqGetRemindersOverAddress
        then do:
            if tqGetRemindersOverAddress.tcContactTelephone = ?
            then assign vcPhone = tqGetRemindersOverAddress.tcContactTelephone.
            else assign vcPhone = tqGetRemindersOverAddress.tcAddressTelephone.
            if tqGetRemindersOverAddress.tcContactFax = ?
            then assign vcFax = tqGetRemindersOverAddress.tcContactFax.
            else assign vcFax = tqGetRemindersOverAddress.tcAddressFax.
            if tqGetRemindersOverAddress.tcContactName = ?
            then assign vcContactName = tqGetRemindersOverAddress.tcContactName.
            else assign vcContactName = tqGetRemindersOverAddress.tcAddressName.
            if tqGetRemindersOverAddress.tcContactEmail = ?
            then assign vcEmail = tqGetRemindersOverAddress.tcContactEmail.
            else assign vcEmail = tqGetRemindersOverAddress.tcAddressEmail.
            assign vcAddressStreet1 = tqGetRemindersOverAddress.tcAddressStreet1
                   vcAddressZip     = tqGetRemindersOverAddress.tcAddressZip
                   vcAddressCity    = tqGetRemindersOverAddress.tcAddressCity.                  
        end.
        if first-of (tqDebtorRemindersOverview.tcDebtorCode) and (vcPhone = ? or vcFax = ? or vcContactName = ? or vcEmail = ?)
        then do:
            assign vcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-HEADOFFICE}.
            <Q-13 run GetRemindersOverAddress (all) (Read) (NoCache)
               (input tqDebtorRemindersOverview.tiBusinessRelation_ID, (BusinessRelationId)
                input tqDebtorRemindersOverview.tcBusinessRelationCode, (BusinessRelationCode)
                input vcAddressTypeCode, (AddressType)
                output dataset tqGetRemindersOverAddress) in BDebtorReport >
            find first tqGetRemindersOverAddress no-error.
            if available tqGetRemindersOverAddress
            then do:
                if vcPhone = ?
                then assign vcPhone = tqGetRemindersOverAddress.tcAddressTelephone.
                if vcFax = ?
                then assign vcFax = tqGetRemindersOverAddress.tcAddressFax.
                if vcContactName = ?
                then assign vcContactName = tqGetRemindersOverAddress.tcAddressName.
                if vcEmail = ?
                then assign vcEmail = tqGetRemindersOverAddress.tcAddressEmail.
                if vcAddressStreet1 = ?
                then assign vcAddressStreet1 = tqGetRemindersOverAddress.tcAddressStreet1.
                if vcAddressZip = ?
                then assign vcAddressZip = tqGetRemindersOverAddress.tcAddressZip.
                if vcAddressCity = ?
                then assign vcAddressCity = tqGetRemindersOverAddress.tcAddressCity.
            end.
        end.
        assign tqDebtorRemindersOverview.tcAddressTelephone = vcPhone
               tqDebtorRemindersOverview.tcAddressFax       = vcFax
               tqDebtorRemindersOverview.tcContactName      = vcContactName
               tqDebtorRemindersOverview.tcContactEmail     = vcEmail
               tqDebtorRemindersOverview.tcAddressStreet1   = vcAddressStreet1
               tqDebtorRemindersOverview.tcAddressZip       = vcAddressZip
               tqDebtorRemindersOverview.tcAddressCity      = vcAddressCity.

         assign vcDinvoiceOpInfoType = {&DINVOICEOPINFOTYPE-SHIPPER} + "," + {&DINVOICEOPINFOTYPE-GOLDENTAX}
                vcDInvoiceOpInfoCode = "":U.
         /* Add Shipper_ID */
         <Q-68 run DInvoiceOpInfoForLegalDocGT (all) (Read) (NoCache)
            (input tqDebtorRemindersOverview.tiDInvoice_ID, (DInvoiceID)
             input vcDInvoiceOpInfoType, (DInvoiceOpInfoType)
             output dataset tqDInvoiceOpInfoForLegalDocGT) in BDebtorReport>
         for each tqDInvoiceOpInfoForLegalDocGT break by tqDInvoiceOpInfoForLegalDocGT.tiDInvoice_ID:
             if first-of(tqDInvoiceOpInfoForLegalDocGT.tiDInvoice_ID) then
                 vcDInvoiceOpInfoCode = tqDInvoiceOpInfoForLegalDocGT.tcDInvoiceOpInfoCode.
             else
                 vcDInvoiceOpInfoCode = vcDInvoiceOpInfoCode + "," + tqDInvoiceOpInfoForLegalDocGT.tcDInvoiceOpInfoCode.
         end.
          
         assign tqDebtorRemindersOverview.tcDInvoiceOpInfoCode = vcDInvoiceOpInfoCode.
    end.

/* Add filterfields to one special line It has two fields separated by '#'
   tcreportingInfo: SummaryByFiler#ReportingCurrency */
/* if can-find(first tqDebtorOpenItems)
then do:
    if vcSummaryByFilter = ? then assign vcSummaryByFilter = {&DEBTORSUMMARYBY-ALL}.
    if vcReportingCurrencyFilter = ? then assign vcReportingCurrencyFilter = {&CURRENCYTYPE-LC}.
    if vlDebtorPerPageFilter = ? then assign vlDebtorPerPageFilter = no.
    if vlPrintDetails = ? then assign vlPrintDetails = yes.
    create tqDebtorRemindersOverview.
    assign tqDebtorRemindersOverview.tcReportingInfo = vcSummaryByFilter + "#":U + 
                                               vcReportingCurrencyFilter + "#":U + 
                                               String(vlDebtorPerPageFilter) + "#":U +
                                               string(vlPrintDetails).
end. */
/****************************************************************************************/

end.

/*  <M-1 run DebtorOpenItems (input  icLanguageCode (icLanguageCode), 
                          input  tFilter (tFilter), 
                          output tqDebtorOpenItems (dcrDebtorOpenItems), 
                          output viFcReturnSuper (oiReturnStatus)) in BDebtorReport> 

<M-2 run GetReportLabels (input  'DebtorRemindersOverview':U (icReportName), 
                          input  icLanguageCode (icLanguageCode), 
                          input  tFilter (tFilter), 
                          output tqHeader (tqHeader), 
                          output tqFilter (tqFilter), 
                          output tqText (tqText), 
                          output oiReturnStatus (oiReturnStatus)) in BDebtorReport>
if oiReturnStatus <> 0
then return. */

/* Delete extra line with reportingInfo which was created by DebtorOpen Items */
/* find first tqDebtorOpenItems where tqDebtorRemindersOverview.tcReportingInfo <> ? and tqDebtorRemindersOverview.tcReportingInfo <> "":U no-error.
if available tqDebtorOpenItems
then delete tqDebtorRemindersOverview. */