SFOLN

Demos / Currency Exchange Rates API

Revalue open foreign-currency invoices at month end

A finance team with customers in five currencies closes the books in euros. Every month end somebody copies closing rates from a website into a spreadsheet, and the auditor later asks which rate was used, from which day and from which source. Here the close job asks for the rates of the closing date in one call, revalues every open invoice, drafts a balanced journal entry and keeps the rate and its date on each line. An invoice with a currency code that does not exist is held instead of being revalued at a guess.

Workflow

Where the API sits

  1. Trigger

    Month-end close starts

    A schedule runs on the first working day and reads the open foreign-currency receivables from the ledger.

  2. API call

    Get the closing rates

    One call with a pair per currency and date set to the last rate day of the month. Unknown currency codes come back skipped_invalid at no charge.

    sfoln/fx-rates

  3. Your logic

    Revalue each invoice

    Open amount × rate, compared with the booked euro value; differences are summed per currency.

  4. Result

    Report and journal entry

    A report with rate and rate date per line, and a balanced draft entry for the controller to post.

Wired as a scheduled job on the first working day of the month: read the open items from the ledger, request one pair per currency with date set to the closing date, post the draft entry through the ledger API. The same call serves a daily price-list update or an invoice that needs today's rate.

Result

The revaluation report writes itself

With the API

LedgerAR revaluation · October 2026prepared in 4 s

Net unrealised result

EUR +53.46

6 invoices revalued

Closing rate date

2026-10-30

Last reference rate of the month

Currencies

5 of 6

UKP is not an ISO 4217 code

Revaluation of open receivables

Halden Instruments B.V. · period 2026-10 · rate source: frankfurter (ECB and other central banks)

Open receivables in foreign currency at 2026-10-30 · functional currency EUR
InvoiceCustomerOpen amountBooked EURClosing rateRate dateClosing EURGain / loss
INV-2087Calder Marine LtdGBP 18,400.0020,957.601.14522026-10-3021,071.68+114.08
INV-2093Brightwater Tools Inc.USD 42,750.0038,526.300.88942026-10-3038,021.85−504.45
INV-2101Brightwater Tools Inc.USD 12,300.0011,017.110.88942026-10-3010,939.62−77.49
INV-2104Alpstein Mechanik AGCHF 27,900.0029,540.521.06412026-10-3029,688.39+147.87
INV-2110Sjövik Pumpteknik ABSEK 310,000.0027,869.000.09072026-10-3028,117.00+248.00
INV-2112Dolina Hydraulika sp. z o.o.PLN 96,500.0022,561.700.23512026-10-3022,687.15+125.45
INV-2115Calder Marine LtdUKP 6,200.00noneno ratenonenoneHeld: fix currency code
Total150,472.23150,525.69+53.46

Closing EUR = open amount × closing rate, rounded to cents. Gain / loss = closing EUR − booked EUR. Each line carries the rate and the date it was published for, so the entry can be traced by an auditor.

Post journal entryExport report (PDF)

Before

SpreadsheetAR reval Oct 2026.xlsxmanual
InvoiceCustomerOpen amountBooked EURClosing rateRate dateClosing EUR
INV-2087Calder Marine LtdGBP 18,400.0020,957.60look uptype informula
INV-2093Brightwater Tools Inc.USD 42,750.0038,526.30look uptype informula
INV-2101Brightwater Tools Inc.USD 12,300.0011,017.11look uptype informula
INV-2104Alpstein Mechanik AGCHF 27,900.0029,540.52look uptype informula
INV-2110Sjövik Pumpteknik ABSEK 310,000.0027,869.00look uptype informula
INV-2112Dolina Hydraulika sp. z o.o.PLN 96,500.0022,561.70look uptype informula
INV-2115Calder Marine LtdUKP 6,200.00?look uptype informula

Someone looks up six rates on a website, types them into the sheet and pastes the totals into a journal. The rate date and the source are not recorded, and the invoice with the wrong currency code is found during the audit.

LedgerJournal entry draftawaiting approval
Journal entry draft JE-2026-10-118 · unrealised FX on trade receivables · reverses on 2026-11-01
AccountLine textDebit EURCredit EUR
1200 Trade receivablesReval AR GBP at 1.1452 of 2026-10-30114.08
1200 Trade receivablesReval AR USD at 0.8894 of 2026-10-30581.94
1200 Trade receivablesReval AR CHF at 1.0641 of 2026-10-30147.87
1200 Trade receivablesReval AR SEK at 0.0907 of 2026-10-30248.00
1200 Trade receivablesReval AR PLN at 0.2351 of 2026-10-30125.45
6960 Unrealised FX lossesOctober revaluation, USD581.94
7960 Unrealised FX gainsOctober revaluation, GBP, CHF, SEK, PLN635.40
Total1,217.341,217.34
Rates requested for
2026-10-30
Rates published for
2026-10-30
Source
frankfurter (ECB and other central banks)
Not revalued
INV-2115skipped_invalidunsupported_currency
Five rates returned and charged; the pair with the unknown code UKP was rejected before any lookup, at no cost.

Highlighted values are read from the API response. The data is a sample in the API's real output shape; names and figures are illustrative.

Call

The call behind it

One request with this input produces the 6 records the screen above is drawn from. Prices are the ones on the API page; records that fail or come back empty are not charged.

Input · POST /v2/actors/sfoln~fx-rates/run-sync-get-dataset-items
{
  "pairs": [
    "USD/EUR",
    "GBP/EUR",
    "CHF/EUR",
    "SEK/EUR",
    "PLN/EUR",
    "UKP/EUR"
  ],
  "date": "2026-10-30"
}
Response · record 1 of 6 · sample data
{
  "input": {
    "pair": "USD/EUR",
    "base": "USD",
    "quote": "EUR",
    "amount": 1
  },
  "pair": "USD/EUR",
  "base": "USD",
  "quote": "EUR",
  "rate": 0.8894,
  "inverseRate": 1.124353497,
  "date": "2026-10-30",
  "requestedDate": "2026-10-30",
  "amount": 1,
  "converted": 0.8894,
  "status": "ok",
  "charged": true,
  "chargedEvent": "fx-rate",
  "source": "frankfurter (ECB and other central banks)",
  "fetchedAt": "2026-11-02T06:30:04.118Z"
}
Charged eventCountPriceTotal
Exchange rate
fx-rate
5$0.0005$0.0025
This run$0.0025

Fields

Which output fields do the work

Output fieldUsed for
rateClosing rate per currency: open amount × rate is the revalued euro amount of each invoice.
date requestedDatePrinted on every report line and in the journal text; a difference between the two shows that the rate was published for another day than the one asked for.
pair base quoteJoin key from the rate back to the invoices of that currency.
sourceCited in the report header as the origin of the rates.
status errorA currency code that is not supported comes back skipped_invalid with a reason; the invoice is held for correction instead of being revalued.
inverseRateFor ledgers that store rates as foreign units per euro.

All output fields are listed on the API page.

Build

Build it

Request one pair per currency for the closing date, then revalue the open items and draft the entry.

Node.js · scheduled close job
const open = await ledger.openReceivables({ notCurrency: 'EUR' });
const currencies = [...new Set(open.map((inv) => inv.currency))];

const res = await fetch('https://api.apify.com/v2/actors/sfoln~fx-rates/run-sync-get-dataset-items', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.APIFY_TOKEN}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ pairs: currencies.map((c) => `${c}/EUR`), date: closingDate }),
});
const rates = new Map((await res.json()).filter((r) => r.status === 'ok').map((r) => [r.base, r]));

const lines = [];
for (const inv of open) {
  const r = rates.get(inv.currency);
  if (!r) { await ledger.hold(inv.number, 'No closing rate for ' + inv.currency); continue; }
  const closingEur = Math.round(inv.openAmount * r.rate * 100) / 100;
  lines.push({ invoice: inv.number, currency: inv.currency, rate: r.rate, rateDate: r.date, diff: closingEur - inv.bookedEur });
}
await ledger.draftJournal({ period, lines, memo: `Rates of ${closingDate}` });
  • Rates are daily mid-market reference rates blended from the ECB and other central banks. If your accounting policy names one official source, check that this fits before relying on it.
  • A pair can carry its own date (USD/EUR@2026-10-30), so one call can also fetch the booking-date rates of new invoices.

Authentication, the MCP endpoint and the asynchronous variant are on the API page.

More

Other things teams build with it

  • Invoices that print the rate and rate date used for conversion
  • A daily price list in ten currencies for a web shop
  • Expense reports converted at the rate of the receipt date
  • A spreadsheet or BI model that needs historical rates for past periods

Related demos

All demos · Currency Exchange Rates API: prices, input and output · /actors/fx-rates.json carries this demo as demo