Skip to content

Render Wise transfers in the correct currency #11258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

davidcornu
Copy link
Member

@davidcornu davidcornu commented Aug 7, 2025

Summary of the problem

We are incorrectly rendering Wise transfer amounts in non-USD currencies as USD.

Describe your changes

Add special handling for Wise transfers:

  1. Render the ledger amount (same as wires)
  2. If the transfer isn't in USD, show the original amount in a tooltip
    CleanShot 2025-08-11 at 13 30 08@2x

@davidcornu davidcornu requested review from a team as code owners August 7, 2025 20:33
Comment on lines 137 to 159
<td style="text-align: right;">
<% if d.is_a? Wire %>
<% case d %>
<% when Wire %>
<%= render_money(d.local_hcb_code.amount_cents.abs) %>
<% when WiseTransfer %>
<% if d.currency == "USD" %>
<%= render_money(d.usd_amount || d.amount) %>
<% else %>
<% fx_tooltip = capture do %>
<% if d.usd_amount_cents %>
<%= render_money(d.usd_amount_cents) %>
<% elsif d.quoted_usd_amount_cents %>
Quoted <%= render_money(d.quoted_usd_amount_cents) %>
<% else %>
No USD amount
<% end %>
<% end %>

<span class="tooltipped tooltipped--w inline-block" aria-label="<%= fx_tooltip %>">
<%= d.amount.format(with_currency: true) %>
</span>
<% end %>
<% else %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the pattern should match the wire pattern?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first thought but I wasn't sure d.local_hcb_code.amount_cents would be populated.

  1. The only non-nullable field on WiseTransfer is amount_cents which can be in any number of currencies and is populated when the transfer is created
    • _cents is a misnomer as it technically stores subunits (e.g. JPY 1000 would be stored as 1000 as it is non-fractional)
  2. quoted_usd_amount_cents (nullable) is populated after a call to the Wise API (but might change?)
  3. usd_amount_cents (nullable) is populated by ops when the transfer is processed

As far as I can tell we don't have any validation on the presence of either (3) or (4). quoted_usd_amount_cents is populated on creation and synced to the canonical pending transaction and subsequently replaced by usd_amount_cents (if present).

So in theory, we should be fine relying on the canonical pending transaction but

  1. I would like to see stronger validations for all of the above
  2. We would probably want to show the original currency (maybe in a tooltip) as that's what the user entered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on validations but d.local_hcb_code.amount_cents should always be set. I'm cool with either product direction - @YodaLightsabr got thoughts? I'd just like us to be consistent with what we do for wires.

Copy link
Contributor

@YodaLightsabr YodaLightsabr Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer making the USD amount more prominent, but we should show the local amount in a tooltip. I will say that wherever we're rendering the USD amount, we should use the HCB code amount because that will always match the transaction amount on the ledger.

_cents is a misnomer as it technically stores subunits (e.g. JPY 1000 would be stored as 1000 as it is non-fractional)

This is true, however I believe this is the terminology used by the money-rails gem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

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.

3 participants