Add InstanceID
This commit is contained in:
@@ -26,6 +26,8 @@ type PricedResource struct {
|
||||
Variations []*pricing.PricingVariation `json:"pricing_variations" bson:"pricing_variations"`
|
||||
CreatorID string `json:"peer_id,omitempty" bson:"peer_id,omitempty"`
|
||||
ResourceID string `json:"resource_id,omitempty" bson:"resource_id,omitempty"`
|
||||
InstanceID string `json:"instance_id,omitempty" bson:"resource_id,omitempty"`
|
||||
|
||||
ResourceType tools.DataType `json:"resource_type,omitempty" bson:"resource_type,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,16 @@ func (abs *AbstractInstanciatedResource[T]) ConvertToPricedResource(t tools.Data
|
||||
selectedBookingModeIndex *int, request *tools.APIRequest) (pricing.PricedItemITF, error) {
|
||||
instances := map[string]string{}
|
||||
var profile pricing.PricingProfileITF
|
||||
var inst ResourceInstanceITF
|
||||
if t := abs.GetSelectedInstance(selectedInstance); t != nil {
|
||||
inst = t
|
||||
instances[t.GetID()] = t.GetName()
|
||||
profile = t.GetProfile(request.PeerID, selectedPartnership, selectedBuyingStrategy, selectedStrategy)
|
||||
} else {
|
||||
for _, instance := range abs.Instances { // TODO why it crush before ?
|
||||
for i, instance := range abs.Instances { // TODO why it crush before ?
|
||||
if i == 0 {
|
||||
inst = instance
|
||||
}
|
||||
instances[instance.GetID()] = instance.GetName()
|
||||
profiles := instance.GetPricingsProfiles(request.PeerID, request.Groups)
|
||||
if len(profiles) > 0 {
|
||||
@@ -111,6 +116,7 @@ func (abs *AbstractInstanciatedResource[T]) ConvertToPricedResource(t tools.Data
|
||||
Name: abs.Name,
|
||||
Logo: abs.Logo,
|
||||
ResourceID: abs.UUID,
|
||||
InstanceID: inst.GetID(),
|
||||
ResourceType: t,
|
||||
Quantity: 1,
|
||||
InstancesRefs: instances,
|
||||
|
||||
Reference in New Issue
Block a user