diff --git a/app/views/pages/dashboard/_investment_summary.html.erb b/app/views/pages/dashboard/_investment_summary.html.erb index ef5d7222e..bfae9c502 100644 --- a/app/views/pages/dashboard/_investment_summary.html.erb +++ b/app/views/pages/dashboard/_investment_summary.html.erb @@ -28,40 +28,44 @@ <% holdings = investment_statement.top_holdings(limit: 5) %> <% if holdings.any? %>
-
-
-
<%= t(".holding") %>
-
<%= t(".weight") %>
-
<%= t(".value") %>
-
<%= t(".return") %>
-
- -
+
+ + + + + + + + + + <% holdings.each_with_index do |holding, idx| %> -
"> -
- <% if holding.security.logo_url.present? %> - <%= holding.ticker %> - <% else %> -
- <%= holding.ticker.to_s.first(2).presence || "—" %> +
"> + -
+
-
+
-
+
+ <% end %> - + +
<%= t(".holding") %><%= t(".weight") %><%= t(".value") %><%= t(".return") %>
+
+ <% if holding.security.logo_url.present? %> + <%= holding.ticker %> + <% else %> +
+ <%= holding.ticker.to_s.first(2).presence || "—" %> +
+ <% end %> +
+

<%= holding.ticker %>

+

<%= truncate(holding.name, length: 20) %>

- <% end %> -
-

<%= holding.ticker %>

-

<%= truncate(holding.name, length: 20) %>

-
+
<%= number_to_percentage(holding.weight || 0, precision: 1) %> - + <%= format_money(holding.amount_money) %> - + <% if holding.trend %> <%= holding.trend.percent_formatted %> @@ -69,10 +73,11 @@ <% else %> - <% end %> - - +
<% end %> diff --git a/app/views/reports/_breakdown_table.html.erb b/app/views/reports/_breakdown_table.html.erb index 3377e2864..ff3141557 100644 --- a/app/views/reports/_breakdown_table.html.erb +++ b/app/views/reports/_breakdown_table.html.erb @@ -15,30 +15,30 @@
-
-
-
<%= t("reports.transactions_breakdown.table.category") %>
-
- <%= link_to reports_path(amount_sort_params), class: "inline-flex items-center gap-1 hover:text-primary" do %> - <%= t("reports.transactions_breakdown.table.amount") %> - <% if current_sort_by == "amount" %> - <%= icon(current_sort_direction == "desc" ? "chevron-down" : "chevron-up", class: "w-3 h-3") %> +
+ + + + + + + + + <% groups.each_with_index do |group, idx| %> <%= render "reports/category_row", item: group, total: total, color_class: color_class, - level: :category %> - <% if idx < groups.size - 1 %> - <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> - <% end %> + level: :category, + show_border: idx < groups.size - 1 || group[:subcategories].present? %> <%# Render subcategories if present %> <% if group[:subcategories].present? && group[:subcategories].any? %> <% group[:subcategories].each_with_index do |subcategory, sub_idx| %> @@ -46,14 +46,13 @@ item: subcategory, total: total, color_class: color_class, - level: :subcategory %> - <% if sub_idx < group[:subcategories].size - 1 %> - <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> - <% end %> + level: :subcategory, + show_border: sub_idx < group[:subcategories].size - 1 %> <% end %> <% end %> <% end %> - + +
<%= t("reports.transactions_breakdown.table.category") %> + <%= link_to reports_path(amount_sort_params), class: "inline-flex items-center gap-1 hover:text-primary" do %> + <%= t("reports.transactions_breakdown.table.amount") %> + <% if current_sort_by == "amount" %> + <%= icon(current_sort_direction == "desc" ? "chevron-down" : "chevron-up", class: "w-3 h-3") %> + <% end %> <% end %> - <% end %> - -
<%= t("reports.transactions_breakdown.table.percentage") %>
- - -
+
<%= t("reports.transactions_breakdown.table.percentage") %>
diff --git a/app/views/reports/_category_row.html.erb b/app/views/reports/_category_row.html.erb index 80c31245a..dbc15afca 100644 --- a/app/views/reports/_category_row.html.erb +++ b/app/views/reports/_category_row.html.erb @@ -1,50 +1,53 @@ <% percentage = total.zero? ? 0 : (item[:total].to_f / total * 100).round(1) is_sub = level == :subcategory + show_border = local_assigns.fetch(:show_border, false) %> -
"> -
- <% if is_sub %> -
- <%= icon "corner-down-right" %> -
- <% end %> - <% if item[:category_icon] %> -
- <%= icon(item[:category_icon], color: "current", size: "sm") %> -
- <% else %> - <%= render DS::FilledIcon.new( - variant: :text, - hex_color: item[:category_color], - text: item[:category_name], - size: "md", - rounded: true - ) %> - <% end %> - - <%= item[:category_name] %> - - - (<%= t("reports.transactions_breakdown.table.entries", count: item[:count]) %>) - -
+"> + "> +
+ <% if is_sub %> +
+ <%= icon "corner-down-right" %> +
+ <% end %> + <% if item[:category_icon] %> +
+ <%= icon(item[:category_icon], color: "current", size: "sm") %> +
+ <% else %> + <%= render DS::FilledIcon.new( + variant: :text, + hex_color: item[:category_color], + text: item[:category_name], + size: "md", + rounded: true + ) %> + <% end %> + + <%= item[:category_name] %> + + + (<%= t("reports.transactions_breakdown.table.entries", count: item[:count]) %>) + +
+ -
+ <%= Money.new(item[:total], Current.family.currency).format %> -
+ -
+ <%= percentage %>% -
-
+ + diff --git a/app/views/reports/_investment_performance.html.erb b/app/views/reports/_investment_performance.html.erb index e50c2b8ea..7434ab923 100644 --- a/app/views/reports/_investment_performance.html.erb +++ b/app/views/reports/_investment_performance.html.erb @@ -60,33 +60,39 @@

<%= t("reports.investment_performance.top_holdings") %>

-
-
<%= t("reports.investment_performance.holding") %>
-
<%= t("reports.investment_performance.weight") %>
-
<%= t("reports.investment_performance.value") %>
-
<%= t("reports.investment_performance.return") %>
-
-
+
+ + + + + + + + + + <% investment_metrics[:top_holdings].each_with_index do |holding, idx| %> -
-
- <% if holding.security.brandfetch_icon_url.present? %> - <%= holding.ticker %> - <% elsif holding.security.logo_url.present? %> - <%= holding.ticker %> - <% else %> -
- <%= holding.ticker[0..1] %> +
"> + + + + + <% end %> - + +
<%= t("reports.investment_performance.holding") %><%= t("reports.investment_performance.weight") %><%= t("reports.investment_performance.value") %><%= t("reports.investment_performance.return") %>
+
+ <% if holding.security.brandfetch_icon_url.present? %> + <%= holding.ticker %> + <% elsif holding.security.logo_url.present? %> + <%= holding.ticker %> + <% else %> +
+ <%= holding.ticker[0..1] %> +
+ <% end %> +
+

<%= holding.ticker %>

+

<%= truncate(holding.name, length: 25) %>

- <% end %> -
-

<%= holding.ticker %>

-

<%= truncate(holding.name, length: 25) %>

-
-
<%= number_to_percentage(holding.weight || 0, precision: 1) %>
-
<%= format_money(holding.amount_money) %>
-
+
<%= number_to_percentage(holding.weight || 0, precision: 1) %><%= format_money(holding.amount_money) %> <% if holding.trend %> <%= holding.trend.percent_formatted %> @@ -94,13 +100,12 @@ <% else %> <%= t("reports.investment_performance.no_data") %> <% end %> - - - <% if idx < investment_metrics[:top_holdings].size - 1 %> - <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> - <% end %> +
+
diff --git a/app/views/reports/_net_worth.html.erb b/app/views/reports/_net_worth.html.erb index 0ed1dc2b3..153090bf8 100644 --- a/app/views/reports/_net_worth.html.erb +++ b/app/views/reports/_net_worth.html.erb @@ -40,43 +40,55 @@
<%# Assets Summary %>
-
-
<%= t("reports.net_worth.total_assets") %>
-
-
- <% net_worth_metrics[:asset_groups].each_with_index do |group, idx| %> -
-
<%= group[:name] %>
-
<%= group[:total].format %>
-
- <% if idx < net_worth_metrics[:asset_groups].size - 1 %> - <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> +
+ + + + + + + + + <% net_worth_metrics[:asset_groups].each_with_index do |group, idx| %> + "> + + + <% end %> - <% end %> - <% if net_worth_metrics[:asset_groups].empty? %> -

<%= t("reports.net_worth.no_assets") %>

- <% end %> + <% if net_worth_metrics[:asset_groups].empty? %> + + + + <% end %> + +
<%= t("reports.net_worth.total_assets") %><%= t("reports.transactions_breakdown.table.amount") %>
<%= group[:name] %><%= group[:total].format %>
<%= t("reports.net_worth.no_assets") %>
<%# Liabilities Summary %>
-
-
<%= t("reports.net_worth.total_liabilities") %>
-
-
- <% net_worth_metrics[:liability_groups].each_with_index do |group, idx| %> -
-
<%= group[:name] %>
-
<%= group[:total].format %>
-
- <% if idx < net_worth_metrics[:liability_groups].size - 1 %> - <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> +
+ + + + + + + + + <% net_worth_metrics[:liability_groups].each_with_index do |group, idx| %> + "> + + + <% end %> - <% end %> - <% if net_worth_metrics[:liability_groups].empty? %> -

<%= t("reports.net_worth.no_liabilities") %>

- <% end %> + <% if net_worth_metrics[:liability_groups].empty? %> + + + + <% end %> + +
<%= t("reports.net_worth.total_liabilities") %><%= t("reports.transactions_breakdown.table.amount") %>
<%= group[:name] %><%= group[:total].format %>
<%= t("reports.net_worth.no_liabilities") %>
diff --git a/app/views/reports/_trends_insights.html.erb b/app/views/reports/_trends_insights.html.erb index 419341853..a0111fa28 100644 --- a/app/views/reports/_trends_insights.html.erb +++ b/app/views/reports/_trends_insights.html.erb @@ -8,41 +8,46 @@ <% if trends_data.any? %>
-
-
<%= t("reports.trends.month") %>
-
<%= t("reports.trends.income") %>
-
<%= t("reports.trends.expenses") %>
-
<%= t("reports.trends.net") %>
-
<%= t("reports.trends.savings_rate") %>
-
-
+
+ + + + + + + + + + + <% trends_data.each_with_index do |trend, idx| %> -
-
"> - <%= trend[:month] %> - <% if trend[:is_current_month] %> - (<%= t("reports.trends.current") %>) - <% end %> -
-
+
"> + + + + + + <% end %> - + +
<%= t("reports.trends.month") %><%= t("reports.trends.income") %><%= t("reports.trends.expenses") %><%= t("reports.trends.net") %><%= t("reports.trends.savings_rate") %>
+
diff --git a/test/controllers/reports_controller_test.rb b/test/controllers/reports_controller_test.rb index 6f041c0da..c53472e99 100644 --- a/test/controllers/reports_controller_test.rb +++ b/test/controllers/reports_controller_test.rb @@ -82,8 +82,8 @@ class ReportsControllerTest < ActionDispatch::IntegrationTest get reports_path(period_type: :monthly) assert_response :ok assert_select "h2", text: I18n.t("reports.trends.title") - assert_select '[role="columnheader"]' do - assert_select "div", text: I18n.t("reports.trends.month") + assert_select "thead" do + assert_select "th", text: I18n.t("reports.trends.month") end end @@ -239,10 +239,10 @@ class ReportsControllerTest < ActionDispatch::IntegrationTest assert_response :ok # Parent category - assert_select "div[data-category='category-#{parent_category.id}']", text: /^Entertainment/ + assert_select "tr[data-category='category-#{parent_category.id}']", text: /^Entertainment/ # Subcategories - assert_select "div[data-category='category-#{subcategory_movies.id}']", text: /^Movies/ - assert_select "div[data-category='category-#{subcategory_games.id}']", text: /^Games/ + assert_select "tr[data-category='category-#{subcategory_movies.id}']", text: /^Movies/ + assert_select "tr[data-category='category-#{subcategory_games.id}']", text: /^Games/ end end