> For the complete documentation index, see [llms.txt](https://docs.omnata.com/omnata-product-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.omnata.com/omnata-product-documentation/omnata-connect-for-salesforce/advanced-features/multi-currency-handling/apex-features.md).

# Apex Features

Because some users may query the database directly using our Apex interface, Omnata has provided access to our multi-currency handling classes for Apex users.

These take the form of global classes that can be invoked from code outside of the managed package.

## Data Classes

The following classes are used to carry currency-rated data. They are used in place of the standard sObjects (CurrencyType, DatedConversionRate) since these objects may or may not exist depending on the Org configuration.

### omnata\_sf.ConversionRate

| Field name     | Type    | Description                              |
| -------------- | ------- | ---------------------------------------- |
| conversionRate | Decimal | The rate, relative to the corporate rate |
| decimalPlaces  | Integer | The number of decimal places             |
|                |         |                                          |

### omnata\_sf.ConversionRateAtDate

| Field name     | Type    | Description                                                   |
| -------------- | ------- | ------------------------------------------------------------- |
| conversionRate | Decimal | The rate, relative to the corporate rate                      |
| decimalPlaces  | Integer | The number of decimal places                                  |
| startDate      | Date    | The start date of this rate’s effective period                |
| nextStartDate  | Date    | The date of the day after this rate’s effective date finishes |

## Helper Classes

### omnata\_sf.CurrencyHelper

Contains logic for handling various multi-currency scenarios.

#### getDatedExchangeRate(String currencyCode, Date effectiveDate)

Returns a omnata\_sf.ConversionRate object, containing the conversion information for the provided currency code, at the provided effective date.

This information will come from the DatedConversionRate Salesforce object.

Example usage (assumes existing multi-currency configuration in Salesforce):

```
omnata_sf.ConversionRate rate = omnata_sf.CurrencyHelper.getDatedExchangeRate('USD', Date.valueOf('2021-08-01');
System.assertEquals(Decimal.valueOf('0.70'),rate.conversionRate));
```

#### getExchangeRate(String currencyCode)

Returns a omnata\_sf.ConversionRateAtDate object, containing the conversion information for the provided currency code

This information will come from the CurrencyTypeSalesforce object.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.omnata.com/omnata-product-documentation/omnata-connect-for-salesforce/advanced-features/multi-currency-handling/apex-features.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
