23 February 2015

Rendering a Decimal into any Currency

A few days ago I faced an interesting challenge. One of our clients decided to enable multi-currency in the middle of the project and that wasn't discussed at the beginning. A couple of other developers from my team have built around 90% of the solution (unaware that multi-currency will be enabled at a later stage) and I got involved towards the end of the project. Part of the solution involved a multi-step wizard which includes a product search VisualForce page as well as a summary page before the end-user is redirected to a payment gateway - something similar to a shopping cart. The product records listed on those pages display mixed information that consists of a few objects linked through lookup fields. In order to make things easier and more dynamic, we've used a wrapper class that contains all the necessary information that we need to display. Pretty standard stuff when you hit this kind of complexity.

So, is there a way to render a Decimal variable into a specific currency format, keeping the conversion rate?