mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
* Fix separators in breakdown table view Correct conditional logic for rendering column separators (rulers) in the reports breakdown table. The top-level check now compares idx to groups.size instead of group.size, and the subcategory check compares idx to group[:subcategories].size. This ensures separators are shown between categories and subcategories correctly, avoiding missing or extra rulers. * Fix subcategory index variable name in partial Rename the inner loop index from `idx` to `sub_idx` in app/views/reports/_breakdown_table.html.erb to avoid shadowing the outer `idx`. This ensures the conditional that renders the separator (`shared/ruler`) uses the correct index for subcategories, preventing incorrect rendering of separators between subcategory rows. * Fix conditional block order in breakdown table Reorder ERB tags to properly nest the subcategory conditional and the ruler render in the reports breakdown partial. This ensures the divider is only rendered between subcategories and prevents mismatched ERB/end tags that could break template rendering.
62 lines
2.7 KiB
Plaintext
62 lines
2.7 KiB
Plaintext
<%# Renders a breakdown table for income or expense groups %>
|
|
<%# Local variables: groups, total, type (:income or :expense), amount_sort_params, current_sort_by, current_sort_direction %>
|
|
|
|
<%
|
|
color_class = type == :income ? "text-success" : "text-destructive"
|
|
icon_name = type == :income ? "trending-up" : "trending-down"
|
|
title_key = type == :income ? "reports.transactions_breakdown.table.income" : "reports.transactions_breakdown.table.expense"
|
|
%>
|
|
|
|
<div>
|
|
<div class="text-large mb-4 flex items-center gap-2 text-lg">
|
|
<%= icon(icon_name, class: "w-5 h-5") %>
|
|
<span><%= t(title_key) %>:</span>
|
|
<span class="font-medium text-secondary <%= color_class %>"> <%= Money.new(total, Current.family.currency).format %></span>
|
|
</div>
|
|
|
|
<div class="bg-container-inset rounded-xl p-1 overflow-x-auto">
|
|
<div class="w-max sm:w-full">
|
|
<div class="grid grid-cols-4 items-center uppercase text-xs font-medium text-secondary px-4 py-2">
|
|
<div class="col-span-2 font-medium text-secondary"><%= t("reports.transactions_breakdown.table.category") %></div>
|
|
<div class="col-span-1 text-right font-medium text-secondary">
|
|
<%= 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 %>
|
|
</div>
|
|
<div class="col-span-1 text-right font-medium text-secondary"><%= t("reports.transactions_breakdown.table.percentage") %></div>
|
|
</div>
|
|
|
|
<div class="bg-container rounded-lg shadow-border-xs">
|
|
<% 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 %>
|
|
<%# Render subcategories if present %>
|
|
<% if group[:subcategories].present? && group[:subcategories].any? %>
|
|
<% group[:subcategories].each_with_index do |subcategory, sub_idx| %>
|
|
<%= render "reports/category_row",
|
|
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 %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|