The personal finance app for everyone (by everyone)
Ruby
Show a dated bill row's due date where its rail is hidden (#3901)
Guillem Arias Fauste4c9d2dc2ecb5
diff --git a/app/helpers/bills_helper.rb b/app/helpers/bills_helper.rbindex 675a04ccce..0930018169 100644--- a/app/helpers/bills_helper.rb+++ b/app/helpers/bills_helper.rb@@ -7,6 +7,12 @@ module BillsHelperl(date, format: date.year == Date.current.year ? :short : :short_with_year)end+ # The date a row in a dated section is about, as its date rail prints it and+ # as its subline leads with where the rail is hidden.+ def bills_row_date(occurrence)+ occurrence.due_on == Date.current ? t("bills.row_today") : bills_upcoming_date(occurrence.due_on)+ end+# One-shot AI features (smart-fill, smart-configure) need both the user's# consent AND a resolvable LLM provider -- an unconfigured self-hosted# install renders no AI affordances at all, following the Rules registry's@@ -292,7 +298,7 @@ module BillsHelpercase (occurrence.effective_due_on - Date.current).to_iwhen 0 then t("bills.month_pulse.date_today")when 1 then t("bills.month_pulse.date_tomorrow")- else l(occurrence.effective_due_on, format: "%b %-d")+ else bills_upcoming_date(occurrence.effective_due_on)endenddiff --git a/app/views/bills/_occurrence.html.erb b/app/views/bills/_occurrence.html.erbindex 9a6561bfef..846f959354 100644--- a/app/views/bills/_occurrence.html.erb+++ b/app/views/bills/_occurrence.html.erb@@ -24,14 +24,10 @@piece of temporal context saying the same word twice. The colour stillcarries the state; the rail now carries the date the state is about.- Desktop-only: on a phone the subline says it in words instead. %>+ Only from @lg. Below it the subline leads with the same date. %><% if date_label %><div class="hidden @lg:block w-14 shrink-0 text-xs <%= occurrence.derived_state == :overdue ? "text-destructive font-medium" : "text-secondary" %>">- <% if occurrence.due_on == Date.current %>- <%= t("bills.row_today") %>- <% else %>- <%= l(occurrence.due_on, format: "%b %-d") %>- <% end %>+ <%= bills_row_date(occurrence) %></div><% end %>@@ -59,6 +55,9 @@<%# In a dated section the subline says WHY this row needs attention,which is the whole point of pulling those rows out of the run. %><p class="text-xs truncate <%= reason && occurrence.derived_state == :overdue ? "text-destructive" : "text-secondary" %>">+ <% if date_label %>+ <span class="@lg:hidden"><%= bills_row_date(occurrence) %> ·</span>+ <% end %><% if reason %><%= reason %><%# Two rows reading the same name and the same amount need tellingdiff --git a/test/controllers/bills_controller_test.rb b/test/controllers/bills_controller_test.rbindex 20030908ac..2e27cffaf7 100644--- a/test/controllers/bills_controller_test.rb+++ b/test/controllers/bills_controller_test.rb@@ -144,6 +144,43 @@ class BillsControllerTest < ActionDispatch::IntegrationTestassert_match I18n.t("bills.month_pulse.pulse_overdue"), response.bodyend+ # The date rail only shows from @lg, and below it (every phone, and a 1280px+ # window with both sidebars open) the rail was the row's only date. The+ # subline leads with the same text there instead.+ test "a dated row states its due date below the rail's breakpoint too" do+ travel_to Date.current.beginning_of_month + 9.days+ due = Date.current + 12+ declare_bill(name: "Rent", amount: 1200, due: due)+ create_bill(name: "Water", amount: 40)+ late = Date.current - 5+ create_bill(name: "Gas", amount: 60, expected_day_of_month: late.day,+ last_occurrence_date: 2.months.ago.to_date, next_expected_date: late)++ get bills_url++ assert_response :success+ subline_dates = css_select("p span[class~='@lg:hidden']").map { |span| span.text.squish }+ assert_includes subline_dates, "#{I18n.l(due, format: :short)} ·"+ assert_includes subline_dates, "#{I18n.t("bills.row_today")} ·"+ # Needs attention, where the subline goes on to give the reason.+ assert_includes subline_dates, "#{I18n.l(late, format: :short)} ·"+ assert_match I18n.t("bills.attention.overdue", count: 5), response.body+ end++ # "%b %-d" is English order in every locale; fr, pl and ru put the day first.+ test "the date rail and Next up print the locale's own short date" do+ travel_to Date.current.beginning_of_month + 9.days+ due = Date.current + 5+ series = declare_bill(name: "Rent", amount: 1200, due: due)++ get bills_url(locale: "fr")++ assert_response :success+ date = I18n.l(due, format: :short, locale: :fr)+ assert_select "div[class~='@lg:block']", text: date+ assert_select "a[href=?] p", bill_path(series), text: date+ end+# The summary answers one question in order: where am I this month, what is# late, what is due soon, what happens next. It used to be a big number, two# small ones and a ring reading 0%.