carlos / platform Public

console: dashboard tile shows ARR refusals and its native amounts

Fix round 1 for the paying accounts tile. A refused ARR beside a shown
count now reads Not available yet with its reason in the note, and a
converted ARR carries its amounts in their own currencies (the
overview's opBillingMoney and nativeText) before the rate day. Tests
cover rates-only and amounts-only refusals and the breakdown, in the
view and in the rendered Dashboard.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9c17526e035748b56a87a0e73fb3b27e40286cab parent 545cde0
2 files changed, +46 −14
  • internal/console/opdashboard.go +14 −10
  • internal/console/opdashboard_test.go +32 −4

CI passed — run details

diff --git a/internal/console/opdashboard.go b/internal/console/opdashboard.go
index 9e91daec8..7031cdaf2 100644
--- a/internal/console/opdashboard.go
+++ b/internal/console/opdashboard.go
@@ -218,12 +218,13 @@ func dashStats(c OperatorCounts) []opStat {
// billingDashStat is the Dashboard's billing tile (billing dashboard plan 2,
// Task 7): Paying accounts, the paying count, and under it ARR in euros a
-// year, with the rate day when any of it converted (the Billing overview
-// carries the breakdown). Both figures go through opMoney: the count
-// declares the facts and payments, ARR those, the amounts and its
-// currencies' rates. A refused count reads Not available yet; a refused
-// ARR puts its reason in place of the note. The whole tile links to
-// Billing, and says so in test mode.
+// year; when any of it converted, its amounts in their own currencies and
+// the rate day follow, as the overview's converted totals carry them. Both
+// figures go through opMoney: the count declares the facts and payments,
+// ARR those, the amounts and its currencies' rates. A refused count reads
+// Not available yet with ARR's reason under it; a refused ARR beside a
+// shown count reads Not available yet and its reason in place of the note.
+// The whole tile links to Billing, and says so in test mode.
func billingDashStat(rev billingRevenue, in moneyInputs) (opStat, []opMoneyFigure) {
var figs []opMoneyFigure
st := opStat{Label: billCopyDashTile, Href: "/fleet/billing", Link: billCopyDashTileLink}
@@ -235,12 +236,15 @@ func billingDashStat(rev billingRevenue, in moneyInputs) (opStat, []opMoneyFigur
st.Value = paying.Text
cur := slices.Sorted(maps.Keys(rev.ByCurrency))
arrUse := opBillingUse(inFacts|inPayments|inAmounts, cur, "")
- arr := opMoney(&figs, "dash.arr", in, arrUse, nil, func() string { return eurText(rev.EUR) })
+ arr := opBillingMoney(&figs, "dash.arr", in, arrUse, nil, rev.EUR, nativeAmounts(rev.ByCurrency))
switch {
- case !arr.Shown:
+ case !arr.Shown && !paying.Shown:
st.Note = arr.Reason
- case ratesUse(cur...) != 0:
- st.Note = fmt.Sprintf(billCopyDashTileNote, arr.Text) + ", " + fmt.Sprintf(billCopyRateNote, opBillingRateDay(in.Rates.Day))
+ case !arr.Shown:
+ st.Note = arr.Text + ". " + arr.Reason
+ case arr.Native != "":
+ st.Note = fmt.Sprintf(billCopyDashTileNote, arr.Text) + " (" + arr.Native + "), " +
+ fmt.Sprintf(billCopyRateNote, opBillingRateDay(in.Rates.Day))
default:
st.Note = fmt.Sprintf(billCopyDashTileNote, arr.Text)
}
diff --git a/internal/console/opdashboard_test.go b/internal/console/opdashboard_test.go
index a8c1ee766..5df16354f 100644
--- a/internal/console/opdashboard_test.go
+++ b/internal/console/opdashboard_test.go
@@ -7,6 +7,7 @@ import (
"fmt"
"html"
"net/http"
+ "net/http/httptest"
"regexp"
"slices"
"strconv"
@@ -1065,15 +1066,25 @@ func TestDashStatGateInvariant(t *testing.T) {
})
}
-// TestDashStatNotes: the tile's words in each case: an all-eur ARR with no
-// rate note, a converted one with the rate day, test mode, and a refused
-// gate (Not available yet with the reason, never a partial number).
+// TestDashStatNotes: the tile's words in each case, in the view and as the
+// Dashboard renders them: an all-eur ARR with no breakdown or rate note, a
+// converted one with its amounts in their own currencies and the rate
+// day, test mode, a refused count (Not available yet with the reason,
+// never a partial number), and ARR alone refused by the rates or by an
+// unknown yearly amount (the count stays, the note says Not available yet
+// and why).
func TestDashStatNotes(t *testing.T) {
+ fx := newConsoleFixture(t)
good := goodMoneyInputs(overviewNow)
base := opStat{Label: billCopyDashTile, Href: "/fleet/billing", Link: billCopyDashTileLink}
eurOnly := []billingFact{{AccountID: 1}, payingFact(2, "eur", 2400)}
stale := good
stale.Reconciled = time.Time{}
+ noRates := good
+ noRates.Rates.FetchedAt = time.Time{}
+ unknown := good
+ unknown.Unknown = 1
+ arrNA := billCopyNotAvailable + ". "
for _, tc := range []struct {
name string
facts []billingFact
@@ -1083,15 +1094,32 @@ func TestDashStatNotes(t *testing.T) {
}{
{"eur", eurOnly, good, false, opStat{Value: "1", Note: fmt.Sprintf(billCopyDashTileNote, "€24.00")}},
{"converted", dashStatFacts(), good, false, opStat{Value: "2",
- Note: fmt.Sprintf(billCopyDashTileNote, "€49.00") + ", " + fmt.Sprintf(billCopyRateNote, "6 Nov 2026")}},
+ Note: fmt.Sprintf(billCopyDashTileNote, "€49.00") + " (€24.00, $28.00), " + fmt.Sprintf(billCopyRateNote, "6 Nov 2026")}},
{"test mode", eurOnly, good, true, opStat{Value: "1", Note: fmt.Sprintf(billCopyDashTileNote, "€24.00"), Flag: billCopyDashTileTestMode}},
{"refused", dashStatFacts(), stale, false, opStat{Value: billCopyNotAvailable, Note: billCopyWhyPayments}},
+ {"rates only", dashStatFacts(), noRates, false, opStat{Value: "2", Note: arrNA + billCopyWhyRates}},
+ {"amounts only", dashStatFacts(), unknown, false, opStat{Value: "2", Note: arrNA + billCopyWhyAmounts}},
} {
want := base
want.Value, want.Note, want.Flag = tc.want.Value, tc.want.Note, tc.want.Flag
got, _ := billingDashStat(dashStatRev(tc.facts, tc.in, tc.test), tc.in)
if got != want {
t.Errorf("%s: stat = %+v\nwant %+v", tc.name, got, want)
+ continue
+ }
+ p := fx.srv.opPage("paul@keymail.dev", "", "dashboard")
+ p.Dash = &dashView{Tone: "positive", Stats: []opStat{got}}
+ rec := httptest.NewRecorder()
+ fx.srv.render(rec, http.StatusOK, "ops_dashboard", p)
+ body := html.UnescapeString(rec.Body.String())
+ for _, part := range []string{
+ `<a rst-stat href="/fleet/billing">`,
+ "<span rst-stat-num>" + want.Value + "</span>",
+ "<span rst-stat-note>" + want.Note + "</span>",
+ } {
+ if !strings.Contains(body, part) {
+ t.Errorf("%s: rendered tile lacks %s", tc.name, part)
+ }
}
}
}