Skip to content

Conversation

@PeaTree-maker
Copy link

@PeaTree-maker PeaTree-maker commented Jan 18, 2026

Description

Adds user-configurable currency preference to display amounts in their preferred currency.

Changes Made

Backend

  • Added currency column to users table with migration (defaults to USD)
  • Updated AuthResponse to include currency field
  • Added /api/auth/change-currency endpoint
  • Updated all auth endpoints to return currency
  • Updated OpenAPI documentation

Frontend

  • Created currency formatter utility (lib/currency.ts)
  • Created useCurrency hook for easy component usage
  • Added currency selector in Settings page (separate card)
  • Updated all display components to format currency

Supported Currencies

USD ($), EUR (€), GBP (£), JPY (¥), CAD (C$), AUD (A$), CHF, CNY (¥), INR (₹)

Testing

  • New users default to USD
  • Users can change currency in Settings
  • All amounts display correctly in selected currency
  • Currency preference persists across sessions
  • Uses proper locale-based formatting
Screenshot 2026-01-18 120546 image

Copy link
Owner

@cachebag cachebag left a comment

Choose a reason for hiding this comment

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

Please ensure CI passes too!

Comment on lines 247 to 257
// ADDED: Fetch currency
let currency: (String,) = sqlx::query_as("SELECT currency FROM users WHERE id = ?")
.bind(claims.sub)
.fetch_one(&pool)
.await?;

Ok(Json(AuthResponse {
id: claims.sub,
username: payload.new_username,
currency: currency.0, // ADDED
}))
Copy link
Owner

Choose a reason for hiding this comment

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

The // ADDED comments don't seem to be needed? Same with line 184 above.

Copy link
Author

Choose a reason for hiding this comment

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

Removed on latest PR

Comment on lines 373 to 378
#[derive(Deserialize, ToSchema, Validate)]
pub struct ChangeCurrencyRequest {
#[validate(length(min = 3, max = 3))]
pub currency: String,
}

Copy link
Owner

Choose a reason for hiding this comment

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

This allows any three-character string (e.g. "FOO", "BAR", "$$$"). The backend should not accept values outside the supported currency set enforced by your frontend changes

.execute(&pool)
.await?;

let user: (String,) = sqlx::query_as("SELECT username FROM users WHERE id = ?")
Copy link
Owner

Choose a reason for hiding this comment

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

I don't know that this is necessary. We already do this?

const response = await api.auth.changeCurrency(...)
updateCurrency(response.currency)

username is ignored. I'm pretty sure we can just omit it.

@PeaTree-maker
Copy link
Author

Ran CI tests locally and everything was fine - will take a look tomorrow 🙃

ps what features are you looking to add? I noticed 2 others submitted currency features

I’m working on:

Multiple accounts
JSON/CSV transaction import
Auto categorisation

@cachebag
Copy link
Owner

ps what features are you looking to add? I noticed 2 others submitted currency features

Yeah, a couple others decided to implement this. If this PR was a bit cleaner, I'd consider merging but it looks like one of the others ones handle this a bit better.

Multiple accounts

This is already implemented, unless I am misunderstanding what you mean by "multiple accounts".

JSON/CSV transaction import

This is also already implemented, albeit for JSON only. Can't imagine CSV format is needed.

Auto categorisation

This would be a cool addition, I'd be happy to review that PR.

@cachebag cachebag marked this pull request as draft January 18, 2026 22:56
@cachebag
Copy link
Owner

Closing in favor #18

@cachebag cachebag closed this Jan 21, 2026
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.

2 participants