carlos / platform Public

cli: print the euro zero, not "()", when ARR has no amounts

Final review finding H (Fable P3-1): with no paying amounts, carlos
billing revenue printed BDC-5's breakdown as "()", the first line an
operator sees on a new deployment. Layout only, no copy change: with no
currencies the <amounts> slot is the formatted euro zero (€0.00).
TestBillingRevenueCLI covers an empty and an absent by_currency.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 5c424e54be8706180c7cddce99d77877fd2dd939 parent 782b196
2 files changed, +19 −0
  • billing_cli.go +4 −0
  • billing_cli_test.go +15 −0
diff --git a/billing_cli.go b/billing_cli.go
index 8c9109416..3ee93679b 100644
--- a/billing_cli.go
+++ b/billing_cli.go
@@ -326,6 +326,10 @@ func printBillingRevenue(w io.Writer, rev billingRevenueReply) {
for _, c := range slices.Sorted(maps.Keys(rev.ARR.ByCurrency)) {
parts = append(parts, formatMinor(rev.ARR.ByCurrency[c], c))
}
+ // With no paying amounts the breakdown is the euro zero, not "()".
+ if len(parts) == 0 {
+ parts = []string{formatMinor(0, "eur")}
+ }
return fmt.Sprintf(cliBillingCopyARR, formatMinor(rev.ARR.EUR, "eur"), strings.Join(parts, " + ")) + rateClause
})
line(cliBillingCopyLabelMRR, rev.MRR, func() string {
diff --git a/billing_cli_test.go b/billing_cli_test.go
index 476cb2457..04cdc58df 100644
--- a/billing_cli_test.go
+++ b/billing_cli_test.go
@@ -200,6 +200,21 @@ func TestBillingRevenueCLI(t *testing.T) {
if want := "mrr " + fmt.Sprintf(cliBillingCopyMRR, "€200.00"); got[1] != want {
t.Errorf("all-euro mrr = %q, want %q", got[1], want)
}
+ // No paying amounts yet: the breakdown is the euro zero, never "()".
+ reply = `{"arr":{"available":true,"by_currency":{},"eur":0,"rate_day":"2026-11-06"},` +
+ `"mrr":{"available":true,"eur":0},"paying":{"available":true,"count":0},"attention":{"available":true,"count":0},` +
+ `"groups":{"available":true,"counts":{"free":37,"house":0,"ours":1,"paying":0,"sponsored":0}},"accounts":38,"test_mode":false}`
+ for _, r := range []string{reply, strings.Replace(reply, `"by_currency":{},`, ``, 1)} {
+ reply = r
+ out.Reset()
+ if err := runBillingWithSession(context.Background(), s, []string{"revenue"}, &out); err != nil {
+ t.Fatal(err)
+ }
+ got = strings.Split(out.String(), "\n")
+ if want := "arr " + fmt.Sprintf(cliBillingCopyARR, "€0.00", "€0.00"); got[0] != want {
+ t.Errorf("no amounts: arr = %q, want %q", got[0], want)
+ }
+ }
if err := runBillingWithSession(context.Background(), s, []string{"revenue", "extra"}, io.Discard); err == nil {
t.Fatal("an extra argument was accepted")
}