project QadFinancials > class BFixedAssetDepreciation > method DepreciationTypeCZTaxStraight

Description

Execute Depreciations for the Type 'CZ Tax Straight' (CZTAXSL)


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 the last year for depretiation*/
    <Q-5 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.
               
        /* Calculate depreciation amount */
        /* Was the addition already performent on the investment */
        if tqFAAssetBookByCEE.tlFAAssetBookIsAddition
        then assign tNewDepreciation.tdNewDeprAmountLC = (idFAAssetBookCapitalAmountLC - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC)
                                                       * tqFAAssetBookByCEE.tdFAAssetBookCEEEvenAddition / 100
                    tNewDepreciation.tdNewDeprAmountCC = (idFAAssetBookCapitalAmountCC - idFAAssetBookSalvageAmountCC - idFAAssetBookDisposalAmountCC)
                                                       * tqFAAssetBookByCEE.tdFAAssetBookCEEEvenAddition / 100.
        
        /* Or Is the Depreciation within the first year */
        else if viCounter = year(itFAAssetBookNextPostingDate) and
                year(itFAAssetBookNextPostingDate) = year(itFAAssetBookStartDate)
        then assign tNewDepreciation.tdNewDeprAmountLC = (idFAAssetBookCapitalAmountLC - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC) 
                                                       * tqFAAssetBookByCEE.tdFAAssetBookCEEEvenFirstYr / 100
                    tNewDepreciation.tdNewDeprAmountCC = (idFAAssetBookCapitalAmountCC - idFAAssetBookSalvageAmountCC - idFAAssetBookDisposalAmountCC)
                                                       * tqFAAssetBookByCEE.tdFAAssetBookCEEEvenFirstYr / 100.
                    
        /* Or Is the Depreciation within the other years */
        else assign tNewDepreciation.tdNewDeprAmountLC = (idFAAssetBookCapitalAmountLC - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC)
                                                       * tqFAAssetBookByCEE.tdFAAssetBookCEEEvenNextYr / 100
                    tNewDepreciation.tdNewDeprAmountCC = (idFAAssetBookCapitalAmountCC - idFAAssetBookSalvageAmountCC - idFAAssetBookDisposalAmountCC) 
                                                       * tqFAAssetBookByCEE.tdFAAssetBookCEEEvenNextYr / 100.
        
        <M-2 run RoundCZTaxDepreciationAmounts (input-output tNewDepreciation.tdNewDeprAmountLC (bdNewDeprAmountLC), 
                                        output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>

        /* Depreciation amount cannot exceed total net book value of fixed asset book */
        assign vdNetBookValueLC = idFAAssetBookCapitalAmountLC
                                - idFAAssetBookSalvageAmountLC
                                - (idFAAssetBookDisposalAmountLC - idFAAssetBookDisposalDepAmountLC)
                                - idFAAssetBookDeprecAmountLC
               vdNetBookValueCC = idFAAssetBookCapitalAmountCC
                                - idFAAssetBookSalvageAmountCC
                                - (idFAAssetBookDisposalAmountCC - idFAAssetBookDisposalDepAmountCC)
                                - idFAAssetBookDeprecAmountCC.

        if tNewDepreciation.tdNewDeprAmountLC > vdNetBookValueLC or
           tNewDepreciation.tdNewDeprAmountCC > vdNetBookValueCC
        then assign tNewDepreciation.tdNewDeprAmountLC = vdNetBookValueLC
                    tNewDepreciation.tdNewDeprAmountCC = vdNetBookValueCC.
                    
        /* Increase number of depreciated periods */
        assign iiFAAssetBookPeriodsDepreciated = iiFAAssetBookPeriodsDepreciated + 1.                                        
    end.    
end.