Skip to content

bug(approvals): Account & Payment columns on Approval queue show '-' instead of data (followup to #713) #733

@cristim

Description

@cristim

Symptom (user-reported)

The Account and Payment columns are now shown, but they have no data, only a dash ("-").

PR #713 added the Account, Term, Payment, Monthly Cost columns to the Approval queue. The columns render, but every row shows - for Account, Payment, and (when not already set) Monthly Cost.

Root cause

The data lives in the right place on the backend but executionToHistoryRow / projectRecommendationFields in internal/api/handler_history.go never copy it onto the synthesised PurchaseHistoryRecord:

  • Account: executionToHistoryRow reads exec.CloudAccountID, but pending executions created by the web bulk-purchase flow (handler_purchases.go near L1399, the only constructor for these rows) never set CloudAccountID. The per-recommendation CloudAccountID IS available via recs[i].CloudAccountID but is not consulted.
  • Payment: projectRecommendationFields populates Service, ResourceType, Region, Term, UpfrontCost, EstimatedSavings, and (single-rec only) MonthlyCost from the recommendation, but never sets row.Payment in either branch — even though RecommendationRecord.Payment exists and is populated by every constructor.
  • MonthlyCost (multi-rec only): same gap; only the single-rec branch maps it.

Net effect: the frontend reads account_id == "" and payment == "" and renders the - fallback for every Approval-queue row.

Proposed fix

In internal/api/handler_history.go:

  1. executionToHistoryRow: when exec.CloudAccountID == nil, fall back to recs[i].CloudAccountID collapsed via a new collapseRecommendationAccount helper (mirrors collapseRecommendationProvider). Returns the shared value across recs, or "" when they disagree (the - rendering then stays correct for an honestly-heterogeneous basket).
  2. projectRecommendationFields:
    • Single-rec: set row.Payment = r.Payment alongside the existing field projections.
    • Multi-rec: set row.Payment = collapseRecommendationPayment(recs) (same pattern) and row.MonthlyCost = sum(recs[i].MonthlyCost).

Add regression tests:

  • Extend TestHandler_getHistory_IncludesPending so its recs carry CloudAccountID, Payment, and MonthlyCost; assert the pending row carries AccountID, Payment, MonthlyCost.
  • New single-rec sub-test that asserts a 1-rec execution passes Payment through.
  • Extend history-approval-queue.test.ts with a test that mocks the API response with the three populated fields and asserts the cells show real values, not the - fallback.

Followup to

#713 (merged) — this is the second pass on the same change, fixing the data-population gap on the backend side.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions