This content has been marked as final. Show 4 replies
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.