Skip to main content
Expert
Oct 5, 2022 11:48 PM UTC
Solved

Copy FX Rates between FX Types and Different periods

The below code copy the Prior Period FX Rates from one Type to Another. This will read the currency from the application properties. I have hard coded the Period but you can use WF or Global or Param and call in the DM/Dashboard.

 

 

 

				'Get the Period 			
				Dim CurrentPeriod As String = "2021M1"
				Dim PriorPeriod As String = "2020M12"
					
				'Get Currency from properties
				Dim objAppProperties As AppProperties =  BRApi.Utilities.GetApplicationProperties(si)
				Dim currency() As String = objAppProperties.CurrencyFilter.Split(",")

				'Add FX rates
				For Each c As String In currency
					Dim fxRatePkUsingNames As New FxRatePkUsingNames("AverageRate", PriorPeriod, c.ToString, "USD")
					Dim objFxRateUsingNames As FxRateUsingNames = BRApi.Finance.Data.GetStoredFxRate(si, fxRatePkUsingNames)	
						If objFxRateUsingNames.Amount > 0 Then
							Dim fxTargetRatePkUsingNames As New FxRatePkUsingNames("ActPriorMon", CurrentPeriod, c.ToString, "USD")
							Dim objFxTargetRateUsingNames As New FxRateUsingNames(fxTargetRatePkUsingNames, objFxRateUsingNames.Amount)
							Dim objXFResult As XFResult = BRApi.Finance.Data.SetFxRate(si, objFxTargetRateUsingNames)
						End If
				Next

 

 

 

 

 

Employee - Sage
Oct 7, 2022 9:10 AM UTC

Thanks Krishna !

3 replies

Employee - Sage
Oct 7, 2022 9:10 AM UTC

Thanks Krishna !

Newcomer
May 26, 2023 10:30 AM UTC

HI

Thanks for this i created a Finance business rule and add this into it however when i consolidate i dont see anything happen. What should trigger this to copy from rate X to Y?

 

Thanks

KrishnaAuthor
Expert
May 26, 2023 7:49 PM UTC

Hi - This is not the finance rule it is an extensibility rule. You can trigger the finance rule using DM Job.