project QadFinancials > class BAccountingInterface > method FillProDsGLVoucher

Description

This method is used to generate prodataset for GL Voucher report.


Parameters


icEntityListinputcharacterEntity List.
ohGLVoucheroutputhandleHandle for GL voucher Report Prodataset.
itFromDateinputdateFrom Date.
itToDateinputdateTill Date.
icCOACrossRefCodeinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAccountingInterface.BulidProDataSet


program code (program3/baccountinginterface.p)

assign oiReturnStatus = -98.
/* Empty temp-tables which will be used later */
empty temp-table tReport.
empty temp-table tGLVoucher.
empty temp-table tCOACrossRefDetInfo.
/* to create a temp table, due to EDI limitation */
create tReport.
assign tReport.tiReportID = 1.
/* Initialize the integer variable for loop */
assign vii = 1.
/* Start querys */
<Q-21 run PostingByPostingDate
   (Start) in BPosting >
<Q-12 run UserByNameID
(Start) in BUser >

repeat while vii <= num-entries(icEntityList):
    <Q-18 run PostingByPostingDate (all) (Read) (NoCache)
       (input integer(entry(vii,icEntityList)), (CompanyId)
        input itFromDate, (PostingDateFrom)
        input itToDate, (PostingDateTo)
        input ?, (PostingDate)
        output dataset tqPostingByPostingDate) in BPosting >
    for each tqPostingByPostingDate:        
        create tGLVoucher.
        assign
            tGLVoucher.tcAccntCode = tqPostingByPostingDate.tcGLCode
            tGLVoucher.tcBookedBy = ''
            tGLVoucher.tcCashier = ''
            tGLVoucher.tcCurrecy = tqPostingByPostingDate.tcCurrencyCode
            tGLVoucher.tcDescription = tqPostingByPostingDate.tcPostingLineText
            tGLVoucher.tcPaymentInstrumentDate = ''
            tGLVoucher.tcPaymentInstrumentNumber = ''
            tGLVoucher.tcPaymentInstrumentType = ''
            tGLVoucher.tcPeriodClosingFlag = '1'
            tGLVoucher.tcSettlementType = ''
            tGLVoucher.tcSubAccntGroup = ''
            tGLVoucher.tcVoucherDate = string(tqPostingByPostingDate.ttPostingDate)
            tGLVoucher.tcVoucherNo = string(tqPostingByPostingDate.tiPostingAddGLNbr)
            tGLVoucher.tcVoucherType = tqPostingByPostingDate.tcJournalDescription
            tGLVoucher.tdCrAmount = if tqPostingByPostingDate.tdPostingLineCreditLC = ?
                                    then 0.00
                                    else tqPostingByPostingDate.tdPostingLineCreditLC
            tGLVoucher.tdCrAmountOfForeign = if tqPostingByPostingDate.tiPostingLineCurrency_ID = tqPostingByPostingDate.tiCompanyCurrency_ID
                                            then 0.00
                                            else if tqPostingByPostingDate.tdPostingLineCreditTC = ?
                                            then 0.00
                                            else tqPostingByPostingDate.tdPostingLineCreditTC
            tGLVoucher.tdDtAmount = if tqPostingByPostingDate.tdPostingLineDebitLC = ?
                                    then 0.00
                                    else tqPostingByPostingDate.tdPostingLineDebitLC
            tGLVoucher.tdDtAmountOfForeign = if tqPostingByPostingDate.tiPostingLineCurrency_ID = tqPostingByPostingDate.tiCompanyCurrency_ID
                                            then 0.00
                                            else if tqPostingByPostingDate.tdPostingLineDebitTC = ?
                                            then 0.00
                                            else tqPostingByPostingDate.tdPostingLineDebitTC
            tGLVoucher.tdExchangeRate = tqPostingByPostingDate.tdPostingLineExchangeRate * tqPostingByPostingDate.tdPostingLineRateScale
            tGLVoucher.tdPrice = 0.00
            tGLVoucher.tdQty = 0.00
            tGLVoucher.tiAttachment = 1
            tGLVoucher.tiLines = tqPostingByPostingDate.tiPostingLineSequence
            tGLVoucher.tiReportID = 1.
        if tqPostingByPostingDate.tiCreatorUsr_ID = ?
        then assign tGLVoucher.tcPreparedBy = ''.   
        else do:   
            <Q-19 run UserByNameID (all) (Read) (NoCache)
               (input tqPostingByPostingDate.tiCreatorUsr_ID, (UsrId)
                input ?, (UsrName)
                input ?, (UsrLogin)
                output dataset tqUserByNameID) in BUser >  
            find first tqUserByNameID no-error.
            if available tqUserByNameID 
            then assign tGLVoucher.tcPreparedBy = tqUserByNameID.tcUsrName.
            else assign tGLVoucher.tcPreparedBy = ''.    
        end. /* if tqPostingByPeriodRange.tiCreatorUsr_ID = ? */       
        if tqPostingByPostingDate.tiLastVerifiedUsr_ID = ?
        then assign tGLVoucher.tcPreparedBy = ''.
        else do:
            <Q-20 run UserByNameID (all) (Read) (NoCache)
               (input tqPostingByPostingDate.tiLastVerifiedUsr_ID, (UsrId)
                input ?, (UsrName)
                input ?, (UsrLogin)
                output dataset tqUserByNameID) in BUser >
            find first tqUserByNameID no-error.
            if available tqUserByNameID
            then assign tGLVoucher.tcCheckedBy = tqUserByNameID.tcUsrName.
            else assign tGLVoucher.tcCheckedBy = ''.   
        end. /* if tqPostingByPeriodRange.tiLastVerifiedUsr_ID = ? */

        create tCOACrossRefDetInfo.
        assign tCOACrossRefDetInfo.tcGLCode = tqPostingByPostingDate.tcGLCode.
    
    end. /*  for each tqPostingByPostingDate: */
    assign vii = vii + 1.
end. /* repeat while vii <= num-entries(icEntityList): */
/* Stop querys */
<Q-22 run PostingByPostingDate
   (Stop) in BPosting >
<Q-17 run UserByNameID
   (Stop) in BUser >


/* Call the method GetAlternateInfo to do validation and get the Alt code and description. */    
assign vhResultTT = temp-table tGLVoucher:default-buffer-handle.
assign vcAltFieldName = "tcAccntCode".
<M-23 run GetAlternateInfo
   (input  vhResultTT (ihResultTT), 
    input  icCOACrossRefCode (icCOACrossRefCode), 
    input  vcAltFieldName (icAltFieldName), 
    output viFcReturnSuper (oiReturnStatus)) in BAccountingInterface>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then do:
    assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.
end.


/* Use prodataset to encapsulat the temp-table */
/*create dataset ohGLVoucher in widget-pool "non-persistent".
ohGLVoucher:set-buffers(buffer tReport:handle,buffer tGLVoucher:handle).
ohGLvoucher:add-relation(buffer tReport:handle,buffer tGLVoucher:handle,'tiReportID,tiReportID',?,true).
ohGLVoucher:name = {&EXPORTREPORTCODE-JZPZ}.*/


create dataset ohGLVoucher in widget-pool "non-persistent". 
create buffer vhReport for table buffer tReport:handle in widget-pool "non-persistent".
create buffer vhGLVoucher for table buffer tGLVoucher:handle in widget-pool "non-persistent".
ohGLVoucher:set-buffers(vhReport, vhGLVoucher).
ohGLVoucher:add-relation(vhReport, vhGLVoucher, 'tiReportID,tiReportID', ?, true).
ohGLVoucher:name = {&EXPORTREPORTCODE-JZPZ}.


/* ohGLVoucher:WRITE-XML("file", "C:\Develop\wht\Client\testJZPZ.xml", YES, ?, ?, NO, NO). */

if oiReturnStatus = -98
then assign oiReturnStatus = 0.