project QadFinancials > class BFixedAssetDepreciation > method DepreciationTypeCZTaxAccelerated

Description

Execute Depreciations for the Type 'CZ Tax Accelerated' (CZTAXACCELERATED)


Parameters


icFAAssetBookDepreciationTypeinputcharacter
iiFAAssetBookIdinputinteger
iiFAAssetBookPeriodsDepreciatedinputinteger
itFAAssetBookStartDateinputdate
itFAAssetBookNextPostingDateinputdate
iiDepreciationYearinputinteger
iiDepreciationPeriodinputinteger
idFAAssetBookCapitalAmountLCinputdecimal
idFAAssetBookDeprecAmountLCinputdecimal
idFAAssetBookSalvageAmountLCinputdecimal
idFAAssetBookDisposalAmountLCinputdecimal
idFAAssetBookDisposalDepAmountLCinputdecimal
idFAAssetBookCapitalAmountCCinputdecimal
idFAAssetBookDeprecAmountCCinputdecimal
idFAAssetBookSalvageAmountCCinputdecimal
idFAAssetBookDisposalAmountCCinputdecimal
idFAAssetBookDisposalDepAmountCCinputdecimal
tNewDepreciationoutputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BFixedAssetDepreciation.DepreciationTypes


program code (program1/bfixedassetdepreciation.p)

empty temp-table tNewDepreciation.

if iiFAAssetBookId <> 0 and
   iiFAAssetBookId <> ?
then do:
    /*Get last year for depretiation*/
    <Q-9 run PeriodByYearType (last) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input iiDepreciationYear, (PeriodYear)
           input {&PERIODTYPECODE-NORMAL}, (PeriodTypeCode)
           output dataset tqPeriodByYearType) in BPeriod >
    find first tqPeriodByYearType no-error.
    if available tqPeriodByYearType and
       tqPeriodByYearType.tiPeriodPeriod > 0
    then assign viLastYear = if tqPeriodByYearType.tiPeriodPeriod = iiDepreciationPeriod
                        then iiDepreciationYear
                        else iiDepreciationYear - 1.
    else assign viLastYear = year(itFAAssetBookNextPostingDate).    
    
    <Q-1 run FAAssetBookByCEE (all) (Read) (NoCache)
          (input iiFAAssetBookId, (FAAssetBookId)
           output dataset tqFAAssetBookByCEE) in BFixedAssetAsset >
    find first tqFAAssetBookByCEE no-error.
    if available tqFAAssetBookByCEE
    then do viCounter = year(itFAAssetBookNextPostingDate) to viLastYear:
        create tNewDepreciation.
        assign tNewDepreciation.tiNewDeprYear = viCounter.
               
        /* Was the addition already performent on the investment */
        if tqFAAssetBookByCEE.tlFAAssetBookIsAddition
        then assign tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC 
                                                           + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC 
                                                           - <M-4 GetCumulDeprAmountLC () in BFixedAssetDepreciation> 
                                                           - idFAAssetBookSalvageAmountLC) 
                                                          * 2 
                                                          / max(tqFAAssetBookByCEE.tdFAAssetBookCEEAccelAddit - iiFAAssetBookPeriodsDepreciated, 2))
                    tNewDepreciation.tdNewDeprAmountCC = ((idFAAssetBookCapitalAmountCC - idFAAssetBookDisposalAmountCC 
                                                           + idFAAssetBookDisposalDepAmountCC - idFAAssetBookDeprecAmountCC 
                                                           - <M-6 GetCumulDeprAmountCC () in BFixedAssetDepreciation> 
                                                           - idFAAssetBookSalvageAmountCC) 
                                                          * 2 
                                                          / max(tqFAAssetBookByCEE.tdFAAssetBookCEEAccelAddit - iiFAAssetBookPeriodsDepreciated,2)).
                    
        /* Or Is the Depreciation within the first year */
        else if viCounter                          = year(itFAAssetBookNextPostingDate) and
                year(itFAAssetBookNextPostingDate) = year(itFAAssetBookStartDate)
        then assign tNewDepreciation.tdNewDeprAmountLC = (((idFAAssetBookCapitalAmountLC - idFAAssetBookSalvageAmountLC) 
                                                           / tqFAAssetBookByCEE.tdFAAssetBookCEEAccelFirstYr) 
                                                          * ((100 + tqFAAssetBookByCEE.tdFAAssetBookCEEAccelIncrDpr) / 100))
                    tNewDepreciation.tdNewDeprAmountCC = (((idFAAssetBookCapitalAmountCC - idFAAssetBookSalvageAmountCC)
                                                           / tqFAAssetBookByCEE.tdFAAssetBookCEEAccelFirstYr) 
                                                          * ((100 + tqFAAssetBookByCEE.tdFAAssetBookCEEAccelIncrDpr) / 100)).
        
        /* Or Is the Depreciation within the other years */
        else assign tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC 
                                                           + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC 
                                                           - <M-3 GetCumulDeprAmountLC () in BFixedAssetDepreciation> 
                                                           - idFAAssetBookSalvageAmountLC) 
                                                          * 2 
                                                          / max(tqFAAssetBookByCEE.tdFAAssetBookCEEAccelNextYr - iiFAAssetBookPeriodsDepreciated,2))
                    tNewDepreciation.tdNewDeprAmountCC = ((idFAAssetBookCapitalAmountCC - idFAAssetBookDisposalAmountCC 
                                                           + idFAAssetBookDisposalDepAmountCC - idFAAssetBookDeprecAmountCC 
                                                           - <M-7 GetCumulDeprAmountCC () in BFixedAssetDepreciation> 
                                                           - idFAAssetBookSalvageAmountCC) 
                                                          * 2 
                                                          / max(tqFAAssetBookByCEE.tdFAAssetBookCEEAccelNextYr - iiFAAssetBookPeriodsDepreciated,2)).

        <M-2 run RoundCZTaxDepreciationAmounts (input-output tNewDepreciation.tdNewDeprAmountLC (bdNewDeprAmountLC), 
                                        output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
        
        assign iiFAAssetBookPeriodsDepreciated = iiFAAssetBookPeriodsDepreciated + 1.                                        
    end.    
end.