diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index 54ec09faa61..d1935aefbcc 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -37,4 +37,11 @@ def class_mapping(accountable_type) "Vehicle" => { text: "text-pink-500", bg: "bg-pink-500", bg_transparent: "bg-pink-500/10", fill: "fill-pink-500", hex: "#F23E94" } }.fetch(accountable_type, { text: "text-gray-500", bg: "bg-gray-500", bg_transparent: "bg-gray-500/10", fill: "fill-gray-500", hex: "#737373" }) end + + def format_accounts_balance(accounts, options = {}) + accounts.group_by(&:currency) + .transform_values { |acc| acc.sum(&:balance_money) } + .map { |_currency, balance| balance.to_s } + .join(", ") + end end diff --git a/app/views/accounts/_accountable_group.html.erb b/app/views/accounts/_accountable_group.html.erb index 199c8fe1252..b958183df45 100644 --- a/app/views/accounts/_accountable_group.html.erb +++ b/app/views/accounts/_accountable_group.html.erb @@ -6,7 +6,7 @@
<%= to_accountable_title(Accountable.from_type(group)) %>
·<%= accounts.count %>
-<%= format_money accounts.sum(&:balance_money) %>
+<%= format_accounts_balance(accounts) %>