project QadFinancials > class BAPMatchingReport > method UnmatchedReceipt

report procedure


Parameters


icLanguageCodeinputcharacter
tFilterinputtemp-table
dcrUnmatchedReceiptoutputdataset
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bapmatchingreport.p)

empty temp-table tqUnmatchedReceipt.

<M-1 run GetReportLabels
   (input  'UnmatchedReceipt':U (icReportName), 
    input  icLanguageCode (icLanguageCode), 
    input  tFilter (tFilter), 
    output tqHeader (tqHeader), 
    output tqFilter (tqFilter), 
    output tqText (tqText), 
    output viFcReturnSuper (oiReturnStatus)) in BAPMatchingReport>
    
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
 
<M-2 run SetDataItemsBasedOnFilterTT
   (output viFcReturnSuper (oiReturnStatus)) in BAPMatchingReport>

if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.

if vlIncludeInventory = ? then assign vlIncludeInventory = false.
if vlIncludeSubcontracted = ? then assign vlIncludeSubcontracted = false.
if vlIncludeMemo = ? then assign vlIncludeMemo = false.


<Q-3 run PendingVoucherForUnmatched (all) (Read) (NoCache)
   (input vcFromPurchaseOrderFilter, (FromPurchaseOrder)
    input vcToPurchaseOrderFilter, (ToPurchaseOrder)
    input vcCreditorCodeFromFilter, (FromCreditorCode)
    input vcCreditorCodeToFilter, (ToCreditorCode)
    input vcFromItemFilter, (FromItem)
    input vcToItemFilter, (ToItem)
    input vtFromReceiptDateFilter, (FromReceiptDate)
    input vtToReceiptDateFilter, (ToReceiptDate)
    input vcSiteFilter, (SiteCode)
    input vcDomainCode, (DomainCode)
    output dataset tqPendingVoucherForUnmatched) in BAPMatchingReport >

<Q-8 run InvTrHistForGLCrossRef (all) (Read) (NoCache)
          (input vcFromPurchaseOrderFilter, (FromPurchaseOrder)
           input vcToPurchaseOrderFilter, (ToPurchaseOrder)
           output dataset tqInvTrHisForGLCrossRef) in BAPMatchingReport >

for each tqPendingVoucherForUnmatched where 
    (if vlIncludeInventory then 
        true else
        (tqPendingVoucherForUnmatched.tcprh_type <> "":U and tqPendingVoucherForUnmatched.tcprh_type <> ?)) and
    (if vlIncludeSubcontracted then 
        true else 
        tqPendingVoucherForUnmatched.tcprh_type <> "S":U) and
    (if vlIncludeMemo then 
        true else 
        tqPendingVoucherForUnmatched.tcprh_type <> "M":U) and
    (if vlIncludeLogisitic then 
        true else 
        (tqPendingVoucherForUnmatched.tcpvo_lc_charge = "":U or tqPendingVoucherForUnmatched.tcpvo_lc_charge = ?)):
        create tUmatchedReceiptWithTax.
        buffer-copy tqPendingVoucherForUnmatched to tUmatchedReceiptWithTax.
end. /*for each tqPendingVoucherForUnmatched where*/


assign vdSumReceiptTaxLC = 0.

<Q-14 run SiteForCompany
   (Start) in BMfgSite >
<Q-15 run CreditorAddressInfoByCreditor
   (Start) in BCreditor >

if viBMfgPOReceiptMatchingID = 0 then
    <I-18 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "false"
            &CLASS              = "BMfgPOReceipt"}>
else 
    <I-19 {bFcOpenInstance
            &CLASS           = "BMfgPOReceipt"}>
         
mainblock:
for each tUmatchedReceiptWithTax break
    by tUmatchedReceiptWithTax.tcpo_nbr 
    by tUmatchedReceiptWithTax.tipvod_id
    by tUmatchedReceiptWithTax.tipvod_id_line:

    assign vdSumReceiptTaxLC = vdSumReceiptTaxLC + tUmatchedReceiptWithTax.tdtx2d_cur_tax_amt.

    if last-of(tUmatchedReceiptWithTax.tcpo_nbr) or
       last-of(tUmatchedReceiptWithTax.tipvod_id) or
       last-of(tUmatchedReceiptWithTax.tipvod_id_line)
    then do:
        assign
            vdReceiptTaxTCTmp       = vdSumReceiptTaxLC * tUmatchedReceiptWithTax.tdpvod_ex_rate
                                      / tUmatchedReceiptWithTax.tdpvod_ex_rate2
            vdReceiptTaxLCTmp       = vdSumReceiptTaxLC
            vdReceiptQtyTmp         = 0
            vdReceiptOpenQtyTmp     = 0
            vdReceiptOpenTaxTCTmp   = 0
            vdReceiptOpenTaxLCTmp   = 0
            vcReceiptGLTmp          = ?
            vcReceiptDivisionTmp    = ?
            vcReceiptCostCenterTmp  = ?
            vcReceiptDaybookTmp     = ?
            vcReceiptVoucherTmp     = ?
            vcReceiptProject        = ?
            vcCreditorCodeTmp       = ?
            vcCreditorNameTmp       = ?
            vcCreditorLineTmp       = ?
            vcCreditorZIPTmp        = ?
            vcCreditorCityTmp       = ?
            vcCreditorCountryTmp    = ?.

       for first tqInvTrHisForGLCrossRef where
           tqInvTrHisForGLCrossRef.tctr_domain = tUmatchedReceiptWithTax.tcprh_domain and
           tqInvTrHisForGLCrossRef.tctr_nbr = tUmatchedReceiptWithTax.tcprh_nbr and
           tqInvTrHisForGLCrossRef.titr_line = tUmatchedReceiptWithTax.tiprh_line and
           tqInvTrHisForGLCrossRef.tctr_lot = tUmatchedReceiptWithTax.tcprh_receiver:

            assign
                vcReceiptDaybookTmp    = tqInvTrHisForGLCrossRef.tctrgl_dy_code
                vcReceiptVoucherTmp    = tqInvTrHisForGLCrossRef.tctrgl_dy_num.
       end.

        /*If the item is Logistic Charge*/
        if tUmatchedReceiptWithTax.tcpvo_lc_charge <> ""  then  
             assign 
                 vdReceiptAmtTCTmp     = tUmatchedReceiptWithTax.tdpvod_accrued_amt * tUmatchedReceiptWithTax.tdpvod_ex_rate 
                                         / tUmatchedReceiptWithTax.tdpvod_ex_rate2
                 vdReceiptAmtLCTmp     = tUmatchedReceiptWithTax.tdpvod_accrued_amt
                 vdReceiptOpenAmtTCTmp = (tUmatchedReceiptWithTax.tdpvod_accrued_amt - tUmatchedReceiptWithTax.tdpvod_vouchered_amt)
                                         * tUmatchedReceiptWithTax.tdpvod_ex_rate / tUmatchedReceiptWithTax.tdpvod_ex_rate2
                 vdReceiptOpenAmtLCTmp = tUmatchedReceiptWithTax.tdpvod_accrued_amt - tUmatchedReceiptWithTax.tdpvod_vouchered_amt
                 vcReceiptItemTypeTmp  = #T-4'Logistic Charge':20(64777)T-4#.
        else do: /*If the item is NOT Logistic Charge*/
            <Q-12 run SiteForCompany (all) (Read) (NoCache)
               (input tUmatchedReceiptWithTax.tcprh_site, (Site)
                input tUmatchedReceiptWithTax.tcprh_domain, (Domain)
                input ?, (CompanyId)
                output dataset tqSiteForCompany) in BMfgSite >
    
            for first tqSiteForCompany:
                assign  vcCompanyCode = tqSiteForCompany.tcCompanyCode
                        vhFcComponent = ?. 
                <M-13 run ApiGetAccountInformationOnPOReceipt
                   (input  vcCompanyCode (icCompanyCode), 
                    input  tUmatchedReceiptWithTax.tcprh_domain (icDomainCode), 
                    input  false (ilReceiptIsLogisticCharge), 
                    input  tUmatchedReceiptWithTax.tcprh_type (icReceiptPrhType), 
                    input  tUmatchedReceiptWithTax.tcprh_vend (icReceiptPrhVendor), 
                    input  tUmatchedReceiptWithTax.tcvd_type (icReceiptVendorType), 
                    input  tUmatchedReceiptWithTax.tcpvod_part (icReceiptItemCode), 
                    input  tUmatchedReceiptWithTax.tcpt_prod_line (icReceiptProductLineCode), 
                    input  tUmatchedReceiptWithTax.tcpt_site (icReceiptSiteCode), 
                    input  'GL':U (icReceiptLogisticChargeGLCode), 
                    input  '':U (icReceiptLogisticChargeDivCode), 
                    input  '':U (icReceiptLogisticChargePrjCode), 
                    input  '':U (icReceiptLogisticChargeCCCode), 
                    output vcReceiptGLTmp (ocGLCode), 
                    output vcReceiptDivisionTmp (ocDivisionCode), 
                    output vcReceiptProject (ocProjectCode), 
                    output vcReceiptCostCenterTmp (ocCostCentreCode), 
                    output viFcReturnSuper (oiReturnStatus)) in BMfgPOReceipt>

                if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0) 
                then assign oiReturnStatus = viFcReturnSuper.
                if oiReturnStatus < 0 
                then leave mainblock.
                
            end. /* for first tqSiteForCompany:*/
            
            assign
                 vdReceiptAmtTCTmp     = tUmatchedReceiptWithTax.tdpvod_trans_qty * tUmatchedReceiptWithTax.tdpvod_pur_cost * tUmatchedReceiptWithTax.tdprh_um_conv
                                         * tUmatchedReceiptWithTax.tdpvod_ex_rate / tUmatchedReceiptWithTax.tdpvod_ex_rate2
                 vdReceiptAmtLCTmp     = tUmatchedReceiptWithTax.tdpvod_trans_qty * tUmatchedReceiptWithTax.tdpvod_pur_cost * tUmatchedReceiptWithTax.tdprh_um_conv
                 vdReceiptOpenAmtTCTmp = (tUmatchedReceiptWithTax.tdpvod_trans_qty - tUmatchedReceiptWithTax.tdpvod_vouchered_qty)
                                         * tUmatchedReceiptWithTax.tdpvod_pur_cost * tUmatchedReceiptWithTax.tdprh_um_conv
                                         * tUmatchedReceiptWithTax.tdpvod_ex_rate / tUmatchedReceiptWithTax.tdpvod_ex_rate2
                 vdReceiptOpenAmtLCTmp = (tUmatchedReceiptWithTax.tdpvod_trans_qty - tUmatchedReceiptWithTax.tdpvod_vouchered_qty)
                                         * tUmatchedReceiptWithTax.tdpvod_pur_cost * tUmatchedReceiptWithTax.tdprh_um_conv
                 vdReceiptQtyTmp       = tUmatchedReceiptWithTax.tdpvod_trans_qty
                 vdReceiptOpenQtyTmp   = tUmatchedReceiptWithTax.tdpvod_trans_qty - tUmatchedReceiptWithTax.tdpvod_vouchered_qty.
            assign
                 vdReceiptOpenTaxTCTmp     = vdReceiptTaxTCTmp * vdReceiptOpenQtyTmp / vdReceiptQtyTmp
                 vdReceiptOpenTaxLCTmp     = vdReceiptTaxLCTmp * vdReceiptOpenQtyTmp / vdReceiptQtyTmp
                 vcReceiptItemTypeTmp   = if tUmatchedReceiptWithTax.tcprh_type = "":U then #T-5'Inventory':30(64778)T-5# else
                                          (if tUmatchedReceiptWithTax.tcprh_type = "S":U then #T-6'Subcontracted':30(64779)T-6# else #T-7'Memo':30(64780)T-7# ).
        end.  /*If the item is NOT Logistic Charge*/

        assign
            vdSumReceiptTaxLC    = 0.

        /* Ensure that the GL, Division and CostCenter are in the range specified */
        if can-do(vcGLAcctCodeFilter, vcReceiptGLTmp) = false or
           can-do(vcDivisionCodeFilter, vcReceiptDivisionTmp) = false or
           can-do(vcCostCenterCodeFilter, vcReceiptCostCenterTmp) = false
        then next.
    
       <Q-9 run CreditorAddressInfoByCreditor (all) (Read) (NoCache)
          (input ?, (CreditorId)
           input ?, (CompanyId)
           input tUmatchedReceiptWithTax.tcpvo_supplier, (CreditorCode)
           input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
           output dataset tqCreditorAddressInfoByCreditor) in BCreditor >

        for first tqCreditorAddressInfoByCreditor:
            assign 
                vcCreditorCodeTmp      = tqCreditorAddressInfoByCreditor.tcCreditorCode
                vcCreditorNameTmp      = tqCreditorAddressInfoByCreditor.tcBusinessRelationName1
                vcCreditorLineTmp      = tqCreditorAddressInfoByCreditor.tcAddressStreet1
                vcCreditorZIPTmp       = tqCreditorAddressInfoByCreditor.tcAddressZip
                vcCreditorCityTmp      = tqCreditorAddressInfoByCreditor.tcAddressCity
                vcCreditorCountryTmp   = tqCreditorAddressInfoByCreditor.tcCountryCode.
        end. /*for first tqCreditorAddressInfoByCreditor*/

        create tqUnmatchedReceipt.
        assign 
            tqUnmatchedReceipt.tcCreditorCode = vcCreditorCodeTmp
            tqUnmatchedReceipt.tcCreditorCity = vcCreditorCityTmp
            tqUnmatchedReceipt.tcCreditorCountry = vcCreditorCountryTmp
            tqUnmatchedReceipt.tcCreditorLine = vcCreditorLineTmp
            tqUnmatchedReceipt.tcCreditorName = vcCreditorNameTmp
            tqUnmatchedReceipt.tcCreditorZIP = vcCreditorZIPTmp
            tqUnmatchedReceipt.tcPurchaseOrderNbr = tUmatchedReceiptWithTax.tcpo_nbr
            tqUnmatchedReceipt.tcPurchaseOrderDescription = tUmatchedReceiptWithTax.tcpo_rmks
            tqUnmatchedReceipt.tcPurchaseOrderBuyer = tUmatchedReceiptWithTax.tcpo_buyer
            tqUnmatchedReceipt.ttPurchaseOrderDate = tUmatchedReceiptWithTax.ttpo_ord_date
            tqUnmatchedReceipt.ttReceiptDate = tUmatchedReceiptWithTax.ttpvo_trans_date
            tqUnmatchedReceipt.ttPurchaseOrderEffectiveDate = tUmatchedReceiptWithTax.ttpvo_eff_date
            tqUnmatchedReceipt.tcReceiptSite = tUmatchedReceiptWithTax.tcprh_site
            tqUnmatchedReceipt.tcReceiptDaybook = vcReceiptDaybookTmp
            tqUnmatchedReceipt.tcReceiptVoucher = vcReceiptVoucherTmp
            tqUnmatchedReceipt.tcReceiptLine = tUmatchedReceiptWithTax.tcprh_receiver
            tqUnmatchedReceipt.tcReceiptItem = tUmatchedReceiptWithTax.tcpvod_part
            tqUnmatchedReceipt.tcReceiptItemType = vcReceiptItemTypeTmp
            tqUnmatchedReceipt.tdReceiptAmtLC = vdReceiptAmtLCTmp + vdReceiptTaxLCTmp
            tqUnmatchedReceipt.tdReceiptAmtTC = vdReceiptAmtTCTmp + vdReceiptTaxTCTmp
            tqUnmatchedReceipt.tdReceiptOpenAmtLC = vdReceiptOpenAmtLCTmp + vdReceiptOpenTaxLCTmp
            tqUnmatchedReceipt.tdReceiptOpenAmtTC = vdReceiptOpenAmtTCTmp + vdReceiptOpenTaxTCTmp
            tqUnmatchedReceipt.tcReceiptAmountCurr = tUmatchedReceiptWithTax.tcprh_curr
            tqUnmatchedReceipt.tdReceiptQty = vdReceiptQtyTmp
            tqUnmatchedReceipt.tdReceiptOpenQty = vdReceiptOpenQtyTmp
            tqUnmatchedReceipt.tcReceiptQuantityUoM = tUmatchedReceiptWithTax.tcprh_um
            tqUnmatchedReceipt.tcReceiptGL = vcReceiptGLTmp
            tqUnmatchedReceipt.tcReceiptDivision = vcReceiptDivisionTmp
            tqUnmatchedReceipt.tcReceiptCostCenter = vcReceiptCostCenterTmp
            tqUnmatchedReceipt.tcReceiptProject = tUmatchedReceiptWithTax.tcpvod_project.


    end. /*if last-of(tUmatchedReceiptWithTax.tcpo_nbr) or......*/

    
end. /*for each tUmatchedReceiptWithTax*/

<I-20 {bFcCloseAndStopInstance
            &CLASS           = "BMfgPOReceipt"}>

<Q-16 run SiteForCompany
   (Stop) in BMfgSite >
<Q-17 run CreditorAddressInfoByCreditor
   (Stop) in BCreditor >