Skip to content

Add main currency code for groups#329

Merged
Petersmit27 merged 2 commits intospliit-app:mainfrom
whimcomp:group-currency-code
Sep 5, 2025
Merged

Add main currency code for groups#329
Petersmit27 merged 2 commits intospliit-app:mainfrom
whimcomp:group-currency-code

Conversation

@whimcomp
Copy link
Contributor

This change is to be able to define an optional main currency selection to groups, for the conversion rate feature, based on this comment.
Group form with currency field
Currency selector

Originally this PR was supposed to be part of the currency conversion feature, but the PR would have been a bit large.

Feature

Currency code in a group influences how amounts are displayed and handled in transactions. The "amount" value is treated as the number of minor units in the currency. For example, "1500" is treated as "$15.00" if the currency is USD, but "ISK 1500" if the currency is ISK (as some currencies like ISK, JPY do not have any cents).

Choosing a currency also enables display of the amounts with the correct symbol according to the locale.
For example:

display of chinese yuan in English
display of chinese yuan in Chinese

The supported currencies are the listed currencies in Frankfurter as of this 20th April 2025.

The "currency-list" package is used to generate the json containing all the currency data as well as all the translations.
The json data can be regenerated with npm run generate-currency-data (useful when another currency or language is added in the future)

Groups without a currency code

The currency code will be undefined for all previous groups. If it is undefined, the currency symbol is required and will be used for display.
All displays will be done with a "fictional" currency defined with 100 minor units (cents) for a major unit (like Euros), this was the previous behaviour.

If the original amounts in the group were in a currency with cents, adding a currency code with cents should not have any problems.
However, if the original amounts were in a currency without cents, adding a currency will result in the amounts being 100 times higher.
For the same reason, if a currency without cents was used, and the currency code is then set to Custom, the amounts will be 100 times lower.

I haven't found a satisfying solution other to recommend not to change between currencies with different lengths.

Let me know what you think!

@caramelmelmel
Copy link

let the group add different currencies
people travelling with folks from different countries also matters here

@lance505
Copy link

bumping for attention, had been interested in this feature for a while and have been testing this PR along with #330 through a fork. haven't noticed any bugs so far and using it to plan for an overseas trip has saved a lot of hassle concerning conversions and rates

@caramelmelmel from what I saw you can set any currency of your choice for an expense, so anyone is free to input their own country's currency, the group currency mostly works to summarize all expenses into a common currency for the sake of readability and to display balances. correct me if I'm wrong, but I think this already does what you are asking for

@Petersmit27
Copy link
Collaborator

When a group's currency is changed to one with a different number of decimal_digits, you'd have to go through all existing expenses and change each one I think.

For now, we can just keep it the way it is and add a warning about this behaviour when someone attempts an edit such as this.

Petersmit27 added a commit that referenced this pull request Sep 5, 2025
Clarify group currency field description

Use default currency code instead of symbol

Hide currency symbol field when using a non-custom Currency

Run prettier

Update currency data

Update package-lock.json
@Petersmit27 Petersmit27 merged commit da84734 into spliit-app:main Sep 5, 2025
@whimcomp
Copy link
Contributor Author

When a group's currency is changed to one with a different number of decimal_digits, you'd have to go through all existing expenses and change each one I think.

For now, we can just keep it the way it is and add a warning about this behaviour when someone attempts an edit such as this.

My main worry was for (big) previous groups using a currency without cents before this change, and wanting to opt-in by selecting their currency code, to then find all of their displayed amounts multiplied by 100. I'm not sure how widespread of a problem that would be, or how many groups on spliit use such a currency.

I thought of having some sort of one-time prompt to detect whether all group expenses are whole (i.e. never use any cents), and proposing to normalize all the expense values in such a case a currency without cents is selected, but it feels overkill and maybe not really needed (could just start a new group?).

Thanks a lot for the review!

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.

4 participants