Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
2.0 KB
Raw Blame
<%# locals: (suggested:, income: false) %>
<%# Detection proposes, the user disposes. Rendered from both the Bills
    overview and Settings -> Recurring, so every key is absolutely scoped.

    Collapsible because this sits above the bills the user actually came to
    see. Someone who is not ready to triage nine guesses should be able to fold
    them away and still find their rent, and have that stick. %>
<%
  title, confirm, dismiss = if income
    [ t("recurring_transactions.suggested_income.title"), t("recurring_transactions.suggested_income.confirm"), t("recurring_transactions.suggested_income.dismiss") ]
  else
    [ t("recurring_transactions.suggested.title"), t("recurring_transactions.suggested.confirm"), t("recurring_transactions.suggested.dismiss") ]
  end
%>
<%= render DS::Section.new(
  title: title,
  count: suggested.size,
  collapsible: true,
  persist_key: income ? "income-suggested" : "bills-suggested"
) do |section| %>
  <% section.with_aside { tag.p(t("recurring_transactions.suggested.collapsed_hint"), class: "text-xs text-subdued group-open:hidden") } %>
  <% suggested.each do |suggestion| %>
    <%= render DS::ReviewRow.new do |row| %>
      <% row.with_actions do %>
        <%= render DS::Link.new(
          text: confirm,
          variant: "primary",
          href: confirm_recurring_transaction_path(suggestion),
          method: :post
        ) %>
        <%= render DS::Link.new(
          text: dismiss,
          variant: "ghost",
          href: dismiss_recurring_transaction_path(suggestion),
          method: :post
        ) %>
      <% end %>
      <p class="text-sm font-medium text-primary @md:truncate"><%= suggestion.display_name %></p>
      <p class="text-xs text-secondary">
        <span class="privacy-sensitive"><%= format_money(suggestion.amount_money.abs) %></span>
        &middot; <%= frequency_label(suggestion) %>
        &middot; <%= t("recurring_transactions.suggested.seen_count", count: suggestion.occurrence_count) %>
      </p>
    <% end %>
  <% end %>
<% end %>