Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Highlight current month in trends insights table (#448)

Mark Hendrikseneb762eff1205
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index e2661d0ba2..96f3f7c177 100644
--- a/app/controllers/reports_controller.rb
+++ b/app/controllers/reports_controller.rb
@@ -287,6 +287,7 @@ class ReportsController < ApplicationController
trends << {
month: month_start.strftime("%b %Y"),
+ is_current_month: (month_start.month == Date.current.month && month_start.year == Date.current.year),
income: income,
expenses: expenses,
net: income - expenses
diff --git a/app/views/reports/_trends_insights.html.erb b/app/views/reports/_trends_insights.html.erb
index 6b294cc9c3..0a02928c42 100644
--- a/app/views/reports/_trends_insights.html.erb
+++ b/app/views/reports/_trends_insights.html.erb
@@ -18,11 +18,11 @@
</tr>
</thead>
<tbody>
- <% trends_data.each_with_index do |trend, index| %>
- <tr class="border-b border-tertiary/50 <%= index == trends_data.length - 1 ? "font-medium" : "" %>">
+ <% trends_data.each do |trend| %>
+ <tr class="border-b border-tertiary/50 <%= trend[:is_current_month] ? "font-medium" : "" %>">
<td class="py-3 pr-4 text-primary">
<%= trend[:month] %>
- <% if index == trends_data.length - 1 %>
+ <% if trend[:is_current_month] %>
<span class="ml-2 text-xs text-tertiary">(<%= t("reports.trends.current") %>)</span>
<% end %>
</td>