default to subscription
This commit is contained in:
@@ -59,8 +59,8 @@ func GetDefaultPricingProfile() PricingProfileITF {
|
||||
Pricing: PricingStrategy[TimePricingStrategy]{
|
||||
Price: 0,
|
||||
Currency: "EUR",
|
||||
BuyingStrategy: PERMANENT,
|
||||
TimePricingStrategy: ONCE,
|
||||
BuyingStrategy: SUBSCRIPTION,
|
||||
TimePricingStrategy: PER_SECOND,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user