Skip to content

Convert the currencies beyond the ECB set - #111

Open
harshvardhaniimi wants to merge 1 commit into
typecraft-dev:mainfrom
harshvardhaniimi:more-currencies
Open

harshvardhaniimi wants to merge 1 commit into
typecraft-dev:mainfrom
harshvardhaniimi:more-currencies

Conversation

@harshvardhaniimi

Copy link
Copy Markdown

Closes #106.

The calculator converts only the 30 currencies in the ECB reference rates, so 100 usd to dop or 100 aed to inr gives no result. This fetches frankfurter.dev's v2 endpoint (/v2/rates), which carries rates from more central banks, and adds the other 131 currencies it publishes. That makes 161 in total.

What changes

  • Rate source: services/CalculatorData.qml requests https://api.frankfurter.dev/v2/rates instead of /v1/latest. It is the same host, so this is still the only network request and currencyRates: false still turns it off.
  • Currency table: core/Calculator.js gains MORE_CURRENCIES, merged into CURRENCIES. The new entries have no symbol (20.00 AED) and are accepted by code or full name (dominican pesos), with an unaccented spelling where the name has accents. They never replace an existing unit or currency name, so 5 cup to ml and 2 ton to kg are unchanged.
  • Decimals: zero-decimal currencies (VND, CLP, XOF and others) and three-decimal ones (KWD, BHD, OMR and others) follow ISO 4217.
  • Parsing: rate validation moves from QML into Calculator.parseRates, so node can test it. It reads both the v2 answer and the cache file, whose format is unchanged, and it now also drops non-finite rates.
  • Docs: README, CLAUDE.md, the site copy and comments say "central-bank rates" instead of "ECB rates".

Left out

Things to know

  • Existing installs: a rate cache under 12 hours old is not refetched, so the new currencies appear at the next refresh (or after omacast call calculator.refreshCurrencies).
  • Site demo: site/public/demo/snapshot.json is not regenerated here, so the demo keeps its current rates.

Testing

  • node --test tests/*.test.js: 186 pass, 3 skipped, 0 fail, with two new tests for the conversions and for parseRates.
  • omarchy plugin validate . passes.
  • I ran CalculatorData.qml from this branch in a throwaway Quickshell instance on Omarchy 4.5.0: it fetched v2, parsed 189 rates and wrote the cache. I have not run this exact branch inside omarchy-shell; an earlier draft of the same change runs there and converts 100 aed in inr.

🤖 Generated with Claude Code

The calculator knew the 30 currencies in the ECB reference rates, so
"100 usd to dop" or "100 aed to inr" gave no result. frankfurter.dev's
v2 API publishes rates from more central banks, so fetch /v2/rates and
add the other 131 currencies it carries.

The new currencies have no symbol and answer to their code or full
name only, so none of them takes a name from a unit or from the 30
currencies already there. Rate parsing moves into core/Calculator.js
(parseRates) so node can test it; it reads the v2 answer and the cache.

Closes typecraft-dev#106

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support currencies outside the ECB reference set (e.g. DOP)

1 participant