feat(frontend/recs): add Monthly cost column alongside Upfront cost · Issue #220 · LeanerCloud/cloud-commitments-cli · GitHub
Skip to content

feat(frontend/recs): add Monthly cost column alongside Upfront cost #220

Closed

Description

@cristim

Background

The recommendations table at frontend/src/recommendations.ts:1147-1158 currently renders these per-rec columns:

Provider · Account · Service · ResourceType · Region · Count · Term · Monthly savings · Upfront cost

Each rec carries a single payment value (all-upfront / partial-upfront / no-upfront) and a corresponding (upfront_cost, monthly_cost) pair on RecommendationRecord (internal/config/types.go):

UpfrontCost  float64 `json:"upfront_cost"`
MonthlyCost  float64 `json:"monthly_cost"`
Savings      float64 `json:"savings"`        // monthly savings vs on-demand

After PR #195 (issue #188) the user can now choose between all three payment variants of the same (service, region, SKU, term) cell. But the table only shows upfront_cost — so for a no-upfront rec the row reads "$0 upfront" with no indication of what the recurring cost actually is, and for partial-upfront the row is missing half its cost picture. The user has to do mental math against the savings column to compare options.

What needs to happen

Add a "Monthly cost" column rendering formatCurrency(rec.monthly_cost) next to the existing Upfront column. After this PR:

  • no-upfront rec: Upfront = $0, Monthly = $X, Savings = $Y (whole story visible)
  • partial-upfront rec: Upfront = $X, Monthly = $Y, Savings = $Z (whole story visible)
  • all-upfront rec: Upfront = $X, Monthly = $0, Savings = $Y (whole story visible)

Hooks the existing column infrastructure already has: monthly_cost is a known field, just not in the rendered list.

Sketch

  • recommendations.ts:
    • Add a <th> for "Monthly cost" between "Upfront cost" (rendered after Savings today) and the action column. Or put it next to Upfront — designer's call.
    • Add a <td>${formatCurrency(rec.monthly_cost)}</td> in the row template.
    • Wire into the per-column sort + filter helpers that already exist for upfront_cost (SORTABLE_NUMERIC_COLUMNS, the popover registry, the friendly-name table, etc.). Mirror the upfront-cost shape.
  • Frontend tests: a row-render test asserting the Monthly column appears for all three payment variants with the expected value.

Acceptance

  • The recommendations table shows both Upfront and Monthly cost per rec.
  • Users can sort and filter by the new column the same way they can by Upfront.
  • Existing tests still pass; new tests pin the rendering for each payment variant.

References

Activity

  1. added 2 commits that reference this issue on May 3, 2026
    dc44d62
    9a03c9a
  2. cristim commented on May 3, 2026

    @cristim
    MemberAuthor

    Verification (post-merge of #242)

    Confirming this issue is addressed — recommend close.

    What I checked

    PR #242 (merged 2026-05-03, "feat(frontend/recs): add Monthly cost + Effective savings % columns") landed:

    • frontend/src/recommendations.ts (column rendering)
    • frontend/src/state.ts
    • frontend/src/__tests__/recommendations.test.ts

    Closes #220 (Monthly cost column) and #221 (Effective savings %) together. Auto-link didn't fire — closing manually.

  3. cristim commented on May 4, 2026

    @cristim
    MemberAuthor

    Retracting the close-recommend above — see #252. PR #242 shipped the columns but the data feeding them is broken (monthly_cost always $0; effective % swings between 100% and negative due to scheduler.go:881 hardcoding MonthlyCost: 0 and mislabeling UpfrontCost = CommitmentCost). Keeping #220 / #221 open until the underlying fix lands.

  4. cristim commented on May 13, 2026

    @cristim
    MemberAuthor

    PR #242 (feat(frontend/recs): add Monthly cost + Effective savings % columns, merged 2026-05-03) fully satisfies this issue's acceptance criteria:

    • A Monthly Cost column was added to the recommendations table, rendering formatCurrency(rec.monthly_cost) for every row so all three payment variants show the complete cost picture (Upfront + Monthly + Savings) without mental arithmetic.
    • The column is wired into the sort comparator, numeric filter popover, and the friendly-name / column-registry infrastructure — matching the upfront-cost shape exactly as described.
    • 255 new test lines in frontend/src/__tests__/recommendations.test.ts pin the rendering for all three payment variants and the sort/filter behaviour.

    Recommend closing this issue as resolved by #242.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions