Description
Due to long method code
Parameters
idRate | input | decimal | |
idScale | input | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bfixedassetdepreciation.p)
assign vdRate = idRate
vdScale = idScale.
if tFADepreciation.tcJournalCode = '':U or
tFADepreciation.tcJournalCode = ?
then do:
assign vcMessage = trim(substitute(#T-7'The daybook specified for asset book type &1 is invalid.':255(2027)T-7#, trim(tqFAAssetBookByDeprecInfo.tcFABookTypeCode)))
oiReturnStatus = -1.
<M-1 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-4030':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
return.
end.
if not can-do({&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U +
{&DEPRECIATIONTYPE-CZTAXACCELERATED}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then do:
if viPeriodPostingYear = ? and
viPeriodPostingPeriod = ?
then do:
assign vtDeprecPostingDate = date(if tFADepreciation.FADepreciationMonth = 12 then 1 else tFADepreciation.FADepreciationMonth + 1, 1, if tFADepreciation.FADepreciationMonth = 12 then tFADepreciation.FADepreciationYear + 1 else tFADepreciation.FADepreciationYear) - 1.
<Q-2 run PeriodByStartEndDate (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input vtDeprecPostingDate, (Date)
output dataset tqPeriodByStartEndDate) in BPeriod >
find first tqPeriodByStartEndDate where
tqPeriodByStartEndDate.ttPeriodStartDate <= vtDeprecPostingDate and
tqPeriodByStartEndDate.ttPeriodEndDate >= vtDeprecPostingDate
no-error.
if available tqPeriodByStartEndDate
then do:
assign vtPostingDate = tqPeriodByStartEndDate.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-77 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.
assign tFADepreciation.FADepreciationAmountCC = /*round(tFADepreciation.FADepreciationAmountLC * vdRate * vdScale, viCompanyCCDec).*/
<M-8 RoundAmount
(input tFADepreciation.FADepreciationAmountLC * vdRate * vdScale (idUnroundedAmount),
input viCompanyCCid (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in business>.
end.
assign tFAAssetBookForFADepreciations.FAAssetBookDeprAmountLC = tFAAssetBookForFADepreciations.FAAssetBookDeprAmountLC + tFADepreciation.FADepreciationAmountLC
tFAAssetBookForFADepreciations.FAAssetBookDeprAmountCC = tFAAssetBookForFADepreciations.FAAssetBookDeprAmountCC + tFADepreciation.FADepreciationAmountCC.
if tNewDepreciation.tdNewDeprAmountLC <> 0
then do:
/* Posting Detail - GL, CC, Project Info */
assign vlDetailCreated = false.
for each tqFAAssetGLByAssetId
by tqFAAssetGLByAssetId.tcFAAssetGLType:
if tqFAAssetGLByAssetId.tcFAAssetGLType <> {&ASSETGLTYPE-COSTDEPREC} and
tqFAAssetGLByAssetId.tcFAAssetGLType <> {&ASSETGLTYPE-CUMULDEPREC}
then next.
<M-4 run AddDetailLine (input 'FADepreciationDet':U (icTable),
input tFADepreciation.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
assign tFADepreciationDet.FADepreciationDetAmountLC = if tqFAAssetGLByAssetId.tcFAAssetGLType = {&ASSETGLTYPE-COSTDEPREC}
then tFADepreciationDet.FADepreciationDetAmountLC + tNewDepreciation.tdNewDeprAmountLC
else tFADepreciationDet.FADepreciationDetAmountLC - tNewDepreciation.tdNewDeprAmountLC
tFADepreciationDet.FADepreciationPostingDescr = tFADepreciation.FADepreciationDescription
tFADepreciationDet.FADepreciation_ID = tFADepreciation.FADepreciation_ID.
if can-do({&DEPRECIATIONTYPE-CZTAXSTRAIGHT} + ",":U +
{&DEPRECIATIONTYPE-CZTAXACCELERATED}, tqFAAssetBookByDeprecInfo.tcFAAssetBookDeprType)
then assign tFADepreciationDet.FADepreciationDetAmountCC = if tqFAAssetGLByAssetId.tcFAAssetGLType = {&ASSETGLTYPE-COSTDEPREC}
then tFADepreciationDet.FADepreciationDetAmountCC + tNewDepreciation.tdNewDeprAmountCC
else tFADepreciationDet.FADepreciationDetAmountCC - tNewDepreciation.tdNewDeprAmountCC.
else assign tFADepreciationDet.FADepreciationDetAmountCC = /*round(tFADepreciationDet.FADepreciationDetAmountLC * vdRate * vdScale, viCompanyCCDec).*/
<M-9 RoundAmount
(input tFADepreciationDet.FADepreciationDetAmountLC * vdRate * vdScale (idUnroundedAmount),
input viCompanyCCid (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in business>.
if tqFAAssetGLByAssetId.tiCostCentre_ID <> 0 and
tqFAAssetGLByAssetId.tiCostCentre_ID <> ?
then assign tFADepreciationDet.CostCentre_ID = tqFAAssetGLByAssetId.tiCostCentre_ID.
if tqFAAssetGLByAssetId.tcFAAssetGLType = {&ASSETGLTYPE-COSTDEPREC}
then assign tFADepreciationDet.CostGL_ID = tqFAAssetGLByAssetId.tiGL_ID.
if tqFAAssetGLByAssetId.tcFAAssetGLType = {&ASSETGLTYPE-CUMULDEPREC}
then assign tFADepreciationDet.CumulativeGL_ID = tqFAAssetGLByAssetId.tiGL_ID.
if tqFAAssetGLByAssetId.tiDivision_ID <> 0 and
tqFAAssetGLByAssetId.tiDivision_ID <> ?
then assign tFADepreciationDet.Division_ID = tqFAAssetGLByAssetId.tiDivision_ID.
if tqFAAssetGLByAssetId.tiProject_ID <> 0 and
tqFAAssetGLByAssetId.tiProject_ID <> ?
then assign tFADepreciationDet.Project_ID = tqFAAssetGLByAssetId.tiProject_ID.
/* Posting Detail - SAFs */
<Q-5 run FAAssetGLSafByAssetGLId (all) (Read) (NoCache)
(input tqFAAssetGLByAssetId.tiFAAssetGL_ID, (FAAssetGLId)
output dataset tqFAAssetGLSafByAssetGLId) in BFixedAssetAsset >
for each tqFAAssetGLSafByAssetGLId where
tqFAAssetGLSafByAssetGLId.tiFAAssetGL_ID = tqFAAssetGLByAssetId.tiFAAssetGL_ID:
<M-6 run AddDetailLine (input 'FADepreciationDetSaf':U (icTable),
input tFADepreciationDet.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BFixedAssetDepreciation>
assign tFADepreciationDetSaf.FADepreciationDetSafSeq = tqFAAssetGLSafByAssetGLId.tiFAAssetGLSafInputSeq
tFADepreciationDetSaf.FADepreciationDetSafType = tqFAAssetGLSafByAssetGLId.tcFAAssetGLSafParentType
tFADepreciationDetSaf.SafStructure_ID = tqFAAssetGLSafByAssetGLId.tiSafStructure_ID
tFADepreciationDetSaf.Saf_ID = tqFAAssetGLSafByAssetGLId.tiSaf_ID.
end.
end.
end.