mirror of
https://github.com/we-promise/sure.git
synced 2026-04-18 19:44:09 +00:00
Refactor balance sheet weight calculation and improve group weight rendering
- Update BalanceSheet model to directly calculate account weights based on converted balances. - Modify dashboard view to compute account weight as a percentage of classification total, enhancing clarity. - Adjust group weight partial to handle effective weight, ensuring accurate rendering of weight representation.
This commit is contained in:
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user