The personal finance app for everyone (by everyone)
Ruby
<%# locals: (period:, due_total:, currency:) %>
<%# A payday, drawn inside the month rather than beside it.
The month is the right container for planning, but it is the wrong unit for
anyone whose money does not arrive monthly: paid weekly, "this month" is
four paychecks and four rent payments in one undifferentiated list, and the
question that actually matters, whether the next few days are covered, is
the one the list cannot answer.
So this stays a marker, not a section header. Same card, same rhythm, one
tinted band naming the money that arrives and the date it has to stretch to.
Both halves name a date on purpose. "Paid Aug 26" read as past tense for a
date four days out, and "due before next" never said before what, so the
band described a pay period without ever saying where it ended. %>
<% next_payday = period.ends_on + 1 %>
<%# Below @lg the two halves stack, the total under the label's text. Side by
side they need about 350px, so on a phone the label wrapped into two ragged
lines beside a one-line total. Container, not viewport, like the rows. %>
<div class="flex items-start @lg:items-center gap-2 px-4 py-2 bg-container-inset">
<% if period.bridge? %>
<%= icon "wallet", size: "sm" %>
<% else %>
<%= icon "arrow-down-circle", size: "sm", color: "success" %>
<% end %>
<div class="flex-1 min-w-0 flex flex-col @lg:flex-row @lg:items-center gap-x-2 gap-y-0.5">
<%# A leading window with nothing arriving is not a payday. Labelling it
"Paid $0.00" would read as a missed cheque rather than the stretch before
the next one, so it says what it is, the same wording the income plan uses. %>
<% if period.bridge? %>
<p class="text-xs font-medium text-secondary">
<%= t("bills.pay_period.before_next_paycheck") %>
</p>
<% else %>
<p class="text-xs font-medium text-secondary">
<%= t("bills.pay_period.paycheck_on", date: l(period.starts_on, format: :short)) %>
<span class="text-subdued">·</span>
<span class="text-success privacy-sensitive">
+<%= format_money(Money.new(period.income, currency)) %>
</span>
</p>
<% end %>
<% if due_total.positive? %>
<p class="@lg:ml-auto text-xs text-subdued privacy-sensitive shrink-0">
<%= t("bills.pay_period.due_before_date",
amount: format_money(Money.new(due_total, currency)),
date: l(next_payday, format: :short)) %>
</p>
<% end %>
</div>
</div>