From 2cdf15d722248353d415b9ba7611e9f6d66be403 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 13 Mar 2026 14:25:04 +0100 Subject: [PATCH] default to subscription --- models/common/pricing/pricing_profile.go | 4 ++-- models/common/pricing/pricing_strategy.go | 5 +++-- models/resources/compute.go | 2 ++ models/workflow_execution/workflow_execution.go | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/models/common/pricing/pricing_profile.go b/models/common/pricing/pricing_profile.go index d5aa1db..23b3bf8 100755 --- a/models/common/pricing/pricing_profile.go +++ b/models/common/pricing/pricing_profile.go @@ -59,8 +59,8 @@ func GetDefaultPricingProfile() PricingProfileITF { Pricing: PricingStrategy[TimePricingStrategy]{ Price: 0, Currency: "EUR", - BuyingStrategy: PERMANENT, - TimePricingStrategy: ONCE, + BuyingStrategy: SUBSCRIPTION, + TimePricingStrategy: PER_SECOND, }, } } diff --git a/models/common/pricing/pricing_strategy.go b/models/common/pricing/pricing_strategy.go index b25dc01..f1aff2a 100755 --- a/models/common/pricing/pricing_strategy.go +++ b/models/common/pricing/pricing_strategy.go @@ -160,7 +160,8 @@ type PricingStrategy[T Strategy] struct { } func (p PricingStrategy[T]) GetPriceHT(amountOfData float64, bookingTimeDuration float64, start time.Time, end *time.Time, variations []*PricingVariation) (float64, error) { - if p.BuyingStrategy == SUBSCRIPTION { + switch p.BuyingStrategy { + case SUBSCRIPTION: price, err := BookingEstimation(p.GetTimePricingStrategy(), p.Price*float64(amountOfData), bookingTimeDuration, start, end) if err != nil { return 0, err @@ -174,7 +175,7 @@ func (p PricingStrategy[T]) GetPriceHT(amountOfData float64, bookingTimeDuration return p.Price, nil - } else if p.BuyingStrategy == PERMANENT { + case PERMANENT: if variations != nil { price := p.Price for _, v := range variations { diff --git a/models/resources/compute.go b/models/resources/compute.go index b7bf63c..e40fa23 100755 --- a/models/resources/compute.go +++ b/models/resources/compute.go @@ -2,6 +2,7 @@ package resources import ( "errors" + "fmt" "strings" "time" @@ -95,6 +96,7 @@ type ComputeResourcePricingProfile struct { } func (p *ComputeResourcePricingProfile) IsPurchasable() bool { + fmt.Println("Buying", p.Pricing.BuyingStrategy) return p.Pricing.BuyingStrategy == pricing.PERMANENT } diff --git a/models/workflow_execution/workflow_execution.go b/models/workflow_execution/workflow_execution.go index c383864..a88a196 100755 --- a/models/workflow_execution/workflow_execution.go +++ b/models/workflow_execution/workflow_execution.go @@ -2,6 +2,7 @@ package workflow_execution import ( "encoding/json" + "fmt" "strings" "time" @@ -141,6 +142,7 @@ func (d *WorkflowExecution) Buy(bs pricing.BillingStrategy, executionsID string, func (d *WorkflowExecution) buyEach(bs pricing.BillingStrategy, executionsID string, wfID string, dt tools.DataType, priceds map[string]pricing.PricedItemITF) []*purchase_resource.PurchaseResource { items := []*purchase_resource.PurchaseResource{} for itemID, priced := range priceds { + fmt.Println(priced.IsPurchasable(), bs) if !priced.IsPurchasable() || bs != pricing.BILL_ONCE { // buy only that must be buy continue }