Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
2.3 KB
Raw Blame
<%# locals: (totals:, transactions_count:) %>
<%# Show Inflow/Outflow labels only when the result set contains exclusively transfers
    (income and expense are both $0). For mixed filters (e.g. Expense+Transfer),
    we keep Income/Expenses labels — transfer amounts aren't included in the summary
    bar in that case, though the transaction list still shows both types. %>
<% show_transfers = totals.income_money.zero? && totals.expense_money.zero? &&
   (totals.transfer_inflow_money.amount > 0 || totals.transfer_outflow_money.amount > 0) %>
<div class="grid grid-cols-1 md:grid-cols-3 bg-container rounded-xl shadow-border-xs md:divide-x divide-y md:divide-y-0 divide-alpha-black-100 theme-dark:divide-alpha-white-200">
  <div class="p-4 space-y-2">
    <p class="text-sm text-secondary"><%= t("transactions.summary.total_transactions") %></p>
    <p class="text-primary font-medium text-xl privacy-sensitive" id="total-transactions"><%= transactions_count %></p>
    <% if totals.excluded_scheduled_count.positive? %>
      <p class="text-xs text-secondary" id="scheduled-transactions-count"><%= t("transactions.summary.scheduled_count", count: totals.excluded_scheduled_count) %></p>
    <% end %>
  </div>
  <div class="p-4 space-y-2">
    <% if show_transfers %>
      <p class="text-sm text-secondary"><%= t("transactions.summary.inflow") %></p>
      <p class="text-primary font-medium text-xl privacy-sensitive" id="total-income">
        <%= (totals.income_money + totals.transfer_inflow_money).format %>
      </p>
    <% else %>
      <p class="text-sm text-secondary"><%= t("transactions.summary.income") %></p>
      <p class="text-primary font-medium text-xl privacy-sensitive" id="total-income">
        <%= totals.income_money.format %>
      </p>
    <% end %>
  </div>
  <div class="p-4 space-y-2">
    <% if show_transfers %>
      <p class="text-sm text-secondary"><%= t("transactions.summary.outflow") %></p>
      <p class="text-primary font-medium text-xl privacy-sensitive" id="total-expense">
        <%= (totals.expense_money + totals.transfer_outflow_money).format %>
      </p>
    <% else %>
      <p class="text-sm text-secondary"><%= t("transactions.summary.expenses") %></p>
      <p class="text-primary font-medium text-xl privacy-sensitive" id="total-expense">
        <%= totals.expense_money.format %>
      </p>
    <% end %>
  </div>
</div>