Skip to main content
This plugin automatically converts currency values from a source currency to a target currency for records within a Flatfile Sheet. It utilizes the Open Exchange Rates API to fetch both the latest and historical exchange rates. The primary use case is for processing financial data, such as transaction logs or expense reports, where amounts need to be standardized into a single currency. The plugin can use a date from another field in the record to fetch the correct historical rate for the conversion. It can optionally store the calculated exchange rate and the date of conversion back into the record. The plugin operates by hooking into the record processing lifecycle, making it a seamless part of the data import process.

Installation

Install the plugin using npm:

Configuration & Parameters

The plugin requires a configuration object with the following parameters:

Required Parameters

Optional Parameters

Usage Examples

Basic Usage

Full Configuration with Historical Rates

Using Utility Functions

Troubleshooting

Common Error Messages

Error Handling

The plugin handles errors gracefully by attaching them directly to records in Flatfile:
  • Validation errors: Attached to specific fields using record.addError(fieldName, message)
  • API/Network errors: Attached as general record errors using record.addError('general', message)

Notes

Requirements

  • An active subscription to the Open Exchange Rates API is required
  • The OPENEXCHANGERATES_API_KEY environment variable must be set in your Flatfile Space with your API key

Limitations

  • All currency conversions are routed through USD as a base currency due to Open Exchange Rates API limitations on free/lower-tier plans
  • The dateField must contain dates in YYYY-MM-DD format only
  • Converted amounts are fixed to 4 decimal places
  • Exchange rates are fixed to 6 decimal places

Default Behavior

  • When dateField is not provided, the plugin uses the current date to fetch the latest exchange rates
  • When exchangeRateField is not provided, the calculated exchange rate is not stored on the record
  • When conversionDateField is not provided, the conversion timestamp is not stored on the record
  • Empty date fields default to the current date in YYYY-MM-DD format