Sort currencies by name as a second order #1216

Merged
alagos merged 1 commits from currency-sort into main 2024-10-01 22:48:39 +08:00
alagos commented 2024-09-30 13:35:37 +08:00 (Migrated from github.com)

The currency sorting is very chaotic only relying on the "priority"
Screenshot 2024-09-30 at 6 30 10 PM
so I've also set the "name" as a second order parameter
Screenshot 2024-09-30 at 6 30 32 PM

The currency sorting is very chaotic only relying on the "priority" <img width="403" alt="Screenshot 2024-09-30 at 6 30 10 PM" src="https://github.com/user-attachments/assets/682c1701-25e2-4f9a-9a15-0ed5a612d576"> so I've also set the "name" as a second order parameter <img width="435" alt="Screenshot 2024-09-30 at 6 30 32 PM" src="https://github.com/user-attachments/assets/598ad7c4-bf28-4be6-8cc4-40579d9862f2">
alagos commented 2024-09-30 16:27:54 +08:00 (Migrated from github.com)

BTW, related with the second screenshot, why does the "Belarusian Ruble" has a higher priority compared with other currencies? To me looks like an unintended error, so I was thinking to change it to 100 in this same PR, but maybe this Ruble is really very important in the world economy 🤷

BTW, related with the second screenshot, why does the "Belarusian Ruble" has [a higher priority](https://github.com/maybe-finance/maybe/blob/main/config/currencies.yml#L87) compared with other currencies? To me looks like an unintended error, so I was thinking to change it to 100 in this same PR, but maybe this Ruble is really very important in the world economy 🤷
zachgoll commented 2024-09-30 22:25:29 +08:00 (Migrated from github.com)

@alagos good idea, I think adding the name as a secondary sort is helpful.

In regards to the priorities of these currencies—there has not been a ton of work done around this yet and the few currencies that have been assigned a priority were a quick guess when we originally set up the list.

We'd be glad to accept any contribution that provides an updated priorities list given there is reasonable data to back up those changes.

@alagos good idea, I think adding the name as a secondary sort is helpful. In regards to the priorities of these currencies—there has not been a ton of work done around this yet and the few currencies that have been assigned a priority were a quick guess when we originally set up the list. We'd be glad to accept any contribution that provides an updated priorities list given there is reasonable data to back up those changes.
alagos commented 2024-10-01 13:40:33 +08:00 (Migrated from github.com)

Right, I'm not sure that I have in mind a reliable source of currency priorities (actually, I think is out of the scope of what I was thinking to fix here).

Right, I'm not sure that I have in mind a reliable source of currency priorities (actually, I think is out of the scope of what I was thinking to fix here).
ssjr commented 2024-10-01 21:47:00 +08:00 (Migrated from github.com)

I set up the project yesterday and started using it locally.
Set the default currency in http://localhost:3000/settings/preferences to "BRL". When I went to add accounts in http://localhost:3000/accounts the default currency was USD and I had to manually change it every time when creating an account.
image

image

Could it be like

  def currencies_for_select
    Money::Currency.all_instances.sort_by do |currency|
      family_currency = Current.family&.currency == currency.iso_code ? 0 : 1

      [ family_currency, currency.priority, currency.name ]
    end
  end
I set up the project yesterday and started using it locally. Set the default currency in http://localhost:3000/settings/preferences to "BRL". When I went to add accounts in http://localhost:3000/accounts the default currency was USD and I had to manually change it every time when creating an account. <img width="226" alt="image" src="https://github.com/user-attachments/assets/c42549d1-82e2-463e-b04b-304c10284e53"> <img width="561" alt="image" src="https://github.com/user-attachments/assets/912af77d-6c9f-4cc6-bedd-177c2b52b940"> Could it be like ```ruby def currencies_for_select Money::Currency.all_instances.sort_by do |currency| family_currency = Current.family&.currency == currency.iso_code ? 0 : 1 [ family_currency, currency.priority, currency.name ] end end ```
zachgoll commented 2024-10-01 22:48:49 +08:00 (Migrated from github.com)

@ssjr auto-population of the family currency is fixed now:

e8eb4b0eb9

@ssjr auto-population of the family currency is fixed now: https://github.com/maybe-finance/maybe/pull/1209/commits/e8eb4b0eb964c1ecf83fbaef51e46de2221695c1
Sign in to join this conversation.