I have a currency field that I multiply by .5 in my apex code.
This changes the data type to a Decimal.
I want to display on a visualforce email template the newly updated number as a currency.
Should I convert it back to a Currency? When I try to do this, I get an error saying that the type is not supported.
My end goal is to display the decimal in this format: $123,456.78
I want the dollar sign, commas, and 2 decimal places. I feel like there must be an easier way to do this rather then sending the decimal to the VFP and then manipulating the format with a outputText. Even with this way the dollar sign does not show.
Any advice?
All Different Attempts:
<p><strong>Gross Sales Run Rate:</strong>
{!strFormattedCurrency}
</p>
<p><strong>Gross Sales Run Rate:</strong>
<apex:outputText value="{0, number, #,###.##}">
$<apex:param value="{!strFormattedCurrency}" />
</apex:outputText>
</p>
<p><strong>Gross Sales Run Rate:</strong>
<apex:outputText value="{0, number, #,###.##}">
$<apex:param value="{!annualRevenue}" />
</apex:outputText>
</p>
<p><strong>Gross Sales Run Rate:</strong>
<apex:outputText value="${0, number, 00.00}">
<apex:param value="{!annualRevenue}" />
</apex:outputText>
</p>
<p><strong>Gross Sales Run Rate:</strong>
<apex:outputText value="{0, number, 00.00}">
<apex:param value="{!strFormattedCurrency}" />
</apex:outputText>
</p>
APEX:
public class BrokerApprovalEmailTemplate {
public Decimal annualRevenue {get;set;}
public String strFormattedCurrency {get;set;}
public void init() {
Decimal crAnnualRevenue;
....
if(creview.Half_Revenue__c == true && (creview.SIC_Code__c == '5411' || creview.SIC_Code__c == '5541')) {
crAnnualRevenue = creview.Annual_Revenue__c * 0.50;
}
else if(creview.Half_Revenue__c == true){
crAnnualRevenue = creview.Annual_Revenue__c * 0.75;
}
else {
crAnnualRevenue = creview.Annual_Revenue__c;
}
annualRevenue = crAnnualRevenue.setScale(2, RoundingMode.HALF_UP);
strFormattedCurrency = '$' + string.valueOf(annualRevenue);