Hello to all the HFM users out there,
I am having some trouble with my currency translation calculation. To explain this, let's say I have 2 additional exchange rates (AVGRATE1 and AVGRATE2) that I want to use for my cash flow accounts besides the default EOM and AVG rates that are stored in my HFM application. I understand that HFM's translation rule is cumulative in nature and here's what I have in my translation subroutine.
HS.Trans "C2#CFCALC" , "C2#CFCALC", "A#AVGRATE1", ""
HS.Trans "A#CF_XXX.C2#CFCALC" , "A#CF_XXX.C2#CFCALC", "A#AVGRATE2", ""
As you can tell, I want all the accounts to be translated using the AVGRATE1 except for CF_XXX accounts. What I am seeing is that it is doing the translation twice and I end up getting twice the amount in the <PARENT CUURENCY> of A#CF_XXX.
I know I can add some IF ELSE statements to handle this but I is there a cleaner way to do this? I have done some research and looked around but can;t find a cleaner solution.
Thanks in advance!
Assuming that C2#CFCALC member has been defined as SwitchTypeForFlow = "N", and CF accounts are of revenue or expense type, then the C2#CFCALC member behaves as revenue/expense and is translated using the normal average rate as defined in the applicationsettings record. When the Sub Translate() routine starts to execute your first line correctly translates CFCALC using AVGRATE1. The second line finds CFCALC translated by the first rate and needs to carry the translated amount to the translated value corresponding to the second rate. Then your second line should look like:
HS.Trans "A#CF_XXX.C2#CFCALC" , "A#CF_XXX.C2#CFCALC", "A#AVGRATE2", "A#AVGRATE1"
Though I have some doubts about your code, I would write it like this (keeping the same concepts I have mentioned above), in order to preserve the sequence HFM uses for retrieving rates from various locations (same entity, entity [None], triangulation etc):
vAVGRATE1 = HS.GetRate("A#AVGRATE1")
vAVGRATE2 = HS.GetRate("A#AVGRATE2")
HS.Trans "C2#CFCALC" , "", vAVGRATE1, ""
HS.Trans "A#CF_XXX.C2#CFCALC" , "", vAVGRATE2, vAVGRATE1
As you may observe, it is not necessary to duplicate the source and destination point of views of the translation since they are the same. Of course this is not important, just an observation.
Hi Kostas, thank you for your help. I just tested it and it works! I have never quite understand the second exchange rate parameter in the HS.TRANS function. My understanding (probably not correct) of that second parameter was only needed when you need to calculate the net difference of the result between after applying the rates.
As you mentioned this thing works cumulatively on the destination, meaning that when your first line executes it translates using AVG1, then when the second line executes it takes the difference (AVG2 - AVG1) as a rate and accumulates the translated value on the destination. Intrinsically the two rate arguments of HS.Trans work like the difference of the two rates. For example, when you want to calculate exchange differences you use the fxdiff pov as the destination like this:
HS.Trans "C2#fxdiff", "C2#OpeningBal", vCLOSINGRATE, vOPENINGRATE
This takes the source value of c2#OpeningBal and translates it using the (vCLOSINGRATE - vOPENINGRATE) and the result is accumulated into c2#fxdiff (initially empty).
Hope this clarifies a little more how this works.