Skip to content

Commit 2330fc6

Browse files
committed
fix(marketplace): adapt to nullable PurchaseHistoryRecord.MonthlyCost
After rebasing onto feat/multicloud-web-frontend, base PR #258 made PurchaseHistoryRecord.MonthlyCost a *float64 (nullable). The marketplace default price-schedule path passed it as a float64. Dereference it nil-safely at the call site, treating an absent monthly breakdown as a zero recurring contribution to residual value (per the nullable-not-zero convention: nil means "no breakdown recorded", which contributes nothing to the residual list price).
1 parent 9e312b2 commit 2330fc6

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎internal/api/handler_marketplace.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ func (h *Handler) marketplaceList(ctx context.Context, req *events.LambdaFunctio
138138
// rather than the full contract term (which overprices older RIs).
139139
remainingMonths := computeRemainingMonths(row.Timestamp, row.Term)
140140

141-
// Validate and normalise the price schedule.
142-
schedule, err := resolveMarketplacePriceSchedule(body.PriceSchedule, remainingMonths, row.UpfrontCost, row.MonthlyCost)
141+
// Validate and normalise the price schedule. A nil MonthlyCost means the
142+
// provider recorded no recurring breakdown (issue #258 made the field
143+
// nullable); treat absent as zero recurring contribution to residual value.
144+
monthlyCost := 0.0
145+
if row.MonthlyCost != nil {
146+
monthlyCost = *row.MonthlyCost
147+
}
148+
schedule, err := resolveMarketplacePriceSchedule(body.PriceSchedule, remainingMonths, row.UpfrontCost, monthlyCost)
143149
if err != nil {
144150
return nil, NewClientError(400, err.Error())
145151
}

0 commit comments

Comments
 (0)