project QadFinancials > class BCashBoxReport > method CashReceived

report procedure


Parameters


icLanguageCodeinputcharacter
tFilterinputtemp-table
dcrCashReceivedoutputdataset
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bcashboxreport.p)

empty temp-table tqCashReceived.

<M-1 run GetReportLabels
   (input  'CashReceived':U (icReportName), 
    input  icLanguageCode (icLanguageCode), 
    input  tFilter (tFilter), 
    output tqHeader (tqHeader), 
    output tqFilter (tqFilter), 
    output tqText (tqText), 
    output oiReturnStatus (oiReturnStatus)) in BCashBoxReport>

if oiReturnStatus <> 0
then return.

find first tqHeader no-error.
if available tqHeader
then assign tqHeader.tcReportTitle = #T-15'Cash Received':20(999890342)T-15#
        tqHeader.tcExtraInfo = #T-16'Petty Cash Report':40(50832)T-16# + " - ":U.

<M-2 run SetDataItemsBasedOnFilterTT  (output oiReturnStatus (oiReturnStatus)) in BCashBoxReport>
/*bank state line's id must be filled*/
if vcCandoBankStateLineIDFilter = ?
then do:
    <M-3 run SetMessage
       (input  #T-17'No bank statement lines have been specified.':100(999890337)T-17# (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-9112':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output oiReturnStatus (oiReturnStatus)) in BCashBoxReport>
    assign oiReturnStatus = -1.
    return.                     
end.

/*cache queries*/
<Q-4 run JournalPrim (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input ?, (JournalCode)
    input ?, (JournalID)
    output dataset tqJournalPrim) in BJournal >           
<Q-5 run PeriodByYearPeriod (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input ?, (PeriodYear)
    input ?, (PeriodPeriod)
    input ?, (PeriodId)
    output dataset tqPeriodByYearPeriod) in BPeriod >                        

/*business relation informations for company*/                            
<Q-6 run BusinessRelationByCompanyID (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
    output dataset tqBusinessRelationByCompanyID) in BCashBoxReport >    

/*core query*/
<Q-7 run BaseCashOperation (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input {&BANKSTATETRANSTYPE-CASH}, (BankStateTransactionType)
    input vcCandoBankStateLineIDFilter, (CanDoBankStateLines)
    output dataset tqBaseCashOperation) in BCashBoxReport >           
                            
<Q-8 run BusinessRelationByBRID  (Start) in BCashBoxReport > 
<Q-9 run GetCurrDescriptions  (Start) in BCashBoxReport >   

for each tqBaseCashOperation:
    /*only input lines could displayed*/
    if tqBaseCashOperation.tcBankStateLineInOut = "-":U
    then next.

    create tqCashReceived.
    buffer-copy tqBaseCashOperation to tqCashReceived.
    
    assign tqCashReceived.tcCurrencyCode         = tqBaseCashOperation.tcCurrencyCode
           tqCashReceived.tcCurrencyCodeBankLine = tqBaseCashOperation.tcCurrencyCode
           tqCashReceived.tcCurrencyCodeLC       = tqBaseCashOperation.tcCurrencyCode
           tqCashReceived.tcCurrencyCodePosting  = tqBaseCashOperation.tcPostingLineCurrency.
           
    /*business relation informations for company*/    
    find first tqBusinessRelationByCompanyID no-error.
    if available tqBusinessRelationByCompanyID then                            
       assign tqCashReceived.tcBusinessRelationName1Comp  = tqBusinessRelationByCompanyID.tcBusinessRelationName1
              tqCashReceived.tcAddressCityComp            = tqBusinessRelationByCompanyID.tcAddressCity
              tqCashReceived.tcAddressStreet1Comp         = tqBusinessRelationByCompanyID.tcAddressStreet1
              tqCashReceived.tcAddressStreet2Comp         = tqBusinessRelationByCompanyID.tcAddressStreet2
              tqCashReceived.tcAddressZipComp             = tqBusinessRelationByCompanyID.tcAddressZip.
        
    vdAmount = ABS(tqBaseCashOperation.tdBankStateLineAmountTC).
    tqCashReceived.tiDollarAmount = INT(TRUNCATE(vdAmount, 0)).
    tqCashReceived.tiCentAmount = INT((vdAmount - tqCashReceived.tiDollarAmount) * 100).
    
    <Q-10 run GetCurrDescriptions (all) (Read) (NoCache)
       (input tqCashReceived.tcCurrencyCode, (CurrencyCode)
        output dataset tqGetCurrDescriptions) in BCashBoxReport >  

    find first tqGetCurrDescriptions no-lock no-error.
    if available tqGetCurrDescriptions then do:    
       tqCashReceived.tcDollarCurrency = tqGetCurrDescriptions.tcCurrencyDescription.
       tqCashReceived.tcCentCurrency = tqGetCurrDescriptions.tcCurrencyDecimalDescription.    
    end.           
            
    find first tqJournalPrim where tqJournalPrim.tiJournal_ID = tqBaseCashOperation.tiJournal_ID no-error.
    if available tqJournalPrim
    then 
    assign tqCashReceived.tcJournalCode = tqJournalPrim.tcJournalCode.
    
    find first tqPeriodByYearPeriod where tqPeriodByYearPeriod.tiPeriod_ID = tqBaseCashOperation.tiPeriod_ID no-error.
    if available tqPeriodByYearPeriod
    then
    assign tqCashReceived.tiPeriodYear = tqPeriodByYearPeriod.tiPeriodYear.
        
    if(tqBaseCashOperation.tiCInvoice_ID <> 0)
    then do:
        assign tqCashReceived.tiVoucherReference = tqBaseCashOperation.tiCInvoiceVoucher.
    
        find first tqJournalPrim where tqJournalPrim.tiJournal_ID = tqBaseCashOperation.tiCInvJournal_ID no-error.
        if available tqJournalPrim
        then assign tqCashReceived.tcJournalCodeReference = tqJournalPrim.tcJournalCode.
        
        find first tqPeriodByYearPeriod where tqPeriodByYearPeriod.tiPeriod_ID = tqBaseCashOperation.tiCInvPeriod_ID no-error.
        if available tqPeriodByYearPeriod
        then assign tqCashReceived.tiPeriodYearReference = tqPeriodByYearPeriod.tiPeriodYear.
        
        <Q-11 run BusinessRelationByBRID (all) (Read) (NoCache)
           (input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
            input tqBaseCashOperation.tiCrBusRel_ID, (BusinessRelationID)
            output dataset tqBusinessRelationByBRID) in BCashBoxReport >
        find first tqBusinessRelationByBRID no-error.
        if available tqBusinessRelationByBRID
        then do:
            assign tqCashReceived.tcBusinessRelationName1   = tqBusinessRelationByBRID.tcBusinessRelationName1
                tqCashReceived.tcAddressCity                = tqBusinessRelationByBRID.tcAddressCity
                tqCashReceived.tcAddressStreet1             = tqBusinessRelationByBRID.tcAddressStreet1
                tqCashReceived.tcAddressStreet2             = tqBusinessRelationByBRID.tcAddressStreet2
                tqCashReceived.tcAddressZip                 = tqBusinessRelationByBRID.tcAddressZip.
        end.                                 
    end.
    
    if(tqBaseCashOperation.tiDInvoice_ID <> 0)
    then do:
        assign tqCashReceived.tiVoucherReference = tqBaseCashOperation.tiDInvoiceVoucher.

        find first tqJournalPrim where tqJournalPrim.tiJournal_ID = tqBaseCashOperation.tiDInvJournal_ID no-error.
        if available tqJournalPrim
        then assign tqCashReceived.tcJournalCodeReference = tqJournalPrim.tcJournalCode.
        
        find first tqPeriodByYearPeriod where tqPeriodByYearPeriod.tiPeriod_ID = tqBaseCashOperation.tiDInvPeriod_ID no-error.
        if available tqPeriodByYearPeriod
        then assign tqCashReceived.tiPeriodYearReference = tqPeriodByYearPeriod.tiPeriodYear.
        
        <Q-12 run BusinessRelationByBRID (all) (Read) (NoCache)
           (input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
            input tqBaseCashOperation.tiDebBusRel_ID, (BusinessRelationID)
            output dataset tqBusinessRelationByBRID) in BCashBoxReport >
        find first tqBusinessRelationByBRID no-error.
        if available tqBusinessRelationByBRID
        then do:
            assign tqCashReceived.tcBusinessRelationName1   = tqBusinessRelationByBRID.tcBusinessRelationName1
                tqCashReceived.tcAddressCity                = tqBusinessRelationByBRID.tcAddressCity
                tqCashReceived.tcAddressStreet1             = tqBusinessRelationByBRID.tcAddressStreet1
                tqCashReceived.tcAddressStreet2             = tqBusinessRelationByBRID.tcAddressStreet2
                tqCashReceived.tcAddressZip                 = tqBusinessRelationByBRID.tcAddressZip.
        end.                                 
    end.
    
    if(tqBaseCashOperation.tiAloccPosting_ID <> 0 and tqBaseCashOperation.tiCInvoice_ID = 0 and tqBaseCashOperation.tiDInvoice_ID = 0)
    then do:
        assign tqCashReceived.tiVoucherReference = tqBaseCashOperation.tiAlocPostingVoucher.

        find first tqJournalPrim where tqJournalPrim.tiJournal_ID = tqBaseCashOperation.tiAlocJournal_ID no-error.
        if available tqJournalPrim
        then assign tqCashReceived.tcJournalCodeReference = tqJournalPrim.tcJournalCode.
        
        find first tqPeriodByYearPeriod where tqPeriodByYearPeriod.tiPeriod_ID = tqBaseCashOperation.tiAlocPeriod_ID no-error.
        if available tqPeriodByYearPeriod
        then assign tqCashReceived.tiPeriodYearReference = tqPeriodByYearPeriod.tiPeriodYear.
    end.
    
    
    if tqCashReceived.tiVoucherReference = 0
    then assign tqCashReceived.tiVoucherReference     = tqCashReceived.tiPostingVoucher
                tqCashReceived.tcJournalCodeReference = tqCashReceived.tcJournalCode
                tqCashReceived.tiPeriodYearReference  = tqCashReceived.tiPeriodYear.
                                                                                        
end.                            
<Q-13 run BusinessRelationByBRID  (Stop) in BCashBoxReport > 
<Q-14 run GetCurrDescriptions  (Stop) in BCashBoxReport >