Description
Execute Depreciations for the Type '1.5 Yearly Declining Balances / Switch to Straight Line' (YD15SL), '2.0 Yearly Declining Balances / Switch to Straight Line' (YD20SL), '2.5 Yearly Declining Balances / Switch to Straight Line' (YD25SL)
Parameters
iiFAAssetBookId | input | integer | |
icFAAssetBookCalculationType | input | character | |
iiFAAssetBookLifeCycle | input | integer | |
iiFAAssetBookPeriodsDepreciated | input | integer | |
itFAAssetBookStartDate | input | date | |
itFAAssetBookNextPostingDate | input | date | |
iiDepreciationYear | input | integer | |
iiDepreciationPeriod | input | integer | |
idFAAssetBookCapitalAmountLC | input | decimal | |
idFAAssetBookDeprecAmountLC | input | decimal | |
idFAAssetBookSalvageAmountLC | input | decimal | |
idFAAssetBookDisposalAmountLC | input | decimal | |
idFAAssetBookDisposalDepAmountLC | input | decimal | |
idFactor | input | decimal | |
tNewDepreciation | output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bfixedassetdepreciation.p)
empty temp-table tNewDepreciation.
<M-1 run DepreciationTypeSL1 (input icFAAssetBookCalculationType (icFAAssetBookCalculationType),
input iiFAAssetBookLifeCycle (iiFAAssetBookLifeCycle),
input iiFAAssetBookPeriodsDepreciated (iiFAAssetBookPeriodsDepreciated),
input itFAAssetBookStartDate (itFAAssetBookStartDate),
input itFAAssetBookNextPostingDate (itFAAssetBookNextPostingDate),
input iiDepreciationYear (iiDepreciationYear),
input iiDepreciationPeriod (iiDepreciationPeriod),
input idFAAssetBookCapitalAmountLC (idFAAssetBookCapitalAmountLC),
input idFAAssetBookDeprecAmountLC (idFAAssetBookDeprecAmountLC),
input idFAAssetBookSalvageAmountLC (idFAAssetBookSalvageAmountLC),
input idFAAssetBookDisposalAmountLC (idFAAssetBookDisposalAmountLC),
input idFAAssetBookDisposalDepAmountLC (idFAAssetBookDisposalDepAmountLC),
output vdNewDeprSL1AmountLC (odNewDeprAmountSL1LC),
output vdNewDeprSL1StartAmountLC (odNewDeprAmountSL1StartLC),
output tNewDepreciation (tNewDepreciation),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
assign oiReturnStatus = if (oiReturnStatus > 0 and
viFcReturnSuper = 0) or
oiReturnStatus < 0
then oiReturnStatus
else viFcReturnSuper.
find first tNewDepreciation no-error.
if oiReturnStatus < 0 or
not available tNewDepreciation
then return.
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 = maximum((((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC) * idFactor / iiFAAssetBookLifeCycle)), if viCounterStart = 1 then vdNewDeprSL1StartAmountLC else vdNewDeprSL1AmountLC)
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 maximum(vdNewDeprStartAmountLC, vdNewDeprSL1StartAmountLC * month(itFAAssetBookStartDate))
else maximum(((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC -
(<M-5 GetCumulDeprAmountEndPrevYearLC (input iiFAAssetBookId (iiFAAssetBookId),
input tNewDepreciation.tiNewDeprYear - 1 (iiPrevYear),
input idFAAssetBookDeprecAmountLC (idFAAssetBookDeprecAmountLC),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>))
* idFactor / iiFAAssetBookLifeCycle), vdNewDeprSL1AmountLC).
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 = if tNewDepreciation.tiNewDeprYear = year(itFAAssetBookStartDate)
then maximum((((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC) * idFactor / iiFAAssetBookLifeCycle)), if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate)) then vdNewDeprSL1StartAmountLC else vdNewDeprSL1AmountLC)
else maximum(((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC -
(<M-4 GetCumulDeprAmountEndPrevYearLC (input iiFAAssetBookId (iiFAAssetBookId),
input tNewDepreciation.tiNewDeprYear - 1 (iiPrevYear),
input idFAAssetBookDeprecAmountLC (idFAAssetBookDeprecAmountLC),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>))
* idFactor / iiFAAssetBookLifeCycle), if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate)) then vdNewDeprSL1StartAmountLC else vdNewDeprSL1AmountLC).
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 = maximum((((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC) * idFactor / iiFAAssetBookLifeCycle)), if viCounterStart = 1 then vdNewDeprSL1StartAmountLC else vdNewDeprSL1AmountLC)
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 maximum(((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC -
(<M-3 GetCumulDeprAmountEndPrevYearLC (input iiFAAssetBookId (iiFAAssetBookId),
input tNewDepreciation.tiNewDeprYear - 1 (iiPrevYear),
input idFAAssetBookDeprecAmountLC (idFAAssetBookDeprecAmountLC),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>))
* idFactor / iiFAAssetBookLifeCycle), vdNewDeprSL1AmountLC).
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 = maximum((((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC) * idFactor / iiFAAssetBookLifeCycle) /
(<M-6 GetTotalDaysOfMonth (input itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) * ((<M-7 GetTotalDaysOfMonth (input itFAAssetBookStartDate (itDate)) in BFixedAssetDepreciation>) - day(itFAAssetBookStartDate) + 1)), if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate)) then vdNewDeprSL1StartAmountLC else vdNewDeprSL1AmountLC).
else assign tNewDepreciation.tdNewDeprAmountLC = maximum(((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC -
(<M-8 GetCumulDeprAmountEndPrevYearLC (input iiFAAssetBookId (iiFAAssetBookId),
input tNewDepreciation.tiNewDeprYear - 1 (iiPrevYear),
input idFAAssetBookDeprecAmountLC (idFAAssetBookDeprecAmountLC),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>))
* idFactor / iiFAAssetBookLifeCycle), if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate)) then vdNewDeprSL1StartAmountLC else vdNewDeprSL1AmountLC).
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 = maximum(((idFAAssetBookCapitalAmountLC - idFAAssetBookDisposalAmountLC + idFAAssetBookDisposalDepAmountLC -
(<M-9 GetCumulDeprAmountEndPrevYearLC (input iiFAAssetBookId (iiFAAssetBookId),
input tNewDepreciation.tiNewDeprYear - 1 (iiPrevYear),
input idFAAssetBookDeprecAmountLC (idFAAssetBookDeprecAmountLC),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>))
* idFactor / iiFAAssetBookLifeCycle), if viCounter = ((year(itFAAssetBookStartDate) * 12) + month(itFAAssetBookStartDate)) then vdNewDeprSL1StartAmountLC else vdNewDeprSL1AmountLC).
if tNewDepreciation.tdNewDeprAmountLC <= 0
then return.
end.
end.
end.