Use FxCustomRate in HTML templates
The object, FxCustomRate
, is available in the HTML Template feature only if the Custom Exchange Rates Finance feature (currently in Limited Availability) is enabled. To request access to the Custom Exchange Rates Finance feature, contact Zuora Global Support.
- Invoices
- Credit Memos
- Debit Memos
To use FxCustomRate
on HTML Template:
- Navigate to Settings > Billing > Manage Billing Document Configuration.
- Click Add New HTML Template or select an existing one.
- On the bottom left corner of the screen, select the Show Object Schema icon
. This object includes all the exchange rates. You can either upload exchange rates via a file or utilize a third-party custom exchange rate provider.
- Search for the
FxCustomRate
object. The fields in theFxCustomRate
object are explained in the table. - Click Copy.
- In the Content tab, drag and drop the HTML component into the HTML template.
- In the HTML template, click the HTML block. The Content panel is displayed on the right of the template editor.
- In the HTML section, enter the following HTML code in the HTML editor:
{{#Invoice}} <br> Converted Amount to EUR: {{#FxCustomRates|FilterByRef(CurrencyTo,EQ,Invoice.Currency)|FilterByValue(CurrencyFrom,EQ,'EUR')|SortBy(RateDate,DESC)|First(1)}} {{Cmd_Assign(EurConversionRate,Rate,True)}} <br> "Rate:RateDate:RateSetName" <br> {{Rate}}:{{RateDate}}:{{RateSetName}} {{/FxCustomRates|FilterByRef(CurrencyTo,EQ,Invoice.Currency)|FilterByValue(CurrencyFrom,EQ,'EUR')|SortBy(RateDate,DESC)|First(1)}} <br> Original Amount: {{Amount|Round(2)|Localise}} {{Invoice.Currency}} <br> Converted Amount: {{#Wp_Eval}} {{Amount}} * {{EurConversionRate}} |Round(2)|Localise {{/Wp_Eval}} EUR {{/Invoice}}
This code filters the foreign exchange (FX) rate for converting from EUR to the invoice currency, for example, USD, sorts the results by RateDate
in descending order to retrieve the most recent rate, and assigns that rate to a temporary variable called EurConversionRate
using Cmd_Assign
. It then displays the rate details, including the rate value, its date, and the rate set name, followed by the original invoice amount in its billing currency. Finally, it calculates and displays the converted amount by multiplying the original amount by the retrieved FX rate.
Also, if you're generating an invoice and want to display a custom FX rate for a given CurrencyFrom
and RateDate
, you can filter it dynamically using invoice fields, like Invoice.Currency
and Invoice.InvoiceDate
.
- Retrieve rate based on invoice date:
{{#FXCustomRates|FilterByRef(CurrencyTo,EQ,Invoice.Currency)|FilterByValue(CurrencyFrom,EQ,GBP)|FilterByValue(RateDate,EQ,Invoice.InvoiceDate)|First(1)}}
- Retrieve the latest:
Rate:{{#FxCustomRates|FilterByRef(CurrencyTo,EQ,Invoice.Currency)|FilterByValue(CurrencyFrom,EQ,'EUR')|SortBy(RateDate,DESC)|First(1)}}
- Click Preview, and select an account and an invoice in the Preview Settings section to preview the corresponding PDF file. If a PDF file has multiple pages due to the conditional page breaks, you can see it in the invoice PDF file displayed.
Fields in the FxCustomRate object
Field Name | Type | Description |
Id | string | Unique identifier for the FX rate entry. |
CreatedById | string | ID of the user who created the entry |
CreatedDate | timestamp | Date and time the entry was created. |
UpdatedById | string | ID of the user who last updated the entry. |
UpdatedDate | timestamp | Date and time the entry was last updated. |
CurrencyFrom | string | Source currency code, for example, USD. |
CurrencyTo | string | Target currency code, for example, USD. |
Rate | decimal | Exchange rate from source to target currency. |
RateDate | date | Date the exchange rate applies to. |
RateSetName | string | Name of the FX rate set. |