Skip to main content
If the sale has a quote, you will not be able to set or change the currency of that sale.

View base currency

Make sure the currency-related preferences are set before using GetBaseCurrency(). Otherwise, you might end up with a default value that produces some interesting conversion results!

List currencies and their conversion rate

Using the SearchEngine

Using the listAgent

Calling GetCurrencies() will give you the slim NSCurrency items. If you need more info than name and ID - such as the rate and units - then you need to retrieve the complex NSCurrencyEntity.

How currency conversion works

  1. Get the amount and currency ID from the sale.
  2. Using the list agent, get the relevant NSCurrencyEntity and extract the rate and currency unit.
  3. Do the math.

Convert to the base currency

Divide by rate and multiply by units.

Convert from the base currency

Divide by units and multiply by rate. In this case, you need to call GetCurrencyEntity() with the ID of the target currency, not the one obtained from the sale!

Convert between any 2 currencies

You can either do a two-step conversion via the base currency or calculate the relative rate between those 2 currencies and apply that directly. The latter is more efficient if you’ll be doing multiple conversions In this example, we assume we know the ID of the start and target currency and also the amount to be converted. Thus, we don’t go via the sale object.
This works even if one of the IDs represents the base currency! Thus you could wrap it up in a reusable function: