Payment Flow + Access Flow Change
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package enum
|
||||
|
||||
type BookingMode int
|
||||
|
||||
const (
|
||||
PLANNED BookingMode = iota // timing prédictible
|
||||
PREEMPTED // peut être interrompu, premium payé
|
||||
WHEN_POSSIBLE // timing imprévisible
|
||||
)
|
||||
|
||||
/*
|
||||
3 notions distinctes :
|
||||
- BookingMode : QUAND est exécuté (PLANNED / PREEMPTED / WHEN_POSSIBLE)
|
||||
- BillingStrategy : fréquence de facturation (ONCE / WEEKLY / MONTHLY / YEARLY)
|
||||
- PaymentType : mode de paiement par ressource (PAY_ONCE / PAY_EVERY_MONTH / ...)
|
||||
*/
|
||||
@@ -1,5 +1,12 @@
|
||||
package models
|
||||
|
||||
type PathSource struct {
|
||||
Source string `json:"source,omitempty" bson:"source,omitempty"` // Image is the container image TEMPO
|
||||
IsReachable bool `json:"is_reachable,omitempty" bson:"is_reachable,omitempty"`
|
||||
Args string `json:"args,omitempty" bson:"args,omitempty"` // Args is the container arguments
|
||||
Volumes map[string]string `json:"volumes,omitempty" bson:"volumes,omitempty"` // Volumes is the container volumes
|
||||
}
|
||||
|
||||
type Container struct {
|
||||
Image string `json:"image,omitempty" bson:"image,omitempty"` // Image is the container image TEMPO
|
||||
Command string `json:"command,omitempty" bson:"command,omitempty"` // Command is the container command
|
||||
|
||||
@@ -3,7 +3,7 @@ package pricing
|
||||
import (
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/booking"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ type PricedItemITF interface {
|
||||
IsBooked() bool
|
||||
GetQuantity() int
|
||||
AddQuantity(amount int)
|
||||
GetBookingMode() booking.BookingMode
|
||||
GetBookingMode() enum.BookingMode
|
||||
GetCreatorID() string
|
||||
SelectPricing() PricingProfileITF
|
||||
GetLocationStart() *time.Time
|
||||
|
||||
@@ -111,13 +111,11 @@ func getAverageTimeInSecond(averageTimeInSecond float64, start time.Time, end *t
|
||||
|
||||
fromAverageDuration := after.Sub(now).Seconds()
|
||||
var tEnd time.Time
|
||||
if end == nil {
|
||||
tEnd = start.Add(5 * time.Minute)
|
||||
} else {
|
||||
fromDateDuration := float64(0)
|
||||
if end != nil {
|
||||
tEnd = *end
|
||||
fromDateDuration = tEnd.Sub(start).Seconds()
|
||||
}
|
||||
fromDateDuration := tEnd.Sub(start).Seconds()
|
||||
|
||||
if fromAverageDuration > fromDateDuration {
|
||||
return fromAverageDuration
|
||||
}
|
||||
@@ -126,6 +124,9 @@ func getAverageTimeInSecond(averageTimeInSecond float64, start time.Time, end *t
|
||||
|
||||
func BookingEstimation(t TimePricingStrategy, price float64, locationDurationInSecond float64, start time.Time, end *time.Time) (float64, error) {
|
||||
locationDurationInSecond = getAverageTimeInSecond(locationDurationInSecond, start, end)
|
||||
if locationDurationInSecond <= 0 {
|
||||
return 0, nil
|
||||
}
|
||||
priceStr := fmt.Sprintf("%v", price)
|
||||
p, err := strconv.ParseFloat(priceStr, 64)
|
||||
if err != nil {
|
||||
@@ -176,7 +177,6 @@ func (p PricingStrategy[T]) GetPriceHT(amountOfData float64, bookingTimeDuration
|
||||
}
|
||||
|
||||
return p.Price, nil
|
||||
|
||||
case PERMANENT:
|
||||
if variations != nil {
|
||||
price := p.Price
|
||||
|
||||
Reference in New Issue
Block a user