project QadFinancials > class BFixedAssetDepreciation > method DepreciationTypeDB

Description

Execute Depreciations for the Type '1.5 Declining Balances' (DB15), '2.0 Declining Balances' (DB20), '2.5 Declining Balances' (DB25)


Parameters


icFAAssetBookCalculationTypeinputcharacter
iiFAAssetBookLifeCycleinputinteger
iiFAAssetBookPeriodsDepreciatedinputinteger
itFAAssetBookStartDateinputdate
itFAAssetBookNextPostingDateinputdate
iiDepreciationYearinputinteger
iiDepreciationPeriodinputinteger
idFAAssetBookCapitalAmountLCinputdecimal
idFAAssetBookDeprecAmountLCinputdecimal
idFAAssetBookSalvageAmountLCinputdecimal
idFAAssetBookDisposalAmountLCinputdecimal
idFAAssetBookDisposalDepAmountLCinputdecimal
idFactorinputdecimal
tNewDepreciationoutputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BFixedAssetDepreciation.DepreciationTypes


program code (program1/bfixedassetdepreciation.p)

empty temp-table tNewDepreciation.

case icFAAssetBookCalculationType:
    when {&BOOKCALCULATIONTYPE-FULLYEAR}
    then do:
        do viCounter = ((year(itFAAssetBookNextPostingDate) * 12) + month(itFAAssetBookNextPostingDate)) to ((iiDepreciationYear * 12) + iiDepreciationPeriod):
            if viCounter = ((year(itFAAssetBookNextPostingDate) * 12) + month(itFAAssetBookNextPostingDate))
            then do:
                do viCounterStart = 1 to month(itFAAssetBookStartDate):
                    create tNewDepreciation.
                    assign tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - <M-7 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle)
                           vdNewDeprStartAmountLC = vdNewDeprStartAmountLC + tNewDepreciation.tdNewDeprAmountLC.
                end.
        
                empty temp-table tNewDepreciation.
            end.
            
            create tNewDepreciation.
            assign tNewDepreciation.tiNewDeprYear     = integer(truncate(viCounter / 12,0)) - (if viCounter mod 12 = 0 then 1 else 0)
                   tNewDepreciation.tiNewDeprMonth    = if viCounter mod 12 = 0 then 12 else viCounter mod 12
                   tNewDepreciation.tdNewDeprAmountLC = if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate))
                                                        then vdNewDeprStartAmountLC
                                                        else ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-1 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle).
            
            if tNewDepreciation.tdNewDeprAmountLC <= 0
            then return.                                                                     
        end.
    end.
    when {&BOOKCALCULATIONTYPE-TEMPORIS}
    then do viCounter = ((year(itFAAssetBookNextPostingDate) * 12) + month(itFAAssetBookNextPostingDate)) to ((iiDepreciationYear * 12) + iiDepreciationPeriod):
        create tNewDepreciation.
        assign tNewDepreciation.tiNewDeprYear     = integer(truncate(viCounter / 12,0)) - (if viCounter mod 12 = 0 then 1 else 0)
               tNewDepreciation.tiNewDeprMonth    = if viCounter mod 12 = 0 then 12 else viCounter mod 12
               tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-3 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle).
        
        if tNewDepreciation.tdNewDeprAmountLC <= 0
        then return.                                                                     
    end.
    when {&BOOKCALCULATIONTYPE-FULLYEARTEMPORIS} /* NextPostingDate to Set = the last date of the month of the starting date if the asset is not yet depreciated */
    then  do viCounter = ((year(itFAAssetBookNextPostingDate) * 12) + month(itFAAssetBookNextPostingDate)) to ((iiDepreciationYear * 12) + iiDepreciationPeriod):
        if viCounter = ((year(itFAAssetBookNextPostingDate) * 12) + month(itFAAssetBookNextPostingDate)) and
                         year(itFAAssetBookNextPostingDate) = year(itFAAssetBookStartDate)
        then do:
            do viCounterStart = 1 to 12:
                create tNewDepreciation.
                assign tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - <M-6 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle).
                       vdNewDeprStartAmountLC = vdNewDeprStartAmountLC + tNewDepreciation.tdNewDeprAmountLC.
            end.
        
            assign vdNewDeprStartAmountLC = vdNewDeprStartAmountLC / (12 - month(itFAAssetBookStartDate) + 1).
            
            empty temp-table tNewDepreciation.
        end.
        
        create tNewDepreciation.
        assign tNewDepreciation.tiNewDeprYear     = integer(truncate(viCounter / 12,0)) - (if viCounter mod 12 = 0 then 1 else 0)
               tNewDepreciation.tiNewDeprMonth    = if viCounter mod 12 = 0 then 12 else viCounter mod 12
               tNewDepreciation.tdNewDeprAmountLC = if tNewDepreciation.tiNewDeprYear = year(itFAAssetBookStartDate)
                                                    then vdNewDeprStartAmountLC
                                                    else ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-5 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle).
        
        if tNewDepreciation.tdNewDeprAmountLC <= 0
        then return.                                                                     
    end.
    when {&BOOKCALCULATIONTYPE-TEMPORISDAILY}
    then do:
        if iiFAAssetBookPeriodsDepreciated = 0
        then do viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate)) to ((iiDepreciationYear * 12) + iiDepreciationPeriod):
            create tNewDepreciation.
            assign tNewDepreciation.tiNewDeprYear     = integer(truncate(viCounter / 12,0)) - (if viCounter mod 12 = 0 then 1 else 0)
                   tNewDepreciation.tiNewDeprMonth    = if viCounter mod 12 = 0 then 12 else viCounter mod 12.
                   
            if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate))
            then assign tNewDepreciation.tdNewDeprAmountLC = (((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-8 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle) /
                                                             (<M-9 GetTotalDaysOfMonth (input  itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) * ((<M-10 GetTotalDaysOfMonth (input  itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) - day(itFAAssetBookStartDate) + 1)).
            else assign tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-11 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle).
        end.
        else if iiFAAssetBookPeriodsDepreciated <> 0
        then do viCounter = ((year(itFAAssetBookNextPostingDate) * 12) + month(itFAAssetBookNextPostingDate)) to ((iiDepreciationYear * 12) + iiDepreciationPeriod):
            create tNewDepreciation.
            assign tNewDepreciation.tiNewDeprYear     = integer(truncate(viCounter / 12,0)) - (if viCounter mod 12 = 0 then 1 else 0)
                   tNewDepreciation.tiNewDeprMonth    = if viCounter mod 12 = 0 then 12 else viCounter mod 12
                   tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-12 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) * idFactor / iiFAAssetBookLifeCycle).
                   
            if tNewDepreciation.tdNewDeprAmountLC <= 0
            then return.                                                                     
        end.    
    end.                                                
end.