project QadFinancials > class BFixedAssetDepreciation > method DepreciationTypeDBRemainingPer

Description

Execute Depreciations for the Type 'Declining Balances from Remaining Periods' (DBREMAININGPER)


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-1 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / max(iiFAAssetBookLifeCycle - viCounterStart + 1, 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 - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-2 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / max(iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated, 1)).
            
            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}
    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>) / max(iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated, 1)).
        
        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):
        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-4 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / max(iiFAAssetBookLifeCycle - viCounterStart + 1, 1)).
                       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>) / max(iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated, 1)).
        
        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.
    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-6 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / max(iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated, 1)) /
                                                             (<M-7 GetTotalDaysOfMonth (input  itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) * ((<M-8 GetTotalDaysOfMonth (input  itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) - day(itFAAssetBookStartDate) + 1)).
            else assign tNewDepreciation.tdNewDeprAmountLC = ((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-9 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / max(iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated, 1)).
            
            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 - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC - idFAAssetBookDeprecAmountLC - <M-10 GetCumulDeprAmountLC () in BFixedAssetDepreciation>) / max(iiFAAssetBookLifeCycle - iiFAAssetBookPeriodsDepreciated, 1)).
                   
            if tNewDepreciation.tdNewDeprAmountLC <= 0
            then return.

            assign iiFAAssetBookPeriodsDepreciated = iiFAAssetBookPeriodsDepreciated + 1.
        end.    
    end.                                                
end.