Description
After Validation of the Parameters this method executes the Depreciations
Parameters
icFABookTypeCode | input | character | |
iiFADepreciationYear | input | integer | |
iiFADepreciationPeriod | input | integer | |
icFAAssetTypeCode | input | character | |
icFAAssetCode | input | character | |
iiPeriodYear | input | integer | |
iiPeriodPeriod | input | integer | |
icPostingText | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bfixedassetdepreciation.p)
assign vlStart1 = false
vlStart2 = false
vlStart3 = false
viPeriodPostingYear = iiPeriodYear
viPeriodPostingPeriod = iiPeriodPeriod
vcText = icPostingText.
/* Set the Depreciation Date Based on Depreciation Year, Depreciation Period */
assign vtDepreciationDate = <M-83 CalcLastDate (input iiFADepreciationYear (iiYear),
input iiFADepreciationPeriod (iiMonth),
input 0 (iiMonthPos)) in BFixedAssetDepreciation>
vtNextPostingDate = <M-86 CalcLastDate (input iiFADepreciationYear (iiYear),
input iiFADepreciationPeriod (iiMonth),
input 1 (iiMonthPos)) in BFixedAssetDepreciation>.
/* If the PostingPeriod was passed from UI, get the posting date for the cc calculation */
if viPeriodPostingYear <> ? and
viPeriodPostingPeriod <> ?
then do:
<Q-56 run PeriodByYearPeriod (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input viPeriodPostingYear, (PeriodYear)
input viPeriodPostingPeriod, (PeriodPeriod)
input ?, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod >
find first tqPeriodByYearPeriod where
tqPeriodByYearPeriod.tiPeriodYear = viPeriodPostingYear and
tqPeriodByYearPeriod.tiPeriodPeriod = viPeriodPostingPeriod
no-error.
if available tqPeriodByYearPeriod
then do:
assign vtPostingDate = tqPeriodByYearPeriod.ttPeriodEndDate.
/*Get Exchange rate between LC and CC for the selected posting date, relevant only if CC is specified*/
assign vdRate = ?
vdScale = ?.
if viCompanyCCId > 0
then do:
<M-748 run GetExchangeRate
(input ? (iiCompanyID),
input viCompanyLCId (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode),
input vtPostingDate (itValidityDate),
output vdRate (odExchangeRate),
output vdScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
end.
end.
end.
/* Retrieve the Asset Book records for making of the transactions */
<Q-1 run FAAssetBookByDeprecInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input icFABookTypeCode, (FAAssetBookType)
input icFAAssetTypeCode, (FAAssetType)
input icFAAssetCode, (FAAssetCode)
input false, (FAAssetBookIsDisposed)
input true, (FAAssetBookIsWithDepr)
input vtDepreciationDate, (DepreciationDate)
output dataset tqFAAssetBookByDeprecInfo) in BFixedAssetAsset >
FOREACHFAASSETBOOKBLOCK:
for each tqFAAssetBookByDeprecInfo
break by tqFAAssetBookByDeprecInfo.tiFAAsset_ID
by int(string(tqFAAssetBookByDeprecInfo.tlFABookTypeIsOfficial,"1/0":U)) descending:
if (tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate = ?)
then do:
assign vcMessage = substitute(#T-62'No start date was specified for asset code '&1' and book code '&2'.':200(15510)T-62#,
trim(tqFAAssetBookByDeprecInfo.tcFAAssetCode),
trim(tqFAAssetBookByDeprecInfo.tcFAAssetBookCode) )
oiReturnStatus = 1.
<M-63 run SetMessage (input trim(vcMessage) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-3684':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
next.
end.
if tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate > vtDepreciationDate
then next.
/* Next Posting Date */
if can-do({&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U + {&DEPRECIATIONTYPE-CZTAXACCELERATED},
tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then do:
assign viNextPeriodYear = if tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate = ?
then year(tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate)
else year(tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate).
assign tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate = <M-88 CalcLastDateOfAccYear (input viNextPeriodYear (iiAccYear),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>.
end.
else if tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate = ?
then assign tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate = <M-85 CalcLastDate (input year(tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate) (iiYear),
input month(tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate) (iiMonth),
input 0 (iiMonthPos)) in BFixedAssetDepreciation>.
if tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate = ?
then do:
assign vcMessage = substitute(#T-70'The system is unable to set the next posting date for asset code &1 and book code &2.':200(16567)T-70#,
trim(tqFAAssetBookByDeprecInfo.tcFAAssetCode),
trim(tqFAAssetBookByDeprecInfo.tcFAAssetBookCode) ) + #T-74'Verify if the GL periods are correctly defined.':200(17306)T-74#
oiReturnStatus = 1.
<M-69 run SetMessage (input trim(vcMessage) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-4033':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
next.
end.
/* Special for CZTAX where correction takes place at the time of run of the depreciations */
if tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate > vtDepreciationDate
then next.
<M-31 run DepreciationTypes (input tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType (icFAAssetBookDepreciationType),
input tqFAAssetBookByDeprecInfo.tcFAAssetBookCalculationType (icFAAssetBookCalculationType),
input tqFAAssetBookByDeprecInfo.tiFAAssetBookLifeCycle (iiFAAssetBookLifeCycle),
input tqFAAssetBookByDeprecInfo.tiFAAssetBookPeriodsDepr (iiFAAssetBookPeriodsDepr),
input tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate (itFAAssetBookStartDate),
input tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate (itFAAssetBookNextPostingDate),
input iiFADepreciationYear (iiFADepreciationYear),
input iiFADepreciationPeriod (iiFADepreciationPeriod),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC (idFAAssetBookAmountLC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountLC (idFAAssetBookDeprAmountLC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC (idFAAssetBookSalvageAmountLC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC (idFAAssetBookDisposalAmountLC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC (idFAAssetBookDisposalDepAmountLC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountCC (idFAAssetBookAmountCC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountCC (idFAAssetBookDeprAmountCC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountCC (idFAAssetBookSalvageAmountCC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedCC (idFAAssetBookDisposalAmountCC),
input tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprCC (idFAAssetBookDisposalDepAmountCC),
input tqFAAssetBookByDeprecInfo.tiFAAssetBook_ID (iiFAAssetBookId),
output tNewDepreciation (tNewDepreciation),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
if viFcReturnSuper <> 0 and oiReturnStatus >= 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
/* AND Now prepare the Fixed Asset SubLedger Records */
if not vlStart1
then do:
<Q-39 run FAAssetGLByAssetId (Start) in BFixedAssetAsset >
assign vlStart1 = true.
end.
if not vlStart2
then do:
<Q-40 run FAAssetGLSafByAssetGLId (Start) in BFixedAssetAsset >
<Q-49 run FAAssetBookByAssetOfficial (Start) in BFixedAssetAsset >
assign vlStart2 = true.
end.
if not vlStart3
then do:
<Q-36 run PeriodByStartEndDate (Start) in BPeriod >
assign vlStart3 = true.
end.
if first-of(tqFAAssetBookByDeprecInfo.tiFAAsset_ID)
then do:
<Q-41 run FAAssetGLByAssetId (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tqFAAssetBookByDeprecInfo.tiFAAsset_ID, (FAAssetID)
input ?, (FAAssetCode)
output dataset tqFAAssetGLByAssetId) in BFixedAssetAsset >
assign viFAAssetBookOfficialId = ?
vtFAAssetBookStartDate = ?.
<Q-48 run FAAssetBookByAssetOfficial (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input true, (FABookTypeIsOfficial)
input tqFAAssetBookByDeprecInfo.tiFAAsset_ID, (FAAssetId)
output dataset tqFAAssetBookByAssetOfficial) in BFixedAssetAsset >
find first tqFAAssetBookByAssetOfficial no-error.
if available tqFAAssetBookByAssetOfficial
then assign viFAAssetBookOfficialId = tqFAAssetBookByAssetOfficial.tiFAAssetBook_ID
vtFAAssetBookStartDate = tqFAAssetBookByAssetOfficial.ttFAAssetBookStartDate.
end.
find first tqFAAssetGLByAssetId where
tqFAAssetGLByAssetId.tiFAAsset_ID = tqFAAssetBookByDeprecInfo.tiFAAsset_ID no-error.
if not available tqFAAssetGLByAssetId
then do:
assign vcMessage = trim(substitute(#T-43'The depreciation GL(s) for asset '&1' is not defined in the system or is invalid.':255(13673)T-43#, trim(tqFAAssetBookByDeprecInfo.tcFAAssetCode)))
oiReturnStatus = -1.
<M-42 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-3033':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
leave FOREACHFAASSETBOOKBLOCK.
end.
find first tNewDepreciation where
tNewDepreciation.tdNewDeprAmountLC > 0 no-error.
if not available tNewDepreciation
then next.
find tFAAssetBookForFADepreciations where
tFAAssetBookForFADepreciations.FAAssetBook_ID = tqFAAssetBookByDeprecInfo.tiFAAssetBook_ID no-error.
if not available tFAAssetBookForFADepreciations
then do:
create tFAAssetBookForFADepreciations.
assign viFAAssetBookId = viFAAssetBookId - 1
tFAAssetBookForFADepreciations.tc_Rowid = string(viFAAssetBookId)
tFAAssetBookForFADepreciations.FAAssetBook_ID = tqFAAssetBookByDeprecInfo.tiFAAssetBook_ID
tFAAssetBookForFADepreciations.FAAsset_ID = tqFAAssetBookByDeprecInfo.tiFAAsset_ID
tFAAssetBookForFADepreciations.FAAssetBookCode = tqFAAssetBookByDeprecInfo.tcFAAssetBookCode
tFAAssetBookForFADepreciations.FAAssetBookSeq = tqFAAssetBookByDeprecInfo.tiFAAssetBookSeq.
end.
/* Let's Create the records into the Class temp-tables */
assign vdCumulatedDeprecLC = 0
vdCumulatedDeprecCC = 0.
for each tNewDepreciation:
if tNewDepreciation.tdNewDeprAmountLC < 0
then leave.
if tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountLC -
vdCumulatedDeprecLC <= 0
then leave.
/* Check if we can make non-official depreciations for the depreciation period */
/* When calculation type is FULL-YEAR or FULL-YEAR-PRORATA-TEMPORIS, the first depreciation is per 1st till start-date periods */
assign tFAAssetBookForFADepreciations.FAAssetBookPeriodsDepr = tFAAssetBookForFADepreciations.FAAssetBookPeriodsDepr +
(if tqFAAssetBookByDeprecInfo.tiFAAssetBookPeriodsDepr = 0 and
can-do({&BOOKCALCULATIONTYPE-FULLYEAR} + ",":U +
{&BOOKCALCULATIONTYPE-FULLYEARTEMPORIS}, tqFAAssetBookByDeprecInfo.tcFAAssetBookCalculationType) and
tNewDepreciation.tiNewDeprYear = year(tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate) and
tNewDepreciation.tiNewDeprMonth = month(tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate)
then tNewDepreciation.tiNewDeprMonth
else 1).
/* Do we have still anything to depreciate? or is the LifeCycle reached? */
/* For the 'Declining Balances' the open amount will remain when reached the lifecycle */
/* For the 'UserDefined' no check at all */
if not can-do({&DEPRECIATIONTYPE-ACT1} + ",":U +
{&DEPRECIATIONTYPE-USER1}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then if (not can-do({&DEPRECIATIONTYPE-DB15} + ",":U + {&DEPRECIATIONTYPE-DB20} + ",":U +
{&DEPRECIATIONTYPE-DB25} + ",":U + {&DEPRECIATIONTYPE-DB15SL} + ",":U +
{&DEPRECIATIONTYPE-DB20SL} + ",":U + {&DEPRECIATIONTYPE-DB25SL} + ",":U +
{&DEPRECIATIONTYPE-YD15SL} + ",":U + {&DEPRECIATIONTYPE-YD20SL} + ",":U +
{&DEPRECIATIONTYPE-YD25SL} + ",":U + {&DEPRECIATIONTYPE-SL1ZERO} + ",":U +
{&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U +
{&DEPRECIATIONTYPE-CZTAXACCELERATED}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType) and
tqFAAssetBookByDeprecInfo.tiFAAssetBookPeriodsDepr + tFAAssetBookForFADepreciations.FAAssetBookPeriodsDepr >= tqFAAssetBookByDeprecInfo.tiFAAssetBookLifeCycle) or
(tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountLC -
vdCumulatedDeprecLC -
tNewDepreciation.tdNewDeprAmountLC < 0)
then assign tNewDepreciation.tdNewDeprAmountLC = tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountLC -
vdCumulatedDeprecLC
tNewDepreciation.tdNewDeprAmountCC = tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountCC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountCC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprCC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedCC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountCC -
vdCumulatedDeprecCC.
/* create depreciation header (tfadepreciation) with link to tqFAAssetBookByDeprecInfo */
<M-14 run AddDetailLine (input 'FADepreciation':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
assign tNewDepreciation.tdNewDeprAmountLC = /*round(tNewDepreciation.tdNewDeprAmountLC, viCompanyLCDec)*/
<M-91 RoundAmount
(input tNewDepreciation.tdNewDeprAmountLC (idUnroundedAmount),
input viCompanyLCid (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>
tFADepreciation.FADepreciationAmountLC = tFADepreciation.FADepreciationAmountLC + tNewDepreciation.tdNewDeprAmountLC
tFADepreciation.FADepreciationDate = vtDepreciationDate
tFADepreciation.FADepreciationDescription = tqFAAssetBookByDeprecInfo.tcFAAssetCode + ' ':U +
tqFAAssetBookByDeprecInfo.tcFAAssetBookCode + ' ':U +
string(tNewDepreciation.tiNewDeprYear) +
/*add month only if it is in interval from 1 to 12*/
if tNewDepreciation.tiNewDeprMonth >= 1 and tNewDepreciation.tiNewDeprMonth <= 12
then '/':U + string(tNewDepreciation.tiNewDeprMonth)
else '':U
tFADepreciation.FADepreciationMonth = tNewDepreciation.tiNewDeprMonth
tFADepreciation.FADepreciationYear = tNewDepreciation.tiNewDeprYear
tFADepreciation.FAAssetBook_ID = tqFAAssetBookByDeprecInfo.tiFAAssetBook_ID
tFADepreciation.tcJournalCode = tqFAAssetBookByDeprecInfo.tcJournalCode
vdCumulatedDeprecLC = vdCumulatedDeprecLC + tNewDepreciation.tdNewDeprAmountLC.
if can-do({&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U +
{&DEPRECIATIONTYPE-CZTAXACCELERATED}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then assign tNewDepreciation.tdNewDeprAmountCC = /*round(tNewDepreciation.tdNewDeprAmountCC, viCompanyCCDec)*/
<M-92 RoundAmount
(input tNewDepreciation.tdNewDeprAmountCC (idUnroundedAmount),
input viCompanyLCid (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>
tFADepreciation.FADepreciationAmountCC = tFADepreciation.FADepreciationAmountCC + tNewDepreciation.tdNewDeprAmountCC
vdCumulatedDeprecCC = vdCumulatedDeprecCC + tNewDepreciation.tdNewDeprAmountCC.
<M-64 run DepreciationMainSub (input vdRate (idRate),
input vdScale (idScale),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
/* If there still remains something to depreciate on the investment, let's set the next posting date, else leave the last previous posting date */
/* For CZ Tax methods */
assign vtNextPostingDateCZTax = ?.
if can-do({&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U + {&DEPRECIATIONTYPE-CZTAXACCELERATED},
tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then do:
/*Depreciation date*/
assign vtDepreciationDate = <M-89 CalcLastDateOfAccYear (input tNewDepreciation.tiNewDeprYear (iiAccYear),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>.
/*Next posting date, year + 1*/
assign vtNextPostingDateCZTax = <M-90 CalcLastDateOfAccYear (input tNewDepreciation.tiNewDeprYear + 1 (iiAccYear),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>.
if vtNextPostingDateCZTax = ? and
(tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC -
vdCumulatedDeprecLC <> 0)
then do:
assign vcMessage = substitute(#T-78'The system is unable to set the next posting date for asset code &1 and book code &2.':200(16567)T-78#,
trim(tqFAAssetBookByDeprecInfo.tcFAAssetCode),
trim(tqFAAssetBookByDeprecInfo.tcFAAssetBookCode) ) + #T-79'Verify if the GL periods are correctly defined.':200(17306)T-79#
oiReturnStatus = -1.
<M-77 run SetMessage (input trim(vcMessage) (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-4322':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
return.
end.
assign tFAAssetBookForFADepreciations.FAAssetBookNextPostingDate = vtNextPostingDateCZTax
tFADepreciation.FADepreciationDate = vtDepreciationDate.
end.
if can-do({&DEPRECIATIONTYPE-ACT1} + ",":U + {&DEPRECIATIONTYPE-USER1},
tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then do:
if tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountLC -
vdCumulatedDeprecLC <= 0
then leave.
end.
else if not can-do({&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U +
{&DEPRECIATIONTYPE-CZTAXACCELERATED} + ",":U +
{&DEPRECIATIONTYPE-SL1ZERO}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType) and
tqFAAssetBookByDeprecInfo.tiFAAssetBookPeriodsDepr + tFAAssetBookForFADepreciations.FAAssetBookPeriodsDepr >= tqFAAssetBookByDeprecInfo.tiFAAssetBookLifeCycle
then leave.
end.
/* If there still remains something to depreciate on the investment, let's set the next posting date, else leave the last previous posting date */
if not can-do({&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U +
{&DEPRECIATIONTYPE-CZTAXACCELERATED}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then assign tFAAssetBookForFADepreciations.FAAssetBookNextPostingDate = if tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC -
vdCumulatedDeprecLC <> 0
then vtNextPostingDate
else ?.
/* Special Cases to set NextPostingDate - methods,calculation types, totaldepreciated amount switch */
if (tqFAAssetBookByDeprecInfo.tdFAAssetBookAmountLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookSalvageAmountLC +
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedDeprLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDisposedLC -
tqFAAssetBookByDeprecInfo.tdFAAssetBookDeprAmountLC -
vdCumulatedDeprecLC <> 0) and
((tqFAAssetBookByDeprecInfo.tcFAAssetBookCalculationType = {&BOOKCALCULATIONTYPE-TEMPORIS} and
can-do({&DEPRECIATIONTYPE-SL1} + ",":U +
{&DEPRECIATIONTYPE-SUM}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)) or
(tqFAAssetBookByDeprecInfo.tcFAAssetBookCalculationType = {&BOOKCALCULATIONTYPE-FULLYEARTEMPORIS} and
can-do({&DEPRECIATIONTYPE-SL1} + ",":U +
{&DEPRECIATIONTYPE-DB15} + ",":U +
{&DEPRECIATIONTYPE-DB20} + ",":U +
{&DEPRECIATIONTYPE-DB25} + ",":U +
{&DEPRECIATIONTYPE-DB15SL} + ",":U +
{&DEPRECIATIONTYPE-DB20SL} + ",":U +
{&DEPRECIATIONTYPE-DB25SL} + ",":U +
{&DEPRECIATIONTYPE-SUM} + ",":U +
{&DEPRECIATIONTYPE-YD15SL} + ",":U +
{&DEPRECIATIONTYPE-YD20SL} + ",":U +
{&DEPRECIATIONTYPE-YD25SL}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)))
then assign tqFAAssetBookByDeprecInfo.ttFAAssetBookNextPostingDate = <M-87 CalcLastDate (input year(tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate) (iiYear),
input month(tqFAAssetBookByDeprecInfo.ttFAAssetBookStartDate) (iiMonth),
input 1 (iiMonthPos)) in BFixedAssetDepreciation>.
end. /* FOREACHFAASSETBOOKBLOCK */
find first tFADepreciation no-error.
if available tFADepreciation
then do:
<M-52 run ConvertIdToCode (output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
assign oiReturnStatus = if (oiReturnStatus > 0 and
viFcReturnSuper = 0) or
oiReturnStatus < 0
then oiReturnStatus
else viFcReturnSuper.
end.
/* Stop the different queries */
if vlStart1
then do:
<Q-45 run FAAssetGLByAssetId (Stop) in BFixedAssetAsset >
end.
if vlStart2
then do:
<Q-46 run FAAssetGLSafByAssetGLId (Stop) in BFixedAssetAsset >
<Q-50 run FAAssetBookByAssetOfficial (Stop) in BFixedAssetAsset >
end.
if vlStart3
then do:
<Q-35 run PeriodByStartEndDate (Stop) in BPeriod >
end.