add purchase resource in model catalog

This commit is contained in:
mr
2025-02-10 13:10:42 +01:00
parent 4ad32401fd
commit 52d5a1fbf9
4 changed files with 11 additions and 14 deletions

View File

@@ -82,12 +82,12 @@ func (r *PricedResource) GetPrice() (float64, error) {
add := r.UsageStart.Add(time.Duration(1 * time.Hour))
r.UsageEnd = &add
}
pricing := *r.SelectedPricing
if pricing == nil {
if r.SelectedPricing == nil {
if len(r.PricingProfiles) == 0 {
return 0, errors.New("pricing profile must be set")
}
pricing = r.PricingProfiles[0]
*r.SelectedPricing = r.PricingProfiles[0]
}
pricing := *r.SelectedPricing
return pricing.GetPrice(1, 0, *r.UsageStart, *r.UsageEnd)
}