diff --git a/app/models/balance_sheet.rb b/app/models/balance_sheet.rb index 9a3d43ea..8c2af0f3 100644 --- a/app/models/balance_sheet.rb +++ b/app/models/balance_sheet.rb @@ -60,7 +60,7 @@ class BalanceSheet key = accountable.model_name.param_key - AccountGroup.new( + group = AccountGroup.new( id: classification ? "#{classification}_#{key}_group" : "#{key}_group", key: key, name: accountable.display_name, @@ -72,13 +72,11 @@ class BalanceSheet color: accountable.color, syncing?: accounts.any?(&:is_syncing), accounts: accounts.map do |account| - account.define_singleton_method(:weight) do - classification_total.zero? ? 0 : account.converted_balance / classification_total.to_d * 100 - end - account - end.sort_by(&:weight).reverse + end.sort_by(&:converted_balance).reverse ) + + group end groups.sort_by do |group| diff --git a/app/views/pages/dashboard/_balance_sheet.html.erb b/app/views/pages/dashboard/_balance_sheet.html.erb index 7a71afe7..337e5268 100644 --- a/app/views/pages/dashboard/_balance_sheet.html.erb +++ b/app/views/pages/dashboard/_balance_sheet.html.erb @@ -116,7 +116,12 @@ <% else %>
<%= number_to_percentage(weight, precision: 2) %>
+<%= number_to_percentage(effective_weight, precision: 2) %>