Professional Documents
Culture Documents
SAMPLEAPP Rules - Rle
SAMPLEAPP Rules - Rle
'
' Stat.Rle has been updated for HFM 11.1.1 release
' with Sub EquityPickUp example
' as well as changes in Sub NoInput to accomodate
' for the EPU calculations
'
'******************************************************
'*************************************************
'* CALCULATE ROUTINE *
'*************************************************
Sub Calculate()
'=================================================
'= Prior Rates =
'=================================================
HS.Exp "A#AverateP=A#Averate.P#Last.Y#Prior"
HS.Exp "A#Operate=A#Clorate.P#Last.Y#Prior"
Value=HS.Value.Member
'=================================================
'= ENTITY CURRENCY =
'=================================================
If Value="<Entity Currency>" Then
If HS.Entity.isBase("","") Then
'------------------------------------------------
' Retrieval of opening balance from prior period
'------------------------------------------------
HS.Exp "C1#Opening=C1#Closing.P#Last.Y#Prior"
'------------------------------------------------
' Calculation of flows for Balance Sheet accounts
'------------------------------------------------
HS.Exp "C1#Check=C1#Closing-C1#TotFlows"
HS.Clear "C1#Movement"
HS.Exp "C1#Movement=C1#Closing-C1#TotFlows"
'------------------------------------------------
' Impact next year
'------------------------------------------------
If HS.Period.isLast Then HS.ImpactStatus "P#First.Y#Next"
'------------------------------------------------
' Park accounts for ROA
'------------------------------------------------
HS.Exp "A#AssetsP=(A#Assets+A#Assets.P#Prior)/2"
HS.Exp "A#AssetsY=(A#Assets.Y#Prior.P#Last+A#Assets)"
If Hs.Period.Number>1 Then
For i=1 to HS.Period.Number-1
HS.Exp "A#AssetsY=A#AssetsY+A#Assets.P#Cur-" & i
Next
End If
HS.Exp "A#AssetsY=A#AssetsY/(Hs.Period.Number+1)"
Else
'------------------------------------------------
' Earnings per share
'------------------------------------------------
HS.Exp "A#EPS=A#NetIncG/A#DilSha"
End If
'=================================================
'= ADJ's Value =
'=================================================
ElseIf Value="<Entity Curr Adjs>" or HS.Value.IsTransCurAdj or Value="[Parent
Adjs]" or Value="[Contribution Adjs]" Then
'-------------------------------------------------
' Retrieval of opening balance from prior period
'-------------------------------------------------
HS.Exp "C1#Opening=C1#Closing.P#Last.Y#Prior"
'-------------------------------------------------
' Move net income from P&L to BS
'-------------------------------------------------
HS.Exp "A#NetInc=A#NetIncPL"
'-------------------------------------------------
' Move prior year net income to retained earnings
'-------------------------------------------------
HS.Exp "A#Retearn.C1#Appropriation=A#NetIncPL.C1#[None].P#Last.Y#Prior"
'-------------------------------------------------
' Calculate Closing
'-------------------------------------------------
HS.Exp "C1#Closing=C1#TotFlows"
'------------------------------------------------
' Impact next year
'------------------------------------------------
If HS.Period.isLast Then HS.ImpactStatus "P#First.Y#Next"
'=================================================
'= TRANSLATED CURRENCY =
'=================================================
ElseIf HS.Value.IsTransCur Then
'-------------------------------------------------
' Retrieval of opening balance from prior period
'-------------------------------------------------
HS.Exp "C1#Opening=C1#Closing.P#Last.Y#Prior"
'-------------------------------------------------
' Calculate Closing
'-------------------------------------------------
HS.Exp "C1#Closing=C1#TotFlows"
'=================================================
'= PROPORTION / ELIMINATION =
'=================================================
Else
'-------------------------------------------------
' Calculate Closing
'-------------------------------------------------
HS.Exp "C1#Closing=C1#TotFlows"
End If
'-------------------------------------------------
' Validation accounts
'-------------------------------------------------
I12=".I#[ICP Top].C1#AllCustom1.C2#AllCustom2"
HS.AbsExp "A#ValidAcct1=A#Asstot" & I12 & "-(A#EquityT" & I12 & "+A#Liatot" &
I12 & ")"
'HS.AbsExp "A#ValidAcct2=A#NetIncPL.I#[ICP Top]-A#NetInc"
End Sub
'*************************************************
'* TRANSLATE ROUTINE *
'*************************************************
Sub Translate()
'------------------------------------------------------
' Rates variables
'------------------------------------------------------
AVE=HS.GetRate("A#AveRate")
CLO=HS.GetRate("A#CloRate")
AVE_1=HS.GetRate("A#AverateP")
CLO_1=HS.GetRate("A#OpeRate")
'------------------------------------------------------
' Translation of movements not using the default
'------------------------------------------------------
HS.Trans "C1#Appropriation","",AVE_1,""
'------------------------------------------------------
' FX calculation
'------------------------------------------------------
HS.Trans "C1#FXOpening","C1#Opening",CLO,CLO_1
HS.Trans "C1#FXMovement","C1#Closing",CLO,AVE
HS.Trans "C1#FXMovement","C1#Opening",AVE,CLO
'------------------------------------------------------
' Net income translation
'------------------------------------------------------
HS.Trans "A#NetInc","",AVE,""
HS.Trans "A#Cap_Cta.C1#FXMovement","A#NetInc.C1#[None]",CLO,AVE
HS.Trans
"A#Cap_Cta.C1#FXOpening","A#NetInc.C1#[None].P#Last.Y#Prior",AVE_1,CLO_1
'------------------------------------------------------
' Translation of accounts at historical rate
'------------------------------------------------------
AcctList = HS.Account.List("","[Base]")
'------------------------------------------------------
' Cumulated Translation Adjustment in the balance sheet
'------------------------------------------------------
Case "HIST1"
'------------------------------------------------------
' Cumulated Translation Adjustment in separate account
'------------------------------------------------------
Case "HIST2"
End Select
Next
End Sub
'*************************************************
'* CONSOLIDATE ROUTINE *
'*************************************************
Sub Consolidate()
Method=HS.Node.Method("")
'=====================================================
'= METHODS: HOLDING - GLOBALE - PROPORZ - EQUITY =
'=====================================================
If Method="HOLDING" or Method="GLOBAL" or Method="PROPORTIONAL" or
Method="EQUITY" Then
'-------------------------------------------------
' Current Entity variables
'-------------------------------------------------
Entity=HS.Entity.Member
PCon=HS.Node.PCon("")
POwn=HS.Node.POwn("")
PMin=PCon-POwn
PCon_1=HS.Node.PCon("P#Last.Y#Prior")
POwn_1=HS.Node.POwn("P#Last.Y#Prior")
PMin_1=PCon_1-POwn_1
VPCon=PCon-PCon_1
VPOwn=POwn-POwn_1
VPMin=PMin-PMin_1
'-------------------------------------------------
' Technical accounts
'-------------------------------------------------
NiEq="A#EquInc"
IEq="A#Inveq"
Link="A#Linkinv"
RcG="A#ResConG"
RcvG="A#CtaG"
NiG="A#NetIncG"
RcM="A#ResConM"
RcvM="A#CtaM"
NiM="A#NetIncM"
'-------------------------------------------------
' Working variables
'-------------------------------------------------
NInc=".C1#NetIncome"
Var=".C1#Variance"
Elim=".V#[Elimination]"
'=================================================
'= Entity Data Unit =
'=================================================
Set DataUnit=HS.OpenDataUnit("")
NumItems=DataUnit.GetNumItems
Call
DataUnit.GetItem(i,Account,ICP,Custom1,Custom2,Custom3,Custom4,Data)
'-------------------------------------------------
' Variance movement
'-------------------------------------------------
If Custom1="Opening" Then C1Dest=Var Else C1Dest=".C1#" & Custom1
'-------------------------------------------------
' Default consolidation
'-------------------------------------------------
If Method<>"EQUITY" Then HS.Con Acc & C1Dest,PCon,""
'-------------------------------------------------
' Automatic elimination
'-------------------------------------------------
Rule=HS.Account.UD3("")
Audit=Rule
'----------------------------------------------------
' Equity Accounts
'----------------------------------------------------
Case "CAPITAL"
If Method<>"HOLDING" Then
Nature=".C2#Equity"
If Custom1="Appropriation" Then
If Method="EQUITY" Then
HS.Con IEq & Nature & Elim,PCon_1*(-1),Audit
HS.Con IEq & Var & Nature & Elim,VPCon*(-
1),Audit
Else
HS.Con Acc & Elim,PCon*(-1),Audit
End If
HS.Con RcG & Nature & Elim,POwn_1,Audit
HS.Con RcG & Var & Nature & Elim,VPOwn,Audit
HS.Con RcM & Nature & Elim,PMin_1,Audit
HS.Con RcM & Var & Nature & Elim,VPMin,Audit
Else
If Method="EQUITY" Then
HS.Con IEq & C1Dest & Nature & Elim,PCon*(-
1),Audit
Else
HS.Con Acc & C1Dest & Elim,PCon*(-1),Audit
End If
HS.Con RcG & C1Dest & Nature & Elim,POwn,Audit
HS.Con RcM & C1Dest & Nature & Elim,PMin,Audit
End If
End If
'----------------------------------------------------
' Cumulated Translation Adjustment for Equity
'----------------------------------------------------
Case "CAP_CTA"
Nature=".C2#Equity"
If Method="EQUITY" Then
HS.Con IEq & C1Dest & Nature & Elim,PCon*(-1),Audit
Else
HS.Con Acc & C1Dest & Elim,PCon*(-1),Audit
End If
HS.Con RcvG & C1Dest & Nature & Elim,POwn,Audit
HS.Con RcvM & C1Dest & Nature & Elim,PMin,Audit
'----------------------------------------------------
' Investments
'----------------------------------------------------
Case "INVEST"
Call SetICP(ICP,ICPMethod)
If ICPMethod="HOLDING" or ICPMethod="GLOBAL" or
ICPMethod="PROPORTIONAL" or ICPMethod="EQUITY" Then
Nature=".C2#Investments"
PElim=".E#" & ICP & ".I#" & Entity & Elim
If Method="EQUITY" Then
HS.Con IEq & C1Dest & Nature & Elim,PCon*(-1),Audit
Else
HS.Con Acc & C1Dest & Elim,PCon*(-1),Audit
End If
HS.Con Link & C1Dest & Elim,PCon,Audit
HS.Con Link & C1Dest & PElim,PCon*(-1),Audit
End If
'----------------------------------------------------
' Cumulated Translation Adjustment for Investments
'----------------------------------------------------
Case "INV_CTA"
Call SetICP(ICP,ICPMethod)
If ICPMethod="HOLDING" or ICPMethod="GLOBAL" or
ICPMethod="PROPORTIONAL" or ICPMethod="EQUITY" Then
Nature=".C2#Investments"
PElim=".E#" & ICP & ".I#" & Entity & Elim
If Custom1="Opening" Then
HS.Con RcG & C1Dest & Nature & PElim,POwn*(-
1),Audit
HS.Con RcM & C1Dest & Nature & PElim,PMin*(-
1),Audit
HS.Con RcvG & C1Dest & Nature & PElim,POwn,Audit
HS.Con RcvM & C1Dest & Nature & PElim,PMin,Audit
End If
End If
'----------------------------------------------------
' Net Income
'----------------------------------------------------
Case "NETINC"
Nature=".C2#Equity"
If Method="EQUITY" Then
HS.Con IEq & NInc & Nature & Elim,PCon*(-1),Audit
HS.Con NiEq & Elim,PCon,Audit
Else
HS.Con Acc & Elim,PCon*(-1),Audit
End If
HS.Con NiG & C1Dest & Elim,POwn,Audit
HS.Con NiM & C1Dest & Elim,PMin,Audit
'----------------------------------------------------
' Standard Elimination
'----------------------------------------------------
Case "STDELIM"
If Method<>"EQUITY" Then
Call SetICP(ICP,ICPMethod)
If ICPMethod="HOLDING" or ICPMethod="GLOBAL" or
ICPMethod="PROPORTIONAL" Then
End If
End Select
End if
Next
End if
'===============================================================
'= METHODS: HOLDING - GLOBALE - PROPORZ - EQUITY - DISPOSED =
'===============================================================
If Method="HOLDING" or Method="GLOBAL" or Method="PROPORTIONAL" or
Method="EQUITY" or Method="DISPOSED" Then
'=================================================
'= Prior Proportional Data Unit =
'=================================================
Set DataUnit=HS.OpenDataUnit("P#Last.Y#Prior.V#[Proportion].C1#Closing")
NumItems=DataUnit.GetNumItems
Call
DataUnit.GetItem(i,Account,ICP,Custom1,Custom2,Custom3,Custom4,Data)
If Data<>0 Then
HS.Con "C1#Opening",1,""
HS.Con "C1#Variance",-1,""
End if
Next
'=================================================
'= Prior Elimination Data Unit =
'=================================================
Elim=".V#[Elimination]"
Audit="OpenElim"
Set DataUnit=HS.OpenDataUnit("P#Last.Y#Prior.V#[Elimination].C1#Closing")
NumItems=DataUnit.GetNumItems
Call
DataUnit.GetItem(i,Account,ICP,Custom1,Custom2,Custom3,Custom4,Data)
If Data<>0 Then
End if
Next
End If
End Sub
'*************************************************
'* Allocation ROUTINE *
'*************************************************
Sub Allocate()
'-------------------------------------------------
' Admex allocation
'-------------------------------------------------
HS.Alloc "A#Admex","A#Admex.E#Group","[Base]","A#CogsTP" &
"/HS.Entity.Sum(A#CogsTP)",""
End Sub
'*************************************************
'* NO INPUT ROUTINE *
'*************************************************
Sub NoInput()
'-------------------------------------------------
' Movement flow for ST accounts
'-------------------------------------------------
HS.NoInput "V#<Entity Currency>.C1#Movement"
'--------------------------------------------------------------------
' Additional changes for EPU calculation for FXOpening and FXMovement
'--------------------------------------------------------------------
HS.NoInput "V#<Entity Currency>.A#EquityPickUp"
HS.NoInput "C1#FXOpening"
HS.NoInput "C1#FXMovement"
End Sub
'*************************************************
'* INPUT ROUTINE *
'*************************************************
Sub Input()
'-------------------------------------------------
' Fully diluted shares
'-------------------------------------------------
HS.Input "A#DilSha"
End Sub
'*************************************************
'* DYNAMIC ROUTINE *
'*************************************************
Sub Dynamic()
HS.Dynamic "A#GMPct=A#GroMar/A#SalesTP*100"
HS.Dynamic "A#ROA.W#Periodic=A#NetIncD*HS.Period.NumPerInGen/A#AssetsP*100"
HS.Dynamic
"A#ROA.W#QTD=A#NetIncD*HS.Period.NumPerInGen/Hs.View.PeriodNumber/A#AssetsQ*100"
HS.Dynamic
"A#ROA.W#HYTD=A#NetIncD*HS.Period.NumPerInGen/Hs.View.PeriodNumber/A#AssetsH*100"
HS.Dynamic
"A#ROA.W#YTD=A#NetIncD*HS.Period.NumPerInGen/Hs.View.PeriodNumber/A#AssetsY*100"
End Sub
'*************************************************
'* Equity Pick Up ROUTINE *
'*************************************************
Sub EquityPickUp()
'----------------------------------------------------------------------------------
---------------------------------------
'In the Run EPU process, we assume that the default POV is the followiing:
'
'Curernt Scenario, Current Year, Current Period
'Entity: Owner of the pair being processed
'Value: <Entity Currency>
'
'The system wil always write to <Entity Currency> of the Owner.
'By default, it will also read from this same entity.
'If we want to read the source data from the owned entity, we will need to use new
Rules functions.
'
'
'The following additional functions are required:
'Hs.Entity.Owned: will return the Owned entity of the pair currently processed
'Hs.Entity.Owner: will return the Owner of the pair
'Please note that this function is not absolutely necessary because it is
equivalent to Hs.Entity.Member
'
'Default parameters: Blank value for Hs.PEPU parameters will return from the EPU
table the percentage of ownership
'for the current pair in the current Scenario, Year, Period
'----------------------------------------------------------------------------------
---------------------------------------
Owner = Hs.Entity.Owner
Owned = Hs.Entity.Owned
lPown = Hs.GetCell("E#" & Owned & ".I#" & Owner & ".V#[None].A#[Shares
%Owned].C1#[None].C2#[None].C3#[None].C4#[None]")
OwnerDefCurr = HS.Entity.DefCurrency("")
TotEquitySubsidiary = "(" & EquityFromChild & "+" & EquityFromDescend & ")"
EquityPickUpCalc = EquityPickUpDest & "=" & TotEquitySubsidiary & "*" & Factor
Hs.Clear EquityPickUpDest
Hs.Exp EquityPickUpCalc
End Sub
'*************************************************
'* Support IC Transactions *
'*************************************************
Sub Transactions()
HS.SupportsTran "S#ActMon.A#RecltIC.C1#Closing"
HS.SupportsTran "S#ActMon.A#RecltIC.C1#Increases"
HS.SupportsTran "S#ActMon.A#RecltIC.C1#Decreases"
HS.SupportsTran "S#ActMon.A#RecltIC.C1#Other"
HS.SupportsTran "S#ActMon.A#PayltIC.C1#Closing"
HS.SupportsTran "S#ActMon.A#PayltIC.C1#Increases"
HS.SupportsTran "S#ActMon.A#PayltIC.C1#Decreases"
HS.SupportsTran "S#ActMon.A#PayltIC.C1#Other"
HS.SupportsTran "S#ActMon.A#RecstIC.C1#Closing"
HS.SupportsTran "S#ActMon.A#RecstIC.C1#Other"
HS.SupportsTran "S#ActMon.A#PaystIC.C1#Closing"
HS.SupportsTran "S#ActMon.A#PaystIC.C1#Other"
HS.SupportsTran "S#ActMon.A#SalesIC"
HS.SupportsTran "S#ActMon.A#CogsIC"
HS.SupportsTran "S#ActMonZPer.A#RecltIC.C1#Closing"
HS.SupportsTran "S#ActMonZPer.A#RecltIC.C1#Increases"
HS.SupportsTran "S#ActMonZper.A#RecltIC.C1#Decreases"
HS.SupportsTran "S#ActMonZPer.A#RecltIC.C1#Other"
HS.SupportsTran "S#ActMonZPer.A#PayltIC.C1#Closing"
HS.SupportsTran "S#ActMonZPer.A#PayltIC.C1#Increases"
HS.SupportsTran "S#ActMonZPer.A#PayltIC.C1#Decreases"
HS.SupportsTran "S#ActMonZPer.A#PayltIC.C1#Other"
HS.SupportsTran "S#ActMonZPer.A#RecstIC.C1#Closing"
HS.SupportsTran "S#ActMonZPer.A#RecstIC.C1#Other"
HS.SupportsTran "S#ActMonZper.A#PaystIC.C1#Closing"
HS.SupportsTran "S#ActMonZper.A#PaystIC.C1#Other"
HS.SupportsTran "S#ActMonZPer.A#SalesIC"
HS.SupportsTran "S#ActMonZPer.A#CogsIC"
HS.SupportsTran "S#ActMonZYTD.A#RecltIC.C1#Closing"
HS.SupportsTran "S#ActMonZYTD.A#RecltIC.C1#Increases"
HS.SupportsTran "S#ActMonZYTD.A#RecltIC.C1#Decreases"
HS.SupportsTran "S#ActMonZYTD.A#RecltIC.C1#Other"
HS.SupportsTran "S#ActMonZYTD.A#PayltIC.C1#Closing"
HS.SupportsTran "S#ActMonZYTD.A#PayltIC.C1#Increases"
HS.SupportsTran "S#ActMonZYTD.A#PayltIC.C1#Decreases"
HS.SupportsTran "S#ActMonZYTD.A#PayltIC.C1#Other"
HS.SupportsTran "S#ActMonZYTD.A#RecstIC.C1#Closing"
HS.SupportsTran "S#ActMonZYTD.A#RecstIC.C1#Other"
HS.SupportsTran "S#ActMonZYTD.A#PaystIC.C1#Closing"
HS.SupportsTran "S#ActMonZYTD.A#PaystIC.C1#Other"
HS.SupportsTran "S#ActMonZYTD.A#SalesIC"
HS.SupportsTran "S#ActMonZYTD.A#CogsIC"
HS.SupportsTran "S#ActQtdZPer.A#RecltIC.C1#Closing"
HS.SupportsTran "S#ActQtdZPer.A#RecltIC.C1#Increases"
HS.SupportsTran "S#ActQtdZper.A#RecltIC.C1#Decreases"
HS.SupportsTran "S#ActQtdZPer.A#RecltIC.C1#Other"
HS.SupportsTran "S#ActQtdZPer.A#PayltIC.C1#Closing"
HS.SupportsTran "S#ActQtdZPer.A#PayltIC.C1#Increases"
HS.SupportsTran "S#ActQtdZPer.A#PayltIC.C1#Decreases"
HS.SupportsTran "S#ActQtdZPer.A#PayltIC.C1#Other"
HS.SupportsTran "S#ActQtdZPer.A#RecstIC.C1#Closing"
HS.SupportsTran "S#ActQtdZPer.A#RecstIC.C1#Other"
HS.SupportsTran "S#ActQtdZper.A#PaystIC.C1#Closing"
HS.SupportsTran "S#ActQtdZper.A#PaystIC.C1#Other"
HS.SupportsTran "S#ActQtdZPer.A#SalesIC"
HS.SupportsTran "S#ActQtdZPer.A#CogsIC"
' Support for Scenario = ActQtdZYTD
HS.SupportsTran "S#ActQtdZYTD.A#RecltIC.C1#Closing"
HS.SupportsTran "S#ActQtdZYTD.A#RecltIC.C1#Increases"
HS.SupportsTran "S#ActQtdZYTD.A#RecltIC.C1#Decreases"
HS.SupportsTran "S#ActQtdZYTD.A#RecltIC.C1#Other"
HS.SupportsTran "S#ActQtdZYTD.A#PayltIC.C1#Closing"
HS.SupportsTran "S#ActQtdZYTD.A#PayltIC.C1#Increases"
HS.SupportsTran "S#ActQtdZYTD.A#PayltIC.C1#Decreases"
HS.SupportsTran "S#ActQtdZYTD.A#PayltIC.C1#Other"
HS.SupportsTran "S#ActQtdZYTD.A#RecstIC.C1#Closing"
HS.SupportsTran "S#ActQtdZYTD.A#RecstIC.C1#Other"
HS.SupportsTran "S#ActQtdZYTD.A#PaystIC.C1#Closing"
HS.SupportsTran "S#ActQtdZYTD.A#PaystIC.C1#Other"
HS.SupportsTran "S#ActQtdZYTD.A#SalesIC"
HS.SupportsTran "S#ActQtdZYTD.A#CogsIC"
End Sub
'*************************************************
'* SUBROUTINES *
'*************************************************
'-------------------------------------------------
' Retrieves current ICP method
'-------------------------------------------------
Sub SetICP(ICP,ICPMethod)
ICPMethod=""
End If
End Sub
'=================================================
'= WRITE TO FILE =
'=================================================
Sub WriteToFile(txtStringToWrite)
'this routine will write to a file and create the file first if it is not there
'the lines 'On Error Resume Next' and 'On Error Goto 0' will let the system
continue processing
'in the case there is an error in the routine. this is desirable because it
would be foolish to
'let the writing to a file routine bring down HFM unnecessarily in the event of
a fatal error
'To call this routine, the following 'template' can be copied and modified
appropriately:
'Call WriteToFile("Replace this text with whatever you would like written to
the file")
'Call WriteToFile("Calculate Cash Flow for:" & HS.Entity.Member & " " &
Hs.Scenario.Member & " " & Hs.Period.Member)
End Sub
'*************************************************
'* FUNCTIONS *
'*************************************************
'-------------------------------------------------
' Minimum
'-------------------------------------------------
Function Minimum(Par1,Par2)
If Par1 > Par2 Then Minimum = Par2 Else Minimum = Par1
End Function