project QadFinancials > class BCreditorReport > method CInvoiceRegister

report procedure

Description

Supplier Invoice Register


Parameters


icLanguageCodeinputcharacter
tFilterinputtemp-table
dcrCInvoiceRegisteroutputdataset
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bcreditorreport.p)

empty temp-table tqCInvoiceRegister.
empty temp-table tqCInvoiceMatchedReceipt.

<M-44 run GetReportLabels
   (input  'CInvoiceRegister':U (icReportName), 
    input  icLanguageCode (icLanguageCode), 
    input  tFilter (tFilter), 
    output tqHeader (tqHeader), 
    output tqFilter (tqFilter), 
    output tqText (tqText), 
    output viFcReturnSuper (oiReturnStatus)) in BCreditorReport>

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

<M-24 run SetDataItemsBasedOnFilterTT  (output viFcReturnSuper (oiReturnStatus)) in BCreditorReport>

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

if vtFromInvPostingDateFilter = ? or
   vtToInvPostingDateFilter   = ?
then do:
    assign vcMessage = trim(#T-70'PostingDate has to be filled to run the report.':100(411490284)T-70#).
    <M-3 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-187983':U (icFcMsgNumber), 
        input  #T-98'Postingdate is mandatory that should be filled.':100(730732203)T-98# (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output oiReturnStatus (oiReturnStatus)) in BCreditorReport>                                              
    assign oiReturnStatus = -1.
    return.
end.

/* Cross-company iteration */
do viCRCompanyIterator = 1 to viCRCompanyEntries:
    /* Get Info about Company (this method fills viCRCurrentCompany_ID) */
    <M-82 run CrossCompanyValues
       (input  viCRCompanyIterator (iiEntryNumber), 
        output viFcReturnSuper (oiReturnStatus)) in BCreditorReport>

    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0
    then return.
    
    assign viFromPostingYearPeriod = ?
           viToPostingYearPeriod   = ?.
    
    <Q-6 run PeriodByPeriodStartEndDate (all) (Read) (NoCache)
       (input viCRCurrentCompany_ID, (CompanyId)
        input vtFromInvPostingDateFilter, (Date)
        input ?, (PeriodId)
        input ?, (PeriodYear)
        input ?, (PeriodPeriod)
        output dataset tqPeriodByPeriodStartEndDate) in BPeriod >
        
    find first tqPeriodByPeriodStartEndDate no-error.
    if available tqPeriodByPeriodStartEndDate
    then assign viFromPostingYearPeriod = tqPeriodByPeriodStartEndDate.tiPeriodYearPeriod.
    else assign viFromPostingYearPeriod = ?.
           
    <Q-31 run PeriodByPeriodStartEndDate (all) (Read) (NoCache)
       (input viCRCurrentCompany_ID, (CompanyId)
        input vtToInvPostingDateFilter, (Date)
        input ?, (PeriodId)
        input ?, (PeriodYear)
        input ?, (PeriodPeriod)
        output dataset tqPeriodByPeriodStartEndDate) in BPeriod >
            
    find first tqPeriodByPeriodStartEndDate no-error.
    if available tqPeriodByPeriodStartEndDate
    then assign viToPostingYearPeriod = tqPeriodByPeriodStartEndDate.tiPeriodYearPeriod.
    else assign viToPostingYearPeriod = ?.

    /* Fill in Supplier Code in Filter Criteria */
    if vcFromCreditorCodeFilter1 <> '':U and
       vcFromCreditorCodeFilter1 <> ?    and
       vcToCreditorCodeFilter1   <> '':U and
       vcToCreditorCodeFilter1   <> ?
    then do:
        <Q-83 run CInvoiceForCInvoicePosting (all) (Read) (NoCache)
           (input viCRCurrentCompany_ID, (CompanyId)
            input vcCreditorTypeFilter, (CreditorType)
            input vcFromCreditorCodeFilter1, (FromCreditorCode)
            input vcToCreditorCodeFilter1, (ToCreditorCode)
            input vcPurchaseTypeFilter, (PurchaseType)
            input vcCurrencyCodeFilter1, (CurrencyCode)
            input vtFromInvPostingDateFilter, (FromPostingDate)
            input vtToInvPostingDateFilter, (ToPostingDate)
            input vlOpenOnlyFilter, (CInvoiceIsOpen)
            output dataset tqCInvoiceForCInvoicePosting) in BCreditorReport >
    
        for each tqCInvoiceForCInvoicePosting:
            create tqCInvoiceRegister.
            buffer-copy tqCInvoiceForCInvoicePosting to tqCInvoiceRegister.
            if vcSortByFilter1 = '2':U
            then assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCompanyCode.
            else assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCreditorCode.
            assign tqCInvoiceRegister.tcPostingCompanyCode = tqCInvoiceRegister.tcCompanyCode
                   tqCInvoiceRegister.tcCurrencyBC         = vcCompanyLC.

            if vlContainCyPosting = false                                 and
               tqCInvoiceForCInvoicePosting.tiCrossCompanyPosting_ID <> 0
            then assign vlContainCyPosting = true.
    
            if vlReceiptDataFilter = true  and
               vlContainLM         = false and
               tqCInvoiceForCInvoicePosting.tlCInvoiceIsLogisticMatching = true
            then assign vlContainLM = true.
        end.

        if vlContainLM = true
        then do:
            <Q-71 run MatchedReceiptaByCreditor (all) (Read) (NoCache)
               (input viCRCurrentCompany_ID, (CompanyId)
                input vlOpenOnlyFilter, (CInvoiceIsOpen)
                input vcCreditorTypeFilter, (CreditorType)
                input vcCurrencyCodeFilter1, (CurrencyCode)
                input vcFromCreditorCodeFilter1, (FromCreditorCode)
                input vcToCreditorCodeFilter1, (ToCreditorCode)
                input vtFromInvPostingDateFilter, (FromPostingDate)
                input vtToInvPostingDateFilter, (ToPostingDate)
                input vcPurchaseTypeFilter, (PurchaseType)
                output dataset tqMatchedReceiptaByCreditor) in BCreditorReport >
            for each tqMatchedReceiptaByCreditor:
                create tqCInvoiceMatchedReceipt.
                buffer-copy tqMatchedReceiptaByCreditor to tqCInvoiceMatchedReceipt.
                assign tqCInvoiceMatchedReceipt.tdprh_pur_cost = tqMatchedReceiptaByCreditor.tdprh_curr_amt.
            end. /* for each tqCInvoiceForMatchedReceipta */
        end. /* if vlContainLM = true */

        if vlContainCyPosting = true
        then do:
            <Q-43 run CInvoiceForCInvoiceCyPosting (all) (Read) (NoCache)
               (input viCRCurrentCompany_ID, (CompanyId)
                input vcFromCreditorCodeFilter1, (FromCreditorCode)
                input vcToCreditorCodeFilter1, (ToCreditorCode)
                input vcCreditorTypeFilter, (CreditorType)
                input vtFromInvPostingDateFilter, (FromPostingDate)
                input vtToInvPostingDateFilter, (ToPostingDate)
                input vlOpenOnlyFilter, (CInvoiceIsOpen)
                input vcPurchaseTypeFilter, (PurchaseType)
                input vcCurrencyCodeFilter1, (CurrencyCode)
                output dataset tqCInvoiceForCInvoiceCyPosting) in BCreditorReport >
        
            for each tqCInvoiceForCInvoiceCyPosting:
                create tqCInvoiceRegister.
                buffer-copy tqCInvoiceForCInvoiceCyPosting to tqCInvoiceRegister.
                if vcSortByFilter1 = '2':U
                then assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCompanyCode.
                else assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCreditorCode.
                assign tqCInvoiceRegister.tcCInvoicePostingType = 'ALLMATCH':U
                       tqCInvoiceRegister.tcCurrencyBC          = vcCompanyLC.
            end.
        end. /* if vlContainCyPosting = true */

        if vlIncludeInitials
        then do:
            <Q-47 run InitialCInvoiceByCreditor (all) (Read) (NoCache)
               (input viCRCurrentCompany_ID, (CompanyId)
                input vcFromCreditorCodeFilter1, (FromCreditorCode)
                input vcToCreditorCodeFilter1, (ToCreditorCode)
                input vtFromInvPostingDateFilter, (FromPostingDate)
                input vtToInvPostingDateFilter, (ToPostingDate)
                input vcCurrencyCodeFilter1, (CurrencyCode)
                input vcCreditorTypeFilter, (CreditorType)
                input vcPurchaseTypeFilter, (PurchaseType)
                input vlOpenOnlyFilter, (CInvoiceIsOpen)
                output dataset tqInitialCInvoiceByCreditor) in BCreditorReport >
            for each tqInitialCInvoiceByCreditor:
                create tqCInvoiceRegister.
                buffer-copy tqInitialCInvoiceByCreditor to tqCInvoiceRegister.
                if vcSortByFilter1 = '2':U
                then assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCompanyCode.
                else assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCreditorCode.
                assign tqCInvoiceRegister.tcPostingCompanyCode = tqCInvoiceRegister.tcCompanyCode
                       tqCInvoiceRegister.tcCurrencyBC         = vcCompanyLC
                       tqCInvoiceRegister.tcCInvoicePostingType = 'INIT:U'.
            end. /* for each tqInitialCInvoiceByCreditor */
        end. /* if vlIncludeInitials */
    end. /* if vcFromCreditorCodeFilter1 <> '':U and */
    /* Blank Supplier Code in Filter Criteria */
    else do:
        <Q-85 run CInvoicePostingByDate (all) (Read) (NoCache)
           (input viCRCurrentCompany_ID, (CompanyId)
            input vlOpenOnlyFilter, (CInvoiceIsOpen)
            input vcCreditorTypeFilter, (CreditorType)
            input vcCurrencyCodeFilter1, (CurrencyCode)
            input vcFromCreditorCodeFilter1, (FromCreditorCode)
            input vtFromInvPostingDateFilter, (FromPostingDate)
            input vcPurchaseTypeFilter, (PurchaseType)
            input vcToCreditorCodeFilter1, (ToCreditorCode)
            input vtToInvPostingDateFilter, (ToPostingDate)
            input viFromPostingYearPeriod, (FromPostingYearPeriod)
            input viToPostingYearPeriod, (ToPostingYearPeriod)
            output dataset tqCInvoicePostingByDate) in BCreditorReport >
    
        for each tqCInvoicePostingByDate break by tqCInvoicePostingByDate.tiCInvoice_ID:
            create tqCInvoiceRegister.
            buffer-copy tqCInvoicePostingByDate to tqCInvoiceRegister.
            if vcSortByFilter1 = '2':U
            then assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCompanyCode.
            else assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCreditorCode.
            assign tqCInvoiceRegister.tcPostingCompanyCode = tqCInvoiceRegister.tcCompanyCode
                   tqCInvoiceRegister.tcCurrencyBC         = vcCompanyLC.

            if vlContainCyPosting = false                            and
               tqCInvoicePostingByDate.tiCrossCompanyPosting_ID <> 0
            then assign vlContainCyPosting = true.

            if vlReceiptDataFilter = true  and
               vlContainLM         = false and
               tqCInvoicePostingByDate.tlCInvoiceIsLogisticMatching = true
            then assign vlContainLM = true.
        end.

        if vlContainLM = true
        then do:
                                          
                <Q-26 run CInvoiceForMatchedReceiptb (all) (Read) (NoCache)
               (input viCRCurrentCompany_ID, (CompanyId)
                input vlOpenOnlyFilter, (CInvoiceIsOpen)
                input vtFromInvPostingDateFilter, (FromPostingDate)
                input vtToInvPostingDateFilter, (ToPostingDate)
                input vcFromCreditorCodeFilter1, (FromCreditorCode)
                input vcToCreditorCodeFilter1, (ToCreditorCode)
                input vcPurchaseTypeFilter, (PurchaseType)
                input vcCreditorTypeFilter, (CreditorType)
                input vcCurrencyCodeFilter1, (CurrencyCode)
                input viFromPostingYearPeriod, (FromPostingYearPeriod)
                input viToPostingYearPeriod, (ToPostingYearPeriod)
                    output dataset tqCInvoiceForMatchedReceiptb) in BCreditorReport>
                    
            for each tqCInvoiceForMatchedReceiptb:
                create tqCInvoiceMatchedReceipt.
                buffer-copy tqCInvoiceForMatchedReceiptb to tqCInvoiceMatchedReceipt.
                assign tqCInvoiceMatchedReceipt.tdprh_pur_cost = tqCInvoiceForMatchedReceiptb.tdprh_curr_amt.
            end. /* for each tqCInvoiceForMatchedReceiptb */
        end. /* if vlContainLM = true */

        if vlContainCyPosting = true
        then do:
            <Q-76 run CInvoiceCyPostingByDate (all) (Read) (NoCache)
               (input viCRCurrentCompany_ID, (CompanyId)
                input vlOpenOnlyFilter, (CInvoiceIsOpen)
                input vcCreditorTypeFilter, (CreditorType)
                input vcCurrencyCodeFilter1, (CurrencyCode)
                input vcFromCreditorCodeFilter1, (FromCreditorCode)
                input vcToCreditorCodeFilter1, (ToCreditorCode)
                input vcPurchaseTypeFilter, (PurchaseType)
                input vtFromInvPostingDateFilter, (FromPostingDate)
                input vtToInvPostingDateFilter, (ToPostingDate)
                input viFromPostingYearPeriod, (FromPostingYearPeriod)
                input viToPostingYearPeriod, (ToPostingYearPeriod)
                output dataset tqCInvoiceCyPostingByDate) in BCreditorReport >
        
            for each tqCInvoiceCyPostingByDate:
                create tqCInvoiceRegister.
                buffer-copy tqCInvoiceCyPostingByDate to tqCInvoiceRegister.
                if vcSortByFilter1 = '2':U
                then assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCompanyCode.
                else assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCreditorCode.
                assign tqCInvoiceRegister.tcCInvoicePostingType = 'ALLMATCH':U
                       tqCInvoiceRegister.tcCurrencyBC          = vcCompanyLC.
            end.
        end. /* if vlContainCyPosting = true */

        if vlIncludeInitials
        then do:
            <Q-58 run InitialCInvoiceByDate (all) (Read) (NoCache)
               (input viCRCurrentCompany_ID, (CompanyId)
                input vcFromCreditorCodeFilter1, (FromCreditorCode)
                input vcToCreditorCodeFilter1, (ToCreditorCode)
                input vtFromInvPostingDateFilter, (FromPostingDate)
                input vtToInvPostingDateFilter, (ToPostingDate)
                input vcCurrencyCodeFilter1, (CurrencyCode)
                input vcCreditorTypeFilter, (CreditorType)
                input vcPurchaseTypeFilter, (PurchaseType)
                input vlOpenOnlyFilter, (CInvoiceIsOpen)
                input viFromPostingYearPeriod, (FromPostingYearPeriod)
                input viToPostingYearPeriod, (ToPostingYearPeriod)
                output dataset tqInitialCInvoiceByDate) in BCreditorReport >
            for each tqInitialCInvoiceByDate:
                create tqCInvoiceRegister.
                buffer-copy tqInitialCInvoiceByDate to tqCInvoiceRegister.
                if vcSortByFilter1 = '2':U
                then assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCompanyCode.
                else assign tqCInvoiceRegister.tcSortByName = tqCInvoiceRegister.tcCreditorCode.
                assign tqCInvoiceRegister.tcPostingCompanyCode = tqCInvoiceRegister.tcCompanyCode
                       tqCInvoiceRegister.tcCurrencyBC         = vcCompanyLC
                       tqCInvoiceRegister.tcCInvoicePostingType = 'INIT:U'.
            end. /* for each tqInitialCInvoiceByCreditor */
        end. /* if vlIncludeInitials */
    end. /* else do */
end. /* do viCRCompanyIterator = 1 to viCRCompanyEntries */