diff --git a/app/controllers/savings_goals_controller.rb b/app/controllers/savings_goals_controller.rb index a4c4327bf..e35a2c3ab 100644 --- a/app/controllers/savings_goals_controller.rb +++ b/app/controllers/savings_goals_controller.rb @@ -20,7 +20,7 @@ class SavingsGoalsController < ApplicationController end def show - @contributions = @savings_goal.savings_contributions.includes(:account).chronological.limit(50) + @contributions = @savings_goal.savings_contributions.includes(:account).chronological @funding_breakdown = funding_breakdown_for(@savings_goal) @stats = stats_for(@savings_goal) end diff --git a/app/views/savings_goals/show.html.erb b/app/views/savings_goals/show.html.erb index e96301c73..323e7b0e7 100644 --- a/app/views/savings_goals/show.html.erb +++ b/app/views/savings_goals/show.html.erb @@ -202,29 +202,33 @@ <% end %> - <%# Stat row — combo pace card + contributions count %> -
- <%# Combo: Avg vs Target pace %> -
-

<%= t(".stats.monthly_pace") %>

-
-

<%= Money.new(@stats[:avg_monthly], @savings_goal.currency).format %>

-

/mo

- <% if @savings_goal.monthly_target_amount %> -

· <%= t(".stats.target_of", amount: Money.new(@savings_goal.monthly_target_amount, @savings_goal.currency).format) %>

+ <%# Stat row — combo pace card + contributions count. Reached goals + hide the pace combo since the comparison is moot. %> + <% goal_reached = @savings_goal.completed? || @savings_goal.status == :reached %> +
gap-3"> + <% unless goal_reached %> + <%# Combo: Avg vs Target pace %> +
+

<%= t(".stats.monthly_pace") %>

+
+

<%= Money.new(@stats[:avg_monthly], @savings_goal.currency).format %>

+

/mo

+ <% if @savings_goal.monthly_target_amount && @savings_goal.monthly_target_amount.to_d.positive? %> +

· <%= t(".stats.target_of", amount: Money.new(@savings_goal.monthly_target_amount, @savings_goal.currency).format) %>

+ <% end %> +
+ <% if @savings_goal.monthly_target_amount && @savings_goal.monthly_target_amount.to_d.positive? %> + <% delta = @savings_goal.monthly_target_amount.to_d - @stats[:avg_monthly].to_d %> + <% if delta.positive? %> +

<%= t(".stats.behind_by", amount: Money.new(delta, @savings_goal.currency).format) %>

+ <% else %> +

<%= t(".stats.above_target_pace") %>

+ <% end %> + <% else %> +

<%= t(".stats.no_required_pace") %>

<% end %>
- <% if @savings_goal.monthly_target_amount %> - <% delta = @savings_goal.monthly_target_amount.to_d - @stats[:avg_monthly].to_d %> - <% if delta.positive? %> -

<%= t(".stats.behind_by", amount: Money.new(delta, @savings_goal.currency).format) %>

- <% else %> -

<%= t(".stats.above_target_pace") %>

- <% end %> - <% else %> -

<%= t(".stats.no_required_pace") %>

- <% end %> -
+ <% end %> <%# Total contributions %>
@@ -241,7 +245,9 @@

<%= t(".contributions_heading") %>

<%= @contributions.size %>
- <%= render "contributions_list", contributions: @contributions %> +
+ <%= render "contributions_list", contributions: @contributions %> +