2025-05-15 10:19:56 -04:00
|
|
|
<%# locals: (balance_sheet:, **args) %>
|
2025-02-21 11:57:59 -05:00
|
|
|
|
2025-05-15 10:19:56 -04:00
|
|
|
<div class="space-y-4" id="balance-sheet">
|
2025-02-21 11:57:59 -05:00
|
|
|
<% balance_sheet.classification_groups.each do |classification_group| %>
|
2025-04-11 09:28:00 -05:00
|
|
|
<div class="bg-container shadow-border-xs rounded-xl space-y-4 p-4">
|
2025-06-10 18:20:06 -04:00
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
<h2 class="text-lg font-medium inline-flex items-center gap-1.5">
|
|
|
|
<span>
|
|
|
|
<%= classification_group.name %>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<% if classification_group.account_groups.any? %>
|
|
|
|
<span class="text-secondary">·</span>
|
2025-05-15 10:19:56 -04:00
|
|
|
<span class="text-secondary font-medium text-lg"><%= classification_group.total_money.format(precision: 0) %></span>
|
|
|
|
<% end %>
|
2025-06-10 18:20:06 -04:00
|
|
|
</h2>
|
|
|
|
|
|
|
|
<% if classification_group.syncing? %>
|
|
|
|
<%= render partial: "shared/sync_indicator", locals: { size: "sm" } %>
|
2025-04-30 18:14:22 -04:00
|
|
|
<% end %>
|
2025-06-10 18:20:06 -04:00
|
|
|
</div>
|
2025-02-21 11:57:59 -05:00
|
|
|
|
|
|
|
<% if classification_group.account_groups.any? %>
|
|
|
|
<div class="space-y-4">
|
|
|
|
<div class="flex gap-1">
|
|
|
|
<% classification_group.account_groups.each do |account_group| %>
|
|
|
|
<div class="h-1.5 rounded-sm" style="width: <%= account_group.weight %>%; background-color: <%= account_group.color %>;"></div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2025-05-15 10:19:56 -04:00
|
|
|
|
2025-06-10 18:20:06 -04:00
|
|
|
<div class="flex flex-wrap gap-4">
|
|
|
|
<% classification_group.account_groups.each do |account_group| %>
|
|
|
|
<div class="flex items-center gap-2 text-sm">
|
|
|
|
<div class="h-2.5 w-2.5 rounded-full" style="background-color: <%= account_group.color %>;"></div>
|
|
|
|
<p class="text-secondary"><%= account_group.name %></p>
|
|
|
|
<p class="text-primary font-mono"><%= number_to_percentage(account_group.weight, precision: 0) %></p>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2025-02-21 11:57:59 -05:00
|
|
|
</div>
|
|
|
|
|
2025-04-30 18:14:22 -04:00
|
|
|
<div class="bg-surface rounded-xl p-1 space-y-1 overflow-x-auto">
|
2025-02-21 11:57:59 -05:00
|
|
|
<div class="px-4 py-2 flex items-center uppercase text-xs font-medium text-secondary">
|
2025-04-30 18:14:22 -04:00
|
|
|
<div class="w-40">Name</div>
|
2025-02-21 11:57:59 -05:00
|
|
|
<div class="ml-auto text-right flex items-center gap-6">
|
|
|
|
<div class="w-24">
|
|
|
|
<p>Weight</p>
|
|
|
|
</div>
|
|
|
|
<div class="w-40">
|
|
|
|
<p>Value</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2025-05-22 10:35:55 -05:00
|
|
|
<div class="shadow-border-xs rounded-lg bg-container font-medium text-sm min-w-fit">
|
|
|
|
<% classification_group.account_groups.each_with_index do |account_group, idx| %>
|
|
|
|
<details class="group open:bg-surface
|
|
|
|
<%= idx == 0 ? "rounded-t-lg" : "" %>
|
|
|
|
<%= idx == classification_group.account_groups.size - 1 ? "rounded-b-lg" : "" %>
|
|
|
|
">
|
|
|
|
<summary class="cursor-pointer p-4 group-open:bg-surface rounded-lg flex items-center justify-between">
|
2025-04-30 18:14:22 -04:00
|
|
|
<div class="w-40 shrink-0 flex items-center gap-4">
|
|
|
|
<%= icon("chevron-right", class: "group-open:rotate-90") %>
|
2025-02-21 11:57:59 -05:00
|
|
|
|
|
|
|
<p><%= account_group.name %></p>
|
|
|
|
</div>
|
|
|
|
|
2025-06-10 18:20:06 -04:00
|
|
|
<div class="flex items-center justify-between text-right gap-6">
|
|
|
|
<div class="w-28 shrink-0 flex items-center justify-end gap-2">
|
|
|
|
<%= render "pages/dashboard/group_weight", weight: account_group.weight, color: account_group.color %>
|
2025-02-21 11:57:59 -05:00
|
|
|
</div>
|
|
|
|
|
2025-06-10 18:20:06 -04:00
|
|
|
<div class="w-40 shrink-0">
|
|
|
|
<p><%= format_money(account_group.total_money) %></p>
|
2025-02-21 11:57:59 -05:00
|
|
|
</div>
|
2025-06-10 18:20:06 -04:00
|
|
|
</div>
|
2025-02-21 11:57:59 -05:00
|
|
|
</summary>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<% account_group.accounts.each_with_index do |account, idx| %>
|
2025-05-22 10:35:55 -05:00
|
|
|
<div class="pl-12 pr-4 py-3 flex items-center justify-between text-sm font-medium">
|
2025-04-30 18:14:22 -04:00
|
|
|
<div class="flex items-center gap-3">
|
2025-02-21 11:57:59 -05:00
|
|
|
<%= render "accounts/logo", account: account, size: "sm", color: account_group.color %>
|
2025-04-30 18:14:22 -04:00
|
|
|
|
2025-02-21 11:57:59 -05:00
|
|
|
<%= link_to account.name, account_path(account) %>
|
|
|
|
</div>
|
|
|
|
|
2025-06-10 18:20:06 -04:00
|
|
|
<div class="ml-auto flex items-center text-right gap-6">
|
|
|
|
<div class="w-28 shrink-0 flex items-center justify-end gap-2">
|
|
|
|
<%
|
2025-05-23 12:25:18 -05:00
|
|
|
# Calculate weight as percentage of classification total
|
|
|
|
classification_total = classification_group.total_money.amount
|
|
|
|
account_weight = classification_total.zero? ? 0 : account.converted_balance / classification_total * 100
|
2025-06-15 10:09:46 -04:00
|
|
|
%>
|
2025-06-10 18:20:06 -04:00
|
|
|
<%= render "pages/dashboard/group_weight", weight: account_weight, color: account_group.color %>
|
|
|
|
</div>
|
2025-05-15 10:19:56 -04:00
|
|
|
|
2025-06-10 18:20:06 -04:00
|
|
|
<div class="w-40 shrink-0">
|
|
|
|
<p><%= format_money(account.balance_money) %></p>
|
2025-05-15 10:19:56 -04:00
|
|
|
</div>
|
2025-06-10 18:20:06 -04:00
|
|
|
</div>
|
2025-02-21 11:57:59 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<% if idx < account_group.accounts.size - 1 %>
|
2025-05-20 14:13:18 -05:00
|
|
|
<%= render "shared/ruler", classes: "ml-21 mr-4" %>
|
2025-02-21 11:57:59 -05:00
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</details>
|
2025-05-22 10:35:55 -05:00
|
|
|
<% unless idx == classification_group.account_groups.size - 1 %>
|
|
|
|
<%= render "shared/ruler", classes: "mx-4 group-ruler" %>
|
|
|
|
<% end %>
|
2025-02-21 11:57:59 -05:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<% else %>
|
2025-04-30 18:14:22 -04:00
|
|
|
<div class="py-10 flex flex-col items-center">
|
|
|
|
<%= render FilledIconComponent.new(
|
|
|
|
variant: :container,
|
|
|
|
icon: classification_group.icon,
|
|
|
|
) %>
|
|
|
|
|
2025-06-10 21:30:53 -04:00
|
|
|
<p class="text-primary text-sm font-medium mb-1 mt-4">No <%= classification_group.name %> yet</p>
|
|
|
|
<p class="text-secondary text-sm text-center"><%= "Add your #{classification_group.name} accounts to see a full breakdown" %></p>
|
2025-02-21 11:57:59 -05:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2025-05-22 10:35:55 -05:00
|
|
|
|
|
|
|
<%# Custom style for hiding ruler when details are open %>
|
|
|
|
<style>
|
|
|
|
details[open] + .group-ruler {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|