default to subscription
This commit is contained in:
@@ -59,8 +59,8 @@ func GetDefaultPricingProfile() PricingProfileITF {
|
|||||||
Pricing: PricingStrategy[TimePricingStrategy]{
|
Pricing: PricingStrategy[TimePricingStrategy]{
|
||||||
Price: 0,
|
Price: 0,
|
||||||
Currency: "EUR",
|
Currency: "EUR",
|
||||||
BuyingStrategy: PERMANENT,
|
BuyingStrategy: SUBSCRIPTION,
|
||||||
TimePricingStrategy: ONCE,
|
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) {
|
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)
|
price, err := BookingEstimation(p.GetTimePricingStrategy(), p.Price*float64(amountOfData), bookingTimeDuration, start, end)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -174,7 +175,7 @@ func (p PricingStrategy[T]) GetPriceHT(amountOfData float64, bookingTimeDuration
|
|||||||
|
|
||||||
return p.Price, nil
|
return p.Price, nil
|
||||||
|
|
||||||
} else if p.BuyingStrategy == PERMANENT {
|
case PERMANENT:
|
||||||
if variations != nil {
|
if variations != nil {
|
||||||
price := p.Price
|
price := p.Price
|
||||||
for _, v := range variations {
|
for _, v := range variations {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package resources
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ type ComputeResourcePricingProfile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ComputeResourcePricingProfile) IsPurchasable() bool {
|
func (p *ComputeResourcePricingProfile) IsPurchasable() bool {
|
||||||
|
fmt.Println("Buying", p.Pricing.BuyingStrategy)
|
||||||
return p.Pricing.BuyingStrategy == pricing.PERMANENT
|
return p.Pricing.BuyingStrategy == pricing.PERMANENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package workflow_execution
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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 {
|
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{}
|
items := []*purchase_resource.PurchaseResource{}
|
||||||
for itemID, priced := range priceds {
|
for itemID, priced := range priceds {
|
||||||
|
fmt.Println(priced.IsPurchasable(), bs)
|
||||||
if !priced.IsPurchasable() || bs != pricing.BILL_ONCE { // buy only that must be buy
|
if !priced.IsPurchasable() || bs != pricing.BILL_ONCE { // buy only that must be buy
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user