MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / amortizedHourlyRate

Function amortizedHourlyRate

internal/estimate/estimator.go:131–146  ·  view source on GitHub ↗

amortizedHourlyRate returns the effective hourly rate for a PriceEntry, spreading any upfront fee evenly over the term hours. For entries with no upfront fee, this equals RatePerHr.

(e resources.PriceEntry)

Source from the content-addressed store, hash-verified

129// spreading any upfront fee evenly over the term hours.
130// For entries with no upfront fee, this equals RatePerHr.
131func amortizedHourlyRate(e resources.PriceEntry) (rate decimal.Decimal, isAmortized bool) {
132 rate = e.RatePerHr
133 if e.UpfrontFee == "" || e.UpfrontFee == "0" {
134 return rate, false
135 }
136 upfront, err := decimal.NewFromString(e.UpfrontFee)
137 if err != nil || upfront.IsZero() {
138 return rate, false
139 }
140 termHours := termToHours(e.Term)
141 if termHours <= 0 {
142 return rate, false
143 }
144 amortized := upfront.Div(decimal.NewFromInt(termHours))
145 return rate.Add(amortized), true
146}
147
148// applyModelSelector finds the best matching PriceEntry for the given selector,
149// marks it as IsCurrent (and clears all others), and returns the effective

Callers 2

applyModelSelectorFunction · 0.85
EstimateAllResourcesFunction · 0.85

Calls 1

termToHoursFunction · 0.85

Tested by

no test coverage detected