project QadFinancials > class BFixedAssetDepreciation > method DepreciationTypeSL1

Description

Execute Depreciations for the Type 'Straight Line' (SL1)


Parameters


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


Internal usage


QadFinancials
method BFixedAssetDepreciation.DepreciationTypeDBSL
method BFixedAssetDepreciation.DepreciationTypes
method BFixedAssetDepreciation.DepreciationTypeYDSL


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 - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - <M-5 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / (iiFAAssetBookLifeCycle - viCounterStart + 1))
                           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 - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-6 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / (iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated))
                   odNewDeprAmountSL1LC               = tNewDepreciation.tdNewDeprAmountLC
                   odNewDeprAmountSL1StartLC          = tNewDepreciation.tdNewDeprAmountLC.

            if tNewDepreciation.tdNewDeprAmountLC <= 0
            then return.   
            
            assign iiFAAssetBookPeriodsDepreciated = iiFAAssetBookPeriodsDepreciated + 
                                                       (if iiFAAssetBookPeriodsDepreciated = 0 and
                                                           tNewDepreciation.tiNewDeprYear = year(itFAAssetBookStartDate) and
                                                           tNewDepreciation.tiNewDeprMonth = month(itFAAssetBookStartDate)
                                                        then tNewDepreciation.tiNewDeprMonth
                                                        else 1).
        end.
    end.
    when {&BOOKCALCULATIONTYPE-TEMPORIS} /* 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):
        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 - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-7 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / (iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated)).
               
        assign odNewDeprAmountSL1StartLC = tNewDepreciation.tdNewDeprAmountLC
               odNewDeprAmountSL1LC      = tNewDepreciation.tdNewDeprAmountLC.
               
        if tNewDepreciation.tdNewDeprAmountLC <= 0
        then return.    
        
        assign iiFAAssetBookPeriodsDepreciated = iiFAAssetBookPeriodsDepreciated + 1.                                                                 
    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):
        
        assign odNewDeprAmountSL1LC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC) / iiFAAssetBookLifeCycle).
               
        if integer(truncate(viCounter / 12,0)) - (if viCounter mod 12 = 0 then 1 else 0) = year(itFAAssetBookStartDate) and
           viCounter = ((year(itFAAssetBookNextPostingDate) * 12) + month(itFAAssetBookNextPostingDate))
        then assign odNewDeprAmountSL1StartLC = ((odNewDeprAmountSL1LC * 12) - idFAAssetBookDeprecAmountLC) /
                                                (12 - month(itFAAssetBookNextPostingDate) + 1).

        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 odNewDeprAmountSL1StartLC
                                                    else odNewDeprAmountSL1LC.

        if tNewDepreciation.tiNewDeprYear <> year(itFAAssetBookStartDate) 
        then assign odNewDeprAmountSL1StartLC = odNewDeprAmountSL1LC.           
    
        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 - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-8 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / (iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated)) /
                                                             (<M-2 GetTotalDaysOfMonth (input  itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) * ((<M-3 GetTotalDaysOfMonth (input  itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) - day(itFAAssetBookStartDate) + 1))
                        odNewDeprAmountSL1StartLC          = tNewDepreciation.tdNewDeprAmountLC.
            else assign tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-9 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / (iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated))
                        odNewDeprAmountSL1LC               = tNewDepreciation.tdNewDeprAmountLC.
            
            if tNewDepreciation.tdNewDeprAmountLC <= 0
            then return.  
            
            assign iiFAAssetBookPeriodsDepreciated = iiFAAssetBookPeriodsDepreciated + 1.                                                                   
        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 - idFAAssetBookSalvageAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-10 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / (iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated)).
                   
            if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate))
            then assign odNewDeprAmountSL1StartLC = tNewDepreciation.tdNewDeprAmountLC.
            else assign odNewDeprAmountSL1LC      = tNewDepreciation.tdNewDeprAmountLC.
                   
            if tNewDepreciation.tdNewDeprAmountLC <= 0
            then return.                                                                     
            
            assign iiFAAssetBookPeriodsDepreciated = iiFAAssetBookPeriodsDepreciated + 1.
        end.    
    end.                                                
end.