add purchase resource in model catalog
This commit is contained in:
parent
4a178d01e3
commit
e55727d9e2
@ -2,6 +2,7 @@ package resources
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -138,6 +139,7 @@ func (r *PricedComputeResource) GetType() tools.DataType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *PricedComputeResource) GetPrice() (float64, error) {
|
func (r *PricedComputeResource) GetPrice() (float64, error) {
|
||||||
|
fmt.Println("GetPrice", r.UsageStart, r.UsageEnd)
|
||||||
if r.UsageStart == nil || r.UsageEnd == nil {
|
if r.UsageStart == nil || r.UsageEnd == nil {
|
||||||
return 0, errors.New("usage start and end must be set")
|
return 0, errors.New("usage start and end must be set")
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,13 @@ func (abs *PricedResource) SetLocationEnd(end time.Time) {
|
|||||||
|
|
||||||
func (abs *PricedResource) GetExplicitDurationInS() float64 {
|
func (abs *PricedResource) GetExplicitDurationInS() float64 {
|
||||||
if abs.ExplicitBookingDurationS == 0 {
|
if abs.ExplicitBookingDurationS == 0 {
|
||||||
if abs.UsageEnd == nil || abs.UsageStart == nil {
|
if abs.UsageEnd == nil && abs.UsageStart == nil {
|
||||||
return time.Duration(1 * time.Hour).Seconds()
|
return time.Duration(1 * time.Hour).Seconds()
|
||||||
}
|
}
|
||||||
|
if abs.UsageEnd == nil {
|
||||||
|
add := abs.UsageStart.Add(time.Duration(1 * time.Hour))
|
||||||
|
abs.UsageEnd = &add
|
||||||
|
}
|
||||||
return abs.UsageEnd.Sub(*abs.UsageStart).Seconds()
|
return abs.UsageEnd.Sub(*abs.UsageStart).Seconds()
|
||||||
}
|
}
|
||||||
return abs.ExplicitBookingDurationS
|
return abs.ExplicitBookingDurationS
|
||||||
|
@ -2,6 +2,7 @@ package resources
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||||
@ -161,6 +162,7 @@ func (r *PricedStorageResource) GetType() tools.DataType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *PricedStorageResource) GetPrice() (float64, error) {
|
func (r *PricedStorageResource) GetPrice() (float64, error) {
|
||||||
|
fmt.Println("GetPrice", r.UsageStart, r.UsageEnd)
|
||||||
if r.UsageStart == nil || r.UsageEnd == nil {
|
if r.UsageStart == nil || r.UsageEnd == nil {
|
||||||
return 0, errors.New("usage start and end must be set")
|
return 0, errors.New("usage start and end must be set")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user