jamessimone / apex-rollup

Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.
MIT License
222 stars 30 forks source link

Issue with Currency Conversion in Multi-Currency Orgs #622

Closed fabm97 closed 1 month ago

fabm97 commented 2 months ago

Hey James,

my customer asked me again to tackle the issue that we can have directly running rollups which calculate their values from children of differing currencies. If you remember we had this problem already sometime ago, but we settled for just updating the rollups daily. Now I tried setting them up for being updated through the Apex Trigger with "Rollup.runFromTrigger();" and encountered the same issue of wild miscalculations.

I created a simple datamodel on my developer edition org to make sure it is not connected to any logic in the customers org. I have a child object "Test Child" and a parent object "Test Parent". I added an "Amount" field of type currency on both objects and a lookup relationship from child object to parent object. Then I configured a rollup to sum the amount of the children up to the parent.

When I run an update on a child record in my setup with a parent record and two child records with differing currencies the result looks like this: image

Instead of the expected 6.38€ we get -43.42€. I can give you full access to my org if you like or I can try to send you some logs if you want. I could really not see any pattern in the miscalculations that happen here.

Would love if you can support us in finding the issue here :)

Edit: Using Version 1.6.33 of Apex Rollup on a Developer Edition Org

jamessimone commented 2 months ago

@fabm97 I should be able to reproduce this issue, but I think granting access could also be helpful so that I can ensure (based on the logs getting generated) that there isn't anything I'm not accounting for in terms of setup

jamessimone commented 2 months ago

@fabm97 I apologize for the long delay in response - I was able to reproduce this issue thanks to the org you set up, and I have now fixed it. Hoping to release the fix in the next day or so

fabm97 commented 2 months ago

Great! Thank you very much for your efforts! :)