Description
Calculates amortization.
Formula
SET CREATENONMISSINGBLK ON;
VAR periodOffset = 0;
VAR amortMethod = 0;
VAR numAmortPeriods = 0;
VAR priorAccumAmort = 0;
VAR basicCost = 0;
VAR salvageVal = 0;
VAR amortAmt = 0;
VAR retirementCosts = 0;
VAR retirementObs = 0;
VAR impairmentDate1 = 0;
VAR impairmentDate2 = 0;
VAR impairmentFairVal1 = 0;
VAR impairmentFairVal2 = 0;
VAR inServiceDate = 0;
VAR delayedStartDate = 0;
VAR prematureEndDate = 0;
VAR maintenanceCost = 0;
VAR insuranceCost = 0;
VAR cashOutflowDate = 0;
VAR fundingDate = 0;
VAR purchaseDate = 0;
VAR cashFlowIncidence = 0;
VAR fundingIncidence = 0;
VAR cashStaggeredPers = 1;
VAR fundingStaggeredPers = 1;
VAR cashAllocPct = 1;
VAR fundingAllocPct = 1;
VAR fundingAmt = 0;
VAR setCashImpact = 0;
VAR setFundingImpact = 0;
VAR capitalizePct = 0;
VAR impairmentOpt = 1;
VAR numRemainingPers;
VAR intangibleNet;
VAR netValue;
VAR saleValue;
VAR yearVal;
VAR monthVal;
VAR paramsSet = 0;
VAR cashflowChanged = 0;
VAR fundingChanged = 0;
VAR preExistingPers = 0;
VAR setStartAmort = 0;
FIX([Hidden_Scenario], [Hidden_Version], [Department], [AssetClassInt])
FIX ("BegBalance", "No Year")
"Basic Cost" (
IF ("Asset Status" > 0)
IF ("In Service Date" < "Purchase Date")
"In Service Date" = "Purchase Date";
ENDIF
"Basic Cost" = "Acquisition Costs" + "Additional Charges";
"Useful Life (in Years)" = "No Scenario"->"No Version"->"No Entity"->"Global"->"Useful Life (in Years)";
"Salvage" = "Salvage Input" * "Asset Units";
ENDIF
)
ENDFIX
FIX (@LEVMBRS("Period", 0) @LEVMBRS("Year", 0))
"Amortization"(
/* Only calc valid asset line items */
IF ("No Year"->"BegBalance"->"Asset Status" >= 0)
IF (@ISMBR("BegBalance") AND paramsSet == 0)
/* Initialized all the variables required to calculate depreciation */
paramsSet = 1;
/* eliminate days from date */
delayedStartDate = @INT("No Year"->"Delayed Start Date" / 100) * 100;
prematureEndDate = @INT("No Year"->"Premature End Date" / 100) * 100;
purchaseDate = @INT("No Year"->"Purchase Date" / 100) * 100;
inServiceDate = @INT("No Year"->"In Service Date" / 100) * 100;
cashOutflowDate = purchaseDate;
fundingDate = purchaseDate;
cashFlowIncidence = "No Year"->"No Scenario"->"No Version"->"No Entity"->"Global"->"Cash Flow Incidence";
IF (cashFlowIncidence <> "No Year"->"Cash Flow Incidence")
cashflowChanged = 1;
ELSE
cashflowChanged = 0;
ENDIF
IF (cashFlowIncidence == -1 AND cashflowChanged == 1)
cashStaggeredPers = 4;
ELSE
/* Extract year and month from date to adjust based in incidence values in global assumptions */
yearVal = @INT(cashOutflowDate / 10000) * 10000;
monthVal = cashOutflowDate - yearVal;
monthVal = monthVal + cashFlowIncidence;
IF (monthVal <= 0)
yearVal = yearVal - 10000;
monthVal = 1200 + monthVal;
ELSEIF (monthVal > 1200)
yearVal = yearVal + 10000;
monthVal = monthVal - 1200;
ENDIF
cashOutflowDate = yearVal + monthVal;
cashStaggeredPers = 1;
ENDIF
fundingIncidence = "No Year"->"No Scenario"->"No Version"->"No Entity"->"Global"->"Funding Incidence";
IF (fundingIncidence <> "No Year"->"Funding Incidence")
fundingChanged = 1;
ELSE
fundingChanged = 0;
ENDIF
IF (fundingIncidence == -1 AND fundingChanged == 1)
fundingStaggeredPers = 4;
ELSE
yearVal = @INT(fundingDate / 10000) * 10000;
monthVal = fundingDate - yearVal;
monthVal = monthVal + fundingIncidence;
IF (monthVal <= 0)
yearVal = yearVal - 10000;
monthVal = 1200 + monthVal;
ELSEIF (monthVal > 1200)
yearVal = yearVal + 10000;
monthVal = monthVal - 1200;
ENDIF
fundingDate = yearVal + monthVal;
fundingStaggeredPers = 1;
ENDIF
/* Initialize for amortization calc in next section */
basicCost = "No Year"->"Basic Cost";
salvageVal = "No Year"->"Salvage Input" * "No Year"->"Asset Units";
impairmentOpt = "No Year"->"Impairment Option";
capitalizePct = "No Year"->"Partial Capitalize %";
saleValue = "No Year"->"Sale Value";
retirementCosts = "No Year"->"Retirement Costs";
retirementObs = "No Year"->"Retirement Obligation";
amortMethod = "No Year"->"No Scenario"->"No Version"->"No Entity"->"Global"->"Amortization Method";
insuranceCost = basicCost * "No Year"->"No Scenario"->"No Version"->"No Entity"->"Global"->"Insurance %";
maintenanceCost = basicCost * "No Year"->"No Scenario"->"No Version"->"No Entity"->"Global"->"Maintenance %";
fundingAmt = basicCost * "No Year"->"No Scenario"->"No Version"->"No Entity"->"Global"->"Funding %";
IF ("No Year"->"Impairment Date1" <> #MISSING)
impairmentDate1 = @INT("No Year"->"Impairment Date1" / 100) * 100;
ELSE
impairmentDate1 = #MISSING;
ENDIF
IF ("No Year"->"Impairment Date2" <> #MISSING)
impairmentDate2 = @INT("No Year"->"Impairment Date2" / 100) * 100;
ELSE
impairmentDate2 = #MISSING;
ENDIF
impairmentFairVal1 = "No Year"->"Impairment Fair Value1";
impairmentFairVal2 = "No Year"->"Impairment Fair Value2";
/* check if we have a pre-existing asset */
IF (inServiceDate < "First Date")
yearVal = (@INT("First Date" / 10000) * 10000 - @INT(inServiceDate / 10000) * 10000) / 10000;
monthVal = ("First Date" - @INT("First Date" / 10000) * 10000) - (inServiceDate - @INT(inServiceDate / 10000) * 10000);
IF (monthVal < 0)
IF (yearVal > 0)
yearVal = yearVal - 1;
ENDIF
monthVal = 1200 + monthVal;
ENDIF
preExistingPers = @ROUND(yearVal * 12 + monthVal / 100, 0);
setStartAmort = 1;
ELSE
preExistingPers = 0;
setStartAmort = 0;
ENDIF
numAmortPeriods = 0;
periodOffset = 0;
IF (amortMethod == 1)
priorAccumAmort = 0;
amortAmt = 0;
setCashImpact = 0;
setFundingImpact = 0;
yearVal = @INT(inServiceDate / 10000) * 10000;
monthVal = (inServiceDate - @INT(inServiceDate / 10000) * 10000);
ENDIF
ENDIF
IF (@ISMBR("No Year"))
paramsSet = 0;
ENDIF
IF (NOT @ISMBR("BegBalance") AND paramsSet == 1)
/* clear out any previously calculated values */
"Amortization" = #MISSING;
"Accumulated Amortization" = #MISSING;
"Intangible Assets Finite, Gross" = #MISSING;
"Loss/(Gain) on Sale of Intangibles" = #MISSING;
"Proceeds from Sale of Intangibles" = #MISSING;
IF (cashFlowIncidence <> -1 OR cashflowChanged == 1)
"Cash Flow Allocator" = #MISSING;
ENDIF
IF (fundingIncidence <> -1 OR fundingChanged == 1)
"Funding Allocator" = #MISSING;
ENDIF
"Cash Outflow from Capital Additions" = #MISSING;
"Cash Inflow from Funding" = #MISSING;
"Long Term Debt" = #MISSING;
"Insurance" = #MISSING;
"Maintenance" = #MISSING;
"Impairment of Assets" = #MISSING;
"Retirement Expenses" = #MISSING;
"Capital Reserve" = #MISSING;
"Capital Expenditure" = #MISSING;
"Retirement Expenses" = #MISSING;
IF ("TP-Date" == purchaseDate AND (delayedStartDate == #MISSING OR (delayedStartDate > #MISSING AND "TP-Date" > delayedStartDate)))
"Capital Expenditure" = basicCost - retirementObs;
ENDIF
IF ("TP-Date" == cashOutflowDate AND (delayedStartDate == #MISSING OR (delayedStartDate > #MISSING AND "TP-Date" > delayedStartDate)))
setCashImpact = cashStaggeredPers;
cashAllocPct = 1 / cashStaggeredPers;
ENDIF
IF ("TP-Date" == fundingDate AND (delayedStartDate == #MISSING OR (delayedStartDate > #MISSING AND "TP-Date" > delayedStartDate)))
setFundingImpact = fundingStaggeredPers;
fundingAllocPct = 1 / fundingStaggeredPers;
ENDIF
IF (setCashImpact > 0)
"Cash Flow Allocator" = cashAllocPct;
setCashImpact = setCashImpact - 1;
ENDIF
"Cash Outflow from Capital Additions" = basicCost * "Cash Flow Allocator";
IF (setFundingImpact > 0)
"Funding Allocator" = fundingAllocPct;
setFundingImpact = setFundingImpact - 1;
ENDIF
"Cash Inflow from Funding" = fundingAmt * "Funding Allocator";
"Long Term Debt" = fundingAmt * "Funding Allocator";
/* Check if we should start amortization */
IF (("TP-Date" == inServiceDate) OR (setStartAmort == 1))
setStartAmort = 0;
periodOffset = 0;
numAmortPeriods = "NumPeriods" * "No Year"->"BegBalance"->"Useful Life (in Years)";
insuranceCost = insuranceCost / "NumPeriods";
maintenanceCost = maintenanceCost / "NumPeriods";
intangibleNet = basicCost;
amortAmt = (basicCost - salvageVal) / numAmortPeriods;
/* Adjust for pre existing assets */
IF (preExistingPers > 0)
numAmortPeriods = numAmortPeriods - preExistingPers;
IF (numAmortPeriods > 0)
priorAccumAmort = amortAmt * preExistingPers;
ENDIF
ENDIF
numRemainingPers = numAmortPeriods;
ENDIF
/* Amortization calculation section */
IF (amortMethod == 1 AND periodOffset < numAmortPeriods)
/* If capitalized book in Capital Reserve instead of Impairment */
IF ("TP-Date" == impairmentDate1)
IF (impairmentOpt == 1)
"Impairment of Assets" = intangibleNet - impairmentFairVal1;
ELSEIF (impairmentOpt == 2)
"Capital Reserve" = intangibleNet - impairmentFairVal1;
ELSEIF (impairmentOpt == 3)
"Capital Reserve" = (intangibleNet - impairmentFairVal1) * capitalizePct;
"Impairment of Assets" = intangibleNet - impairmentFairVal1 - "Capital Reserve";
ENDIF
basicCost = basicCost - (intangibleNet - impairmentFairVal1);
amortAmt = impairmentFairVal1 / numRemainingPers;
ELSEIF ("TP-Date" == impairmentDate2)
IF (impairmentOpt == 1)
"Impairment of Assets" = intangibleNet - impairmentFairVal2;
ELSEIF (impairmentOpt == 2)
"Capital Reserve" = intangibleNet - impairmentFairVal2;
ELSEIF (impairmentOpt == 3)
"Capital Reserve" = (intangibleNet - impairmentFairVal2) * capitalizePct;
"Impairment of Assets" = intangibleNet - impairmentFairVal2 - "Capital Reserve";
ENDIF
basicCost = basicCost - (intangibleNet - impairmentFairVal2);
amortAmt = impairmentFairVal2 / numRemainingPers;
ENDIF
IF (periodOffset + 1 == numAmortPeriods)
amortAmt = (basicCost - salvageVal) - priorAccumAmort;
ENDIF
priorAccumAmort = priorAccumAmort + amortAmt;
intangibleNet = basicCost - priorAccumAmort;
/* Only assign values to member if we are in range */
IF ("TP-Date" >= delayedStartDate AND ("TP-Date" >= inServiceDate OR preExistingPers > 0) AND (prematureEndDate == #MISSING OR "TP-Date" < prematureEndDate))
"Intangible Assets Finite, Gross" = basicCost;
"Amortization" = amortAmt;
"Accumulated Amortization" = priorAccumAmort;
"Insurance" = insuranceCost;
"Maintenance" = maintenanceCost;
ENDIF
/* Set the loss/gain if we had a sale or writeoff */
IF ("TP-Date" == prematureEndDate)
IF ("No Year"->"BegBalance"->"Reason Ended" == 2 OR
"No Year"->"BegBalance"->"Reason Ended" == 3)
netValue = basicCost - priorAccumAmort + retirementCosts;
IF ("No Year"->"BegBalance"->"Reason Ended" == 3)
"Loss/(Gain) on Sale of Intangibles" = netValue - saleValue + amortAmt;
ELSE
"Loss/(Gain) on Sale of Intangibles" = netValue + amortAmt;
ENDIF
"Retirement Expenses" = retirementCosts - retirementObs;
"Proceeds from Sale of Intangibles" = saleValue - retirementCosts;
ENDIF
ENDIF
periodOffset = periodOffset +1;
numRemainingPers = numRemainingPers -1;
ENDIF
ENDIF
ENDIF
);
ENDFIX
FIX ("BegBalance", "No Year")
"Cash Flow Incidence" (
IF (cashflowChanged == 1 AND "Asset Status" > 0)
"Cash Flow Incidence" = cashFlowIncidence;
ENDIF
IF (fundingChanged == 1 AND "Asset Status" > 0)
"Funding Incidence" = fundingIncidence;
ENDIF
)
ENDFIX
ENDFIX
FIX([Hidden_Scenario], [Hidden_Version], [Department])
@IANCESTORS([LineItem]);
@ANCESTORS([AssetClassInt]);
ENDFIX