plugin-convert-currency

A Flatfile plugin for currency conversion using Open Exchange Rates API


plugin-autocast

A plugin for automatically casting values in Flatfile.

plugin-automap

A plugin to provide automapping imported files for headless workflows.

plugin-constraints

A plugin for extending blueprint with external constraints

plugin-convert-currency

A Flatfile plugin for currency conversion using Open Exchange Rates API

plugin-convert-json-schema

A plugin for converting JSON Schema to Flatfile Blueprint and configuring a...

plugin-convert-openapi-schema

A plugin for converting OpenAPI schema to Flatfile Blueprint.

plugin-convert-sql-ddl

A plugin for converting SQL DDL into Flatfile Blueprint.

plugin-convert-translate

A Flatfile Listener plugin for field translation using the Google Translate...

plugin-convert-what3words

A Flatfile plugin for converting What3Words addresses to standard addresses...

plugin-convert-yaml-schema

A plugin for converting YAML Schema definitions to Flatfile Blueprint.

plugin-dedupe

Dedupe records in a sheet via a sheet level custom action.

plugin-delimiter-extractor

A plugin for parsing .delimiter files in Flatfile.

plugin-dxp-configure

A plugin for using DXP class-based configurations.

plugin-enrich-geocode

A Flatfile plugin for geocoding addresses using the Google Maps Geocoding A...

plugin-enrich-gpx

A Flatfile plugin for parsing GPX files and extracting relevant data

plugin-enrich-sentiment

A Flatfile plugin for sentiment analysis of text fields in records

plugin-enrich-summarize

A Flatfile plugin for text summarization and key phrase extraction

plugin-export-delimited-zip

A Flatfile plugin for exporting Workbooks to delimited files and zipping th...

plugin-export-pivot-table

A Flatfile plugin for generating pivot tables from sheet data and saving as...

plugin-export-workbook

A plugin for exporting data in Flatfile to Workbooks.

plugin-extract-html-table

A Flatfile plugin for extracting table data from HTML files

plugin-extract-markdown

A plugin for parsing markdown files in Flatfile.

plugin-import-faker

A Flatfile plugin that generates example records using Faker

plugin-import-llm-records

A Flatfile plugin that generates example records using AI

plugin-import-rss

A Flatfile plugin for importing RSS feed data

plugin-job-handler

A plugin for handling Flatfile Jobs.

plugin-json-extractor

A plugin for parsing json files in Flatfile.

plugin-markdown-extractor

A plugin for parsing markdown files in Flatfile.

plugin-pdf-extractor

A plugin for parsing PDF files in Flatfile.

plugin-record-hook

A plugin for running custom logic on individual data records in Flatfile.

plugin-rollout

A plugin for automatically rolling out new changes to workbooks in flatfile...

plugin-space-configure

A plugin for configuring a Flatfile Space.

plugin-space-configure-from-template

A plugin for configuring a Flatfile Space from a Space Template.

plugin-stored-constraints

A plugin for running stored constraints

plugin-validate-boolean

A Flatfile plugin for boolean validation with multi-language support

plugin-validate-date

A Flatfile plugin for normalizing date formats

plugin-validate-email

A Flatfile Listener plugin for email validation

plugin-validate-isbn

A Flatfile Listener plugin for ISBN validation with configurable options. V...

plugin-validate-number

A Flatfile Listener plugin for number validation

plugin-validate-phone

A validator plugin for phone number formatting on individual data records i...

plugin-validate-string

A Flatfile plugin for string configuration and validation

plugin-view-mapped

A plugin for making the view post mapping show only mapped columns.

plugin-webhook-egress

A plugin for egressing data from a Flatfile Workbook to a webhook.

plugin-xlsx-extractor

A plugin for parsing xlsx files in Flatfile.

plugin-xml-extractor

A plugin for parsing .xml files in Flatfile.

plugin-zip-extractor

A plugin for unzipping zip files and uploading content back in Flatfile.

util-extractor

A library containing common utilities and helpers for extractors.

util-file-buffer

A utility for extracting data from any file and making it available as a bu...

util-response-rejection

This plugin handles response rejections returned from an external source.

Installation


Installnpm i @flatfile/plugin-convert-currency
Source: View source
Package:@flatfile/plugin-convert-currency 0 installs

@flatfile/plugin-convert-currency

This plugin implements a currency converter for Flatfile using the Open Exchange Rates API. It allows automatic conversion of currency amounts in your Flatfile sheets, with support for historical exchange rates.

Event Type: listener.on('commit:created')

Supported Field Types: string, number

Features

  • Automatic currency conversion based on configurable fields
  • Support for historical exchange rates using a date field
  • Configurable source and target currencies
  • Optional fields for storing exchange rates and conversion dates
  • Comprehensive error handling and validation
  • Uses the Open Exchange Rates API for up-to-date and historical exchange rates

Parameters

sheetSlug - string - (required)

The slug of the sheet where the plugin should operate.

sourceCurrency - string - (required)

The source currency code (e.g., "USD").

targetCurrency - string - (required)

The target currency code (e.g., "EUR").

amountField - string - (required)

The field name containing the amount to be converted.

dateField - string - (optional)

The field name containing the date for historical rates.

convertedAmountField - string - (required)

The field name where the converted amount will be stored.

exchangeRateField - string - (optional)

The field name where the exchange rate will be stored.

conversionDateField - string - (optional)

The field name where the conversion date will be stored.

Usage

Environment Variables

Add the following environment variables to your space:

  • OPENEXCHANGERATES_API_KEY - Your Open Exchange Rates API key

install

npm install @flatfile/plugin-convert-currency

import

import { FlatfileListener } from "@flatfile/listener";
import { currencyConverterPlugin } from "@flatfile/plugin-convert-currency";

listener.js

const listener = new FlatfileListener();

listener.use(
  currencyConverterPlugin({
    sheetSlug: "transactions",
    sourceCurrency: "USD",
    targetCurrency: "EUR",
    amountField: "amount",
    dateField: "transactionDate",
    convertedAmountField: "amountInEUR",
    exchangeRateField: "exchangeRate",
    conversionDateField: "conversionDate",
  })
);

Example

This example sets up a currency conversion plugin for the "transactions" sheet. It will automatically convert amounts from USD to EUR for each record in the sheet.

import { FlatfileListener } from "@flatfile/listener";
import { currencyConverterPlugin } from "@flatfile/plugin-convert-currency";

export default function (listener: FlatfileListener) {
  listener.use(
    currencyConverterPlugin({
      sheetSlug: "transactions",
      sourceCurrency: "USD",
      targetCurrency: "EUR",
      amountField: "amount",
      dateField: "transactionDate",
      convertedAmountField: "amountInEUR",
      exchangeRateField: "exchangeRate",
      conversionDateField: "conversionDate",
    })
  );

  listener.on("job:ready", async (event) => {
    const { jobId, workbookId } = event.context;
    await event.actions.updateJob(jobId, {
      status: "complete",
      info: "Currency conversion complete",
    });
  });
}

In this example, the plugin will:

  1. Validate the configuration upon initialization
  2. Process each record in the "transactions" sheet
  3. If autoConvert is true:
    • Check for a valid amount in the "amount" field
    • Use the date in the "transactionDate" field for historical rates (if present)
    • Call the Open Exchange Rates API to get the exchange rate
    • Calculate the converted amount and store it in the "amountInEUR" field
    • Store the exchange rate in the "exchangeRate" field
    • Store the conversion date in the "conversionDate" field
  4. Handle errors and add them to the respective fields or as general errors to the record

The job:ready event listener is used to mark the job as complete after the conversion process.

Note: This plugin requires an active subscription to the Open Exchange Rates API.