UDBR script example, intercompany profit margin per counterpart
The margins are based on a calculation of other accounts and will be stored on a margin account, with intercompany code M.
Typically the margin is the result of the division of the monthly gross profit by the monthly gross revenue. This margin account will then be used for the intercompany profit elimination.
In the example scripted below, the gross profit is the sum of the accounts: 409000002, 5001000002, 5004000002, 5005000002. The gross revenue is the account 409000002. All these accounts are intercompany accounts.
The intercompany profit margin is a statistical account called interPMargin with intercompany code M. This account can be analyzed by dimension.
The formula for this calculation is:
interPMargin = monthlyGrossProfit / monthlyGrossRevenue
Where:
monthlyGrossProfit = ((409000002 periodvalue) + (5001000002 periodvalue)+ (5004000002 periodvalue)+ (5005000002 periodvalue))
monthlyGrossRevenue = (409000002 periodvalue)
source1 = Creator.createSource()
source1.setAccount('4009000002')
source1.loadPeriodData()
source2 = Creator.createSource()
source2.setAccount('5001000002')
source2.loadPeriodData()
source3 = Creator.createSource()
source3.setAccount('5004000002')
source3.loadPeriodData()
source4 = Creator.createSource()
source4.setAccount('5005000002')
source4.loadPeriodData()
monthlyGrossProfit = Creator.createTarget()
monthlyGrossProfit.setAccount('INTERPMARGIND')
monthlyGrossProfit.addDataWithFactor(source1, 1)
monthlyGrossProfit.addDataWithFactor(source2, 1)
monthlyGrossProfit.addDataWithFactor(source3, 1)
monthlyGrossProfit.addDataWithFactor(source4, 1)
monthlyGrossRevenue = Creator.createTarget()
monthlyGrossRevenue.setAccount('INTERPMARGIND')
monthlyGrossRevenue.addDataWithFactor(source1, 1)
interPMargin = Creator.createTarget()
interPMargin.setAccount('INTERPMARGIND')
interPMargin.addDataWithFactor(monthlyGrossProfit, 1)
interPMargin.divideByTarget(monthlyGrossRevenue)
interPMargin.multiplyByConstant(100)
interPMargin.setTransferAmount()
interPMargin.setTransferCurrency('PER')
interPMargin.setAmountToConstant(1)
interPMargin.mergeAndSaveData()
Description of example parts
This is a description of the purpose of the different parts in the script:
source1 = Creator.createSource()
source1.setAccount('4009000002')
source1.loadPeriodData()
source2 = Creator.createSource()
source2.setAccount('5001000002')
source2.loadPeriodData()
source3 = Creator.createSource()
source3.setAccount('5004000002')
source3.loadPeriodData()
source4 = Creator.createSource()
source4.setAccount('5005000002')
source4.loadPeriodData()
monthlyGrossProfit = Creator.createTarget()
monthlyGrossProfit.setAccount('INTERPMARGIND')
monthlyGrossProfit.addDataWithFactor(source1, 1)
monthlyGrossProfit.addDataWithFactor(source2, 1)
monthlyGrossProfit.addDataWithFactor(source3, 1)
monthlyGrossProfit.addDataWithFactor(source4, 1)
monthlyGrossRevenue = Creator.createTarget()
monthlyGrossRevenue.setAccount('INTERPMARGIND')
monthlyGrossRevenue.addDataWithFactor(source1, 1)
interPMargin = Creator.createTarget()
interPMargin.setAccount('INTERPMARGIND')
interPMargin.addDataWithFactor(monthlyGrossProfit, 1)
interPMargin.divideByTarget(monthlyGrossRevenue)
interPMargin.multiplyByConstant(100)
interPMargin.setTransferAmount()
interPMargin.setTransferCurrency('PER')
interPMargin.setAmountToConstant(1)
interPMargin.mergeAndSaveData()