icFAAssetBookDepreciationType | input | character | |
iiFAAssetBookId | 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 | |
idFAAssetBookCapitalAmountCC | input | decimal | |
idFAAssetBookDeprecAmountCC | input | decimal | |
idFAAssetBookSalvageAmountCC | input | decimal | |
idFAAssetBookDisposalAmountCC | input | decimal | |
idFAAssetBookDisposalDepAmountCC | input | decimal | |
tNewDepreciation | output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
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.