project QadFinancials > class BRevaluationReport > method Revaluation

report procedure


Parameters


icLanguageCodeinputcharacterLanguage Code.
tFilterinputtemp-tableTemp table likes filter, stores all the data user input on User Interface report select criteria.
dcrRevaluationoutputdatasetDataset of Revaluation Report.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/brevaluationreport.p)

empty temp-table tqRevaluation.

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

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

if oiReturnStatus < 0
then return.

<M-2 run SetDataItemsBasedOnFilterTT
   (output viFcReturnSuper (oiReturnStatus)) in BRevaluationReport>

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

if oiReturnStatus < 0
then return.

/* Check mandatory fields */
if viRVAccYearFilter = ?
then do:
    <M-3 run SetMessage
       (input  trim(#T-36'You must specify a value for the GL Calendar Year filter.':50(2286)t-36#) (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  '':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QADFIN-2788':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BRevaluationReport>

    assign oiReturnStatus = -1.
    return.
end.

if vlRVAmountInCCFilter and
  (vcCompanyCC = "":U or
   vcCompanyCC = ?)
then return.

/* if viRVRevaluationNumberFilter = ?
then do:
    <Q-37 run PeriodForRevReport (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input viRVAccYearFilter, (AccYear)
        input viRVAccPeriodFilter, (AccPeriod)
        output dataset tqPeriodForRevReport) in BRevaluationReport >

    for each tqPeriodForRevReport:
        if viRVRevaluationNumberFilter = ?
        then assign viRVRevaluationNumberFilter = tqPeriodForRevReport.tiRevalHeaderNumber.
        else
        if viRVRevaluationNumberFilter < tqPeriodForRevReport.tiRevalHeaderNumber
        then assign viRVRevaluationNumberFilter = tqPeriodForRevReport.tiRevalHeaderNumber.
    end.

    empty temp-table tqPeriodForRevReport.
end.

if viRVRevaluationNumberFilter = ?
then return. */

<Q-42 run GLForRevReport (Start) in BRevaluationReport >

<Q-43 run GLForRevReport (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input {&GLSYSTEMTYPE-EXCHANGEUNREALLOSS}, (GLSystemTypeCode)
    output dataset tqGLForRevReport) in BRevaluationReport >

find first tqGLForRevReport where
           tqGLForRevReport.tcGLSystemTypeCode = {&GLSYSTEMTYPE-EXCHANGEUNREALLOSS}
           no-error.

assign vcGLCodeExLoss        = if available tqGLForRevReport
                               then tqGLForRevReport.tcGLCode
                               else "":U
       vcGLDescriptionExLoss = if available tqGLForRevReport
                               then tqGLForRevReport.tcGLDescription
                               else "":U.

<Q-44 run GLForRevReport (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input {&GLSYSTEMTYPE-EXCHANGEUNREALPROFIT}, (GLSystemTypeCode)
    output dataset tqGLForRevReport) in BRevaluationReport >

find first tqGLForRevReport where
           tqGLForRevReport.tcGLSystemTypeCode = {&GLSYSTEMTYPE-EXCHANGEUNREALPROFIT}
           no-error.

assign vcGLCodeExGain        = if available tqGLForRevReport
                               then tqGLForRevReport.tcGLCode
                               else "":U
       vcGLDescriptionExGain = if available tqGLForRevReport
                               then tqGLForRevReport.tcGLDescription
                               else "":U.

<Q-45 run GLForRevReport (Stop) in BRevaluationReport >

<Q-39 run CurrencyForRevReport (all) (Read) (NoCache)
   (output dataset tqCurrencyForRevReport) in BRevaluationReport >

<Q-40 run DivisionForRevReport (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    output dataset tqDivisionForRevReport) in BRevaluationReport >

<Q-41 run CostCentreForRevReport (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    output dataset tqCostCentreForRevReport) in BRevaluationReport >

<Q-13 run CDocumentForRevReport (Start) in BRevaluationReport >
<Q-14 run CInvoiceForRevReport (Start) in BRevaluationReport >
<Q-15 run DDocumentForRevReport (Start) in BRevaluationReport >
<Q-16 run DInvoiceForRevReport (Start) in BRevaluationReport >

<Q-38 run RevaluationForBase (all) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input viRVAccPeriodFilter, (AccPeriod)
    input viRVAccYearFilter, (AccYear)
    input viRVRevaluationNumberFilter, (RevalNumber)
    input vcRVRevaluationAreaFilter, (RevalArea)
    output dataset tqRevaluationForBase) in BRevaluationReport >

for each tqRevaluationForBase
         break by tqRevaluationForBase.tiRevalGL_ID:
    create tqRevaluation.
    buffer-copy tqRevaluationForBase to tqRevaluation.

    assign tqRevaluation.tcGLCodeExLoss        = vcGLCodeExLoss
           tqRevaluation.tcGLDescriptionExLoss = vcGLDescriptionExLoss
           tqRevaluation.tcGLCodeExGain        = vcGLCodeExGain
           tqRevaluation.tcGLDescriptionExGain = vcGLDescriptionExGain.

    /* Calculate document's values */
    if tqRevaluationForBase.tiRevalDetParentObject_ID > 0
    then case tqRevaluationForBase.tcRevalDetParentObjectType:
        /* CInvoice */
        when {&REVALDETTYPE-CINV}
        then do:
            <Q-21 run CInvoiceForRevReport (all) (Read) (NoCache)
               (input ?, (CompanyId)
                input tqRevaluationForBase.tiRevalDetParentObject_ID, (CInvoiceID)
                output dataset tqCInvoiceForRevReport) in BRevaluationReport >

            find first tqCInvoiceForRevReport where
                       tqCInvoiceForRevReport.tiCInvoice_ID = tqRevaluationForBase.tiRevalDetParentObject_ID
                       no-error.

            if available tqCInvoiceForRevReport
            then assign tqRevaluation.tcBusinessRelationCode  = tqCInvoiceForRevReport.tcBusinessRelationCode
                        tqRevaluation.tcBusinessRelationName1 = tqCInvoiceForRevReport.tcBusinessRelationName1
                        tqRevaluation.tcCInvoiceType          = tqCInvoiceForRevReport.tcCInvoiceType
                        tqRevaluation.tcCreditorCode          = tqCInvoiceForRevReport.tcCreditorCode
                        tqRevaluation.tcCreditorDebtor        = tqCInvoiceForRevReport.tcCreditorCode
                        tqRevaluation.tcJournalCode           = tqCInvoiceForRevReport.tcJournalCode
                        tqRevaluation.tdCInvoiceExchangeRate  = tqCInvoiceForRevReport.tdCInvoiceExchangeRate
                        tqRevaluation.tdCInvoiceRateScale     = tqCInvoiceForRevReport.tdCInvoiceRateScale
                        tqRevaluation.tdExRateAll             = tqCInvoiceForRevReport.tdCInvoiceExchangeRate * tqCInvoiceForRevReport.tdCinvoiceRateScale
                        tqRevaluation.tiCInvoiceVoucher       = tqCInvoiceForRevReport.tiCInvoiceVoucher
                        tqRevaluation.tiDocumentAll           = tqCInvoiceForRevReport.tiCInvoiceVoucher
                        tqRevaluation.tiPeriodPeriodCinv      = tqCInvoiceForRevReport.tiCInvoicePostingPeriod
                        tqRevaluation.tiPeriodYearCinv        = tqCInvoiceForRevReport.tiCInvoicePostingYear
                        tqRevaluation.tiYearAll               = year(tqCInvoiceForRevReport.ttCInvoiceDate)
                        tqRevaluation.ttCInvoiceDate          = tqCInvoiceForRevReport.ttCInvoiceDate
                        tqRevaluation.ttDateAll               = tqCInvoiceForRevReport.ttCInvoiceDate.
        end.

        /* CDocument */
        when {&REVALDETTYPE-CDOC}
        then do:
            <Q-22 run CDocumentForRevReport (all) (Read) (NoCache)
               (input ?, (CompanyId)
                input tqRevaluationForBase.tiRevalDetParentObject_ID, (CDocumentID)
                output dataset tqCDocumentForRevReport) in BRevaluationReport >

            find first tqCDocumentForRevReport where
                       tqCDocumentForRevReport.tiCDocument_ID = tqRevaluationForBase.tiRevalDetParentObject_ID
                       no-error.

            if available tqCDocumentForRevReport
            then assign tqRevaluation.tcBusinessRelationCode  = tqCDocumentForRevReport.tcBusinessRelationCode
                        tqRevaluation.tcBusinessRelationName1 = tqCDocumentForRevReport.tcBusinessRelationName1
                        tqRevaluation.tcCDocumentSubType      = tqCDocumentForRevReport.tcCDocumentSubType
                        tqRevaluation.tcCDocumentType         = tqCDocumentForRevReport.tcCDocumentType
                        tqRevaluation.tcCreditorCode          = tqCDocumentForRevReport.tcCreditorCode
                        tqRevaluation.tcCreditorDebtor        = tqCDocumentForRevReport.tcCreditorCode
                        tqRevaluation.tdCDocumentExchangeRate = tqCDocumentForRevReport.tdCDocumentExchangeRate
                        tqRevaluation.tdCDocumentRateScale    = tqCDocumentForRevReport.tdCDocumentRateScale
                        tqRevaluation.tdExRateAll             = tqCDocumentForRevReport.tdCDocumentExchangeRate * tqCDocumentForRevReport.tdCDocumentRateScale
                        tqRevaluation.tiCDocumentNumber       = tqCDocumentForRevReport.tiCDocumentNumber
                        tqRevaluation.tiCDocumentYear         = tqCDocumentForRevReport.tiCDocumentYear
                        tqRevaluation.tiDocumentAll           = tqCDocumentForRevReport.tiCDocumentNumber
                        tqRevaluation.tiYearAll               = year(tqCDocumentForRevReport.ttCDocumentCreationDate)
                        tqRevaluation.ttCDocumentCreationDate = tqCDocumentForRevReport.ttCDocumentCreationDate
                        tqRevaluation.ttDateAll               = tqCDocumentForRevReport.ttCDocumentCreationDate.
        end.

        /* DInvoice */
        when {&REVALDETTYPE-DINV}
        then do:
            <Q-23 run DInvoiceForRevReport (all) (Read) (NoCache)
               (input ?, (CompanyId)
                input tqRevaluationForBase.tiRevalDetParentObject_ID, (DInvoiceID)
                output dataset tqDInvoiceForRevReport) in BRevaluationReport >

            find first tqDInvoiceForRevReport where
                       tqDInvoiceForRevReport.tiDInvoice_ID = tqRevaluationForBase.tiRevalDetParentObject_ID
                       no-error.

            if available tqDInvoiceForRevReport
            then assign tqRevaluation.tcBusinessRelationCode  = tqDInvoiceForRevReport.tcBusinessRelationCode
                        tqRevaluation.tcBusinessRelationName1 = tqDInvoiceForRevReport.tcBusinessRelationName1
                        tqRevaluation.tcCreditorDebtor        = tqDInvoiceForRevReport.tcDebtorCode
                        tqRevaluation.tcDebtorCode            = tqDInvoiceForRevReport.tcDebtorCode
                        tqRevaluation.tcDInvoiceType          = tqDInvoiceForRevReport.tcDInvoiceType
                        tqRevaluation.tcJournalCode           = tqDInvoiceForRevReport.tcJournalCode
                        tqRevaluation.tdDInvoiceExchangeRate  = tqDInvoiceForRevReport.tdDInvoiceExchangeRate
                        tqRevaluation.tdDInvoiceRateScale     = tqDInvoiceForRevReport.tdDInvoiceRateScale
                        tqRevaluation.tdExRateAll             = tqDInvoiceForRevReport.tdDInvoiceExchangeRate * tqDInvoiceForRevReport.tdDInvoiceRateScale
                        tqRevaluation.tiDInvoiceVoucher       = tqDInvoiceForRevReport.tiDInvoiceVoucher
                        tqRevaluation.tiDocumentAll           = tqDInvoiceForRevReport.tiDInvoiceVoucher
                        tqRevaluation.tiPeriodPeriodDinv      = tqDInvoiceForRevReport.tiDInvoicePostingPeriod
                        tqRevaluation.tiPeriodYearDinv        = tqDInvoiceForRevReport.tiDInvoicePostingYear
                        tqRevaluation.tiYearAll               = year(tqDInvoiceForRevReport.ttDInvoiceDate)
                        tqRevaluation.ttDateAll               = tqDInvoiceForRevReport.ttDInvoiceDate
                        tqRevaluation.ttDInvoiceDate          = tqDInvoiceForRevReport.ttDInvoiceDate.
        end.

        /* DDocument*/
        when {&REVALDETTYPE-DDOC}
        then do:
            <Q-24 run DDocumentForRevReport (all) (Read) (NoCache)
               (input ?, (CompanyId)
                input tqRevaluationForBase.tiRevalDetParentObject_ID, (DDocumentID)
                output dataset tqDDocumentForRevReport) in BRevaluationReport >

            find first tqDDocumentForRevReport where
                       tqDDocumentForRevReport.tiDDocument_ID = tqRevaluationForBase.tiRevalDetParentObject_ID
                       no-error.

            if available tqDDocumentForRevReport
            then assign tqRevaluation.tcBusinessRelationCode  = tqDDocumentForRevReport.tcBusinessRelationCode
                        tqRevaluation.tcBusinessRelationName1 = tqDDocumentForRevReport.tcBusinessRelationName1
                        tqRevaluation.tcCreditorDebtor        = tqDDocumentForRevReport.tcDebtorCode
                        tqRevaluation.tcDDocumentSubType      = tqDDocumentForRevReport.tcDDocumentSubType
                        tqRevaluation.tcDDocumentType         = tqDDocumentForRevReport.tcDDocumentType
                        tqRevaluation.tcDebtorCode            = tqDDocumentForRevReport.tcDebtorCode
                        tqRevaluation.tdDDocumentExchangeRate = tqDDocumentForRevReport.tdDDocumentExchangeRate
                        tqRevaluation.tdDDocumentRateScale    = tqDDocumentForRevReport.tdDDocumentRateScale
                        tqRevaluation.tdExRateAll             = tqDDocumentForRevReport.tdDDocumentExchangeRate * tqDDocumentForRevReport.tdDDocumentRateScale
                        tqRevaluation.tiDDocumentNumber       = tqDDocumentForRevReport.tiDDocumentNumber
                        tqRevaluation.tiDDocumentYear         = tqDDocumentForRevReport.tiDDocumentYear
                        tqRevaluation.tiDocumentAll           = tqDDocumentForRevReport.tiDDocumentNumber
                        tqRevaluation.tiYearAll               = year(tqDDocumentForRevReport.ttDDocumentCreationDate)
                        tqRevaluation.ttDateAll               = tqDDocumentForRevReport.ttDDocumentCreationDate
                        tqRevaluation.ttDDocumentCreationDate = tqDDocumentForRevReport.ttDDocumentCreationDate.
        end.
    end.

    if vlRVAmountinCCFilter
    then do:
        assign tqRevaluation.tdRevalDetCreditXC    = tqRevaluationForBase.tdRevalDetCreditCC
               tqRevaluation.tdRevalDetDebitXC     = tqRevaluationForBase.tdRevalDetDebitCC
               tqRevaluation.tdRevalDetRevCreditXC = tqRevaluationForBase.tdRevalDetRevCreditCC
               tqRevaluation.tdRevalDetRevDebitXC  = tqRevaluationForBase.tdRevalDetRevDebitCC.

        if last-of(tqRevaluationForBase.tiRevalGL_ID)
        then assign tqRevaluation.tdRevalGLCreditXC    = tqRevaluationForBase.tdRevalGLCreditCC
                    tqRevaluation.tdRevalGLDebitXC     = tqRevaluationForBase.tdRevalGLDebitCC
                    tqRevaluation.tdRevalGLRevCreditXC = tqRevaluationForBase.tdRevalGLRevCreditCC
                    tqRevaluation.tdRevalGLRevDebitXC  = tqRevaluationForBase.tdRevalGLRevDebitCC.

        if tqRevaluationForBase.tdRevalGLDebitTC - tqRevaluationForBase.tdRevalGLCreditTC <> 0
        then assign tqRevaluation.tdExRateAll = (tqRevaluationForBase.tdRevalGLDebitCC   -
                                                 tqRevaluationForBase.tdRevalGLCreditCC) /
                                                (tqRevaluationForBase.tdRevalGLDebitTC   -
                                                 tqRevaluationForBase.tdRevalGLCreditTC).
    end.
    else do:
        assign tqRevaluation.tdRevalDetCreditXC    = tqRevaluationForBase.tdRevalDetCreditLC
               tqRevaluation.tdRevalDetDebitXC     = tqRevaluationForBase.tdRevalDetDebitLC
               tqRevaluation.tdRevalDetRevCreditXC = tqRevaluationForBase.tdRevalDetRevCreditLC
               tqRevaluation.tdRevalDetRevDebitXC  = tqRevaluationForBase.tdRevalDetRevDebitLC.

        if last-of(tqRevaluationForBase.tiRevalGL_ID)
        then assign tqRevaluation.tdRevalGLCreditXC    = tqRevaluationForBase.tdRevalGLCreditLC
                    tqRevaluation.tdRevalGLDebitXC     = tqRevaluationForBase.tdRevalGLDebitLC
                    tqRevaluation.tdRevalGLRevCreditXC = tqRevaluationForBase.tdRevalGLRevCreditLC
                    tqRevaluation.tdRevalGLRevDebitXC  = tqRevaluationForBase.tdRevalGLRevDebitLC.
    end.

    if tqRevaluation.tdRevalGLCreditXC    = ? or
       tqRevaluation.tdRevalGLDebitXC     = ? or
       tqRevaluation.tdRevalGLRevCreditXC = ? or
       tqRevaluation.tdRevalGLRevDebitXC  = ?
    then do:
        delete tqRevaluation.
        next.
    end.

    find first tqCurrencyForRevReport where
               tqCurrencyForRevReport.tiCurrency_ID = tqRevaluationForBase.tiCurrency_ID
               no-error.

    if available tqCurrencyForRevReport
    then assign tqRevaluation.tcCurrencyCode             = tqCurrencyForRevReport.tcCurrencyCode
                tqRevaluation.tcCurrencyDescription      = tqCurrencyForRevReport.tcCurrencyDescription
                tqRevaluation.tiCurrencyNumberOfDecimals = tqCurrencyForRevReport.tiCurrencyNumberOfDecimals.

    find first tqDivisionForRevReport where
               tqDivisionForRevReport.tiDivision_ID = tqRevaluationForBase.tiDivision_ID
               no-error.

    if available tqDivisionForRevReport
    then assign tqRevaluation.tcDivisionCode        = tqDivisionForRevReport.tcDivisionCode
                tqRevaluation.tcDivisionDescription = tqDivisionForRevReport.tcDivisionDescription.

    find first tqCostCentreForRevReport where
               tqCostCentreForRevReport.tiCostCentre_ID = tqRevaluationForBase.tiCostCentre_ID
               no-error.

    if available tqCostCentreForRevReport
    then assign tqRevaluation.tcCostCentreCode        = tqCostCentreForRevReport.tcCostCentreCode
                tqRevaluation.tcCostCentreDescription = tqCostCentreForRevReport.tcCostCentreDescription.
                
        
    case tqRevaluationForBase.tcRevalRevaluationArea:
        when "PROFITANDLOSSGL":U
        then assign tqRevaluation.tcRevalRevaluationArea = trim(#T-53'Profit & Loss Accounts':30(63817)T-53#).

        when "BALANCESHEETGL":U
        then assign tqRevaluation.tcRevalRevaluationArea = trim(#T-54'Balance Sheet Accounts':30(63816)T-54#).

        when "GL":U
        then assign tqRevaluation.tcRevalRevaluationArea = trim(#T-55'GL Revaluation':30(63815)T-55#).

        when "DOPENITEMS":U
        then assign tqRevaluation.tcRevalRevaluationArea = trim(#T-56'Customer Open Items':30(65701)T-56#).

        when "DDOCUMENTS":U
        then assign tqRevaluation.tcRevalRevaluationArea = trim(#T-57'Customer Payments':30(65702)t-57#).

        when "COPENITEMS":U
        then assign tqRevaluation.tcRevalRevaluationArea = trim(#T-58'Supplier Open Items':30(65703)T-58#).

        when "CDOCUMENTS":U
        then assign tqRevaluation.tcRevalRevaluationArea = trim(#T-59'Supplier Payments':30(65704)t-59#).
    end case.
end.

<Q-17 run CDocumentForRevReport (Stop) in BRevaluationReport >
<Q-18 run CInvoiceForRevReport (Stop) in BRevaluationReport >
<Q-19 run DDocumentForRevReport (Stop) in BRevaluationReport >
<Q-20 run DInvoiceForRevReport (Stop) in BRevaluationReport >

empty temp-table tqRevaluationForBase.
empty temp-table tqCostCentreForRevReport.
empty temp-table tqDivisionForRevReport.
empty temp-table tqCurrencyForRevReport.