Skip to content

Fix currency conversion#8

Open
wharris wants to merge 1 commit into
bjbech:masterfrom
wharris:invert-exchange-rates
Open

Fix currency conversion#8
wharris wants to merge 1 commit into
bjbech:masterfrom
wharris:invert-exchange-rates

Conversation

@wharris

@wharris wharris commented Sep 12, 2025

Copy link
Copy Markdown

Commit a1b9a67 added the country selection feature. The rates given in conversionRate.json were in currency/USD but script.js calculates the USD offset by multiplying the foreign currency offset by the conversion rate. The result was that converted offsets were incorrect. EUR and GBP offsets were converted to a too-low USD offset and CAD offsets were converted to a more generous USD offset. For example, £307.88 was calculated as $227.83 instead of $418.72.

This commit fixes the problem by reversing the sense of the rates in conversionRate.json so they are now in USD/currency. Within rounding, the reciprocals of the old rates were equal to the values I looked up at around 2025-09-12T18:30+00:00. I chose to change the data over changing the calculation to avoid any possibility of a division-by-zero.

Commit a1b9a67 added the country selection feature. The rates given in
conversionRate.json were in currency/USD but script.js calculates the
USD offset by multiplying the foreign currency offset by the conversion
rate. The result was that converted offsets were incorrect. EUR and GBP
offsets were converted to a too-low USD offset and CAD offsets were
converted to a more generous USD offset. For example, £307.88 was
calculated as $227.83 instead of $418.72.

This commit fixes the problem by reversing the sense of the rates in
conversionRate.json so they are now in USD/currency. Within rounding,
the reciprocals of the old rates were equal to the values I looked up at
around 2025-09-12T18:30+00:00. I chose to change the data over changing
the calculation to avoid any possibility of a division-by-zero.
@netlify

netlify Bot commented Sep 12, 2025

Copy link
Copy Markdown

Deploy Preview for themarcooffset ready!

Name Link
🔨 Latest commit 34c5f76
🔍 Latest deploy log https://app.netlify.com/projects/themarcooffset/deploys/68c46d688bf750000830d1c3
😎 Deploy Preview https://deploy-preview-8--themarcooffset.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant