pricing

package
v0.0.0-...-9bb3d89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BookingEstimation

func BookingEstimation(t TimePricingStrategy, price float64, locationDurationInSecond float64, start time.Time, end *time.Time) (float64, error)

func TimePricingStrategyListStr

func TimePricingStrategyListStr() []string

Types

type AccessPricingProfile

type AccessPricingProfile[T Strategy] struct {
	AllowedPaymentType []PaymentType      `json:"allowed_payment_type,omitempty" bson:"allowed_payment_type,omitempty"` // Price is the price of the resource
	Pricing            PricingStrategy[T] `json:"pricing,omitempty" bson:"pricing,omitempty"`                           // Price is the price of the resource
	DefaultRefund      RefundType         `json:"default_refund" bson:"default_refund"`                                 // DefaultRefund is the default refund type of the pricing
	RefundRatio        int32              `json:"refund_ratio" bson:"refund_ratio" default:"0"`                         // RefundRatio is the refund ratio if missing
}

func (*AccessPricingProfile[T]) GetOverrideStrategyValue

func (b *AccessPricingProfile[T]) GetOverrideStrategyValue() int

func (AccessPricingProfile[T]) GetPriceHT

func (a AccessPricingProfile[T]) GetPriceHT(quantity float64, val float64, start time.Time, end time.Time, variations []*PricingVariation, params ...string) (float64, error)

func (AccessPricingProfile[T]) GetPurchase

func (a AccessPricingProfile[T]) GetPurchase() BuyingStrategy

func (AccessPricingProfile[T]) IsBooked

func (a AccessPricingProfile[T]) IsBooked() bool

func (AccessPricingProfile[T]) IsPurchasable

func (a AccessPricingProfile[T]) IsPurchasable() bool

type BillingStrategy

type BillingStrategy int // BAM BAM
const (
	BILL_ONCE BillingStrategy = iota // is a permanent buying ( predictible )
	BILL_PER_WEEK
	BILL_PER_MONTH
	BILL_PER_YEAR
)

should except... on

func BillingStrategyList

func BillingStrategyList() []BillingStrategy

func (BillingStrategy) IsBillingStrategyAllowed

func (t BillingStrategy) IsBillingStrategyAllowed(bs int) (BillingStrategy, bool)

func (BillingStrategy) String

func (t BillingStrategy) String() string

type BuyingStrategy

type BuyingStrategy int
const (
	SUBSCRIPTION           BuyingStrategy = iota // is a permanent buying ( predictible )
	UNDEFINED_SUBSCRIPTION                       // a endless subscription ( unpredictible )
	PERMANENT                                    // a defined subscription ( predictible )

)

should except... on

func BuyingStrategyList

func BuyingStrategyList() []BuyingStrategy

func (BuyingStrategy) IsBillingStrategyAllowed

func (t BuyingStrategy) IsBillingStrategyAllowed(bs BillingStrategy) (BillingStrategy, bool)

func (BuyingStrategy) String

func (t BuyingStrategy) String() string

type ExploitPricingProfile

type ExploitPricingProfile[T Strategy] struct {
	AccessPricingProfile[T]
	AdditionnalRefundTypes []RefundType `json:"refund_types" bson:"refund_types"` // RefundTypes is the refund types of the pricing

	PrivilegeStrategy   ExploitPrivilegeStrategy `json:"privilege_strategy,omitempty" bson:"privilege_strategy,omitempty"`       // Strategy is the strategy of the pricing
	GarantedDelaySecond uint                     `json:"garanted_delay_second,omitempty" bson:"garanted_delay_second,omitempty"` // GarantedDelaySecond is the garanted delay of the pricing

	Exceeding      bool  `json:"exceeding" bson:"exceeding"`                         // Exceeding is the exceeding of the bill
	ExceedingRatio int32 `json:"exceeding_ratio" bson:"exceeding_ratio" default:"0"` // ExceedingRatio is the exceeding ratio of the bill
}

type ExploitPrivilegeStrategy

type ExploitPrivilegeStrategy int
const (
	BASIC ExploitPrivilegeStrategy = iota
	GARANTED_ON_DELAY
	GARANTED
)

func ExploitPrivilegeStrategyList

func ExploitPrivilegeStrategyList() []ExploitPrivilegeStrategy

func (ExploitPrivilegeStrategy) String

func (t ExploitPrivilegeStrategy) String() string

type PaymentType

type PaymentType int
const (
	PAY_ONCE PaymentType = iota
	PAY_EVERY_WEEK
	PAY_EVERY_MONTH
	PAY_EVERY_YEAR
)

func PaymentTypeList

func PaymentTypeList() []PaymentType

func (PaymentType) String

func (t PaymentType) String() string

type PricedItemITF

type PricedItemITF interface {
	GetID() string
	GetName() string
	GetInstanceID() string
	GetType() tools.DataType
	IsPurchasable() bool
	IsBooked() bool
	GetQuantity() int
	AddQuantity(amount int)
	GetBookingMode() booking.BookingMode
	GetCreatorID() string
	SelectPricing() PricingProfileITF
	GetLocationStart() *time.Time
	SetLocationStart(start time.Time)
	SetLocationEnd(end time.Time)
	GetLocationEnd() *time.Time
	GetExplicitDurationInS() float64
	GetPriceHT() (float64, error)
}

type PricingProfileITF

type PricingProfileITF interface {
	IsBooked() bool
	IsPurchasable() bool
	GetPurchase() BuyingStrategy
	GetOverrideStrategyValue() int
	GetPriceHT(quantity float64, val float64, start time.Time, end time.Time, variation []*PricingVariation, params ...string) (float64, error)
}

func GetDefaultPricingProfile

func GetDefaultPricingProfile() PricingProfileITF

type PricingStrategy

type PricingStrategy[T Strategy] struct {
	Price    float64 `json:"price" bson:"price" default:"0"`         // Price is the Price of the pricing
	Currency string  `json:"currency" bson:"currency" default:"USD"` // Currency is the currency of the pricing

	// NO NEED ?
	BuyingStrategy      BuyingStrategy      `json:"buying_strategy" bson:"buying_strategy" default:"0"`             // BuyingStrategy is the buying strategy of the pricing
	TimePricingStrategy TimePricingStrategy `json:"time_pricing_strategy" bson:"time_pricing_strategy" default:"0"` // TimePricingStrategy is the time pricing strategy of the pricing
	OverrideStrategy    T                   `json:"override_strategy" bson:"override_strategy" default:"-1"`        // Modulation is the modulation of the pricing
}

may suppress in pricing strategy -> to set in map

func (PricingStrategy[T]) GetBuyingStrategy

func (p PricingStrategy[T]) GetBuyingStrategy() BuyingStrategy

func (PricingStrategy[T]) GetOverrideStrategy

func (p PricingStrategy[T]) GetOverrideStrategy() T

func (PricingStrategy[T]) GetPriceHT

func (p PricingStrategy[T]) GetPriceHT(amountOfData float64, bookingTimeDuration float64, start time.Time, end *time.Time, variations []*PricingVariation) (float64, error)

func (PricingStrategy[T]) GetTimePricingStrategy

func (p PricingStrategy[T]) GetTimePricingStrategy() TimePricingStrategy

type PricingVariation

type PricingVariation struct {
	Inflate    bool    `json:"inflate" bson:"price"`   // Price is the Price of the pricing
	Percentage float64 `json:"percent" bson:"percent"` // Currency is the currency of the pricing        // Modulation is the modulation of the pricing
	Priority   int     `json:"priority" bson:"priority"`
}

func (*PricingVariation) GetPriceHT

func (pv *PricingVariation) GetPriceHT(priceHT float64) float64

type RefundType

type RefundType int
const (
	REFUND_DEAD_END RefundType = iota
	REFUND_ON_ERROR
	REFUND_ON_EARLY_END
)

func RefundTypeList

func RefundTypeList() []RefundType

func (RefundType) String

func (t RefundType) String() string

type Strategy

type Strategy interface {
	GetStrategy() string
	GetStrategyValue() int
}

type TimePricingStrategy

type TimePricingStrategy int
const (
	ONCE TimePricingStrategy = iota
	PER_SECOND
	PER_MINUTE
	PER_HOUR
	PER_DAY
	PER_WEEK
	PER_MONTH
)

func TimePricingStrategyList

func TimePricingStrategyList() []TimePricingStrategy

func (TimePricingStrategy) GetStrategy

func (t TimePricingStrategy) GetStrategy() string

func (TimePricingStrategy) GetStrategyValue

func (t TimePricingStrategy) GetStrategyValue() int

func (TimePricingStrategy) String

func (t TimePricingStrategy) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL