From 5d32b4646a869ca2da99634d71ee80df7c14a24e Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 23 Feb 2026 15:18:27 +0100 Subject: [PATCH] Add InstanceID --- models/resources/priced_resource.go | 4 +++- models/resources/resource.go | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/models/resources/priced_resource.go b/models/resources/priced_resource.go index 1b1bd60..c6b67f1 100755 --- a/models/resources/priced_resource.go +++ b/models/resources/priced_resource.go @@ -26,7 +26,9 @@ 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"` - ResourceType tools.DataType `json:"resource_type,omitempty" bson:"resource_type,omitempty"` + InstanceID string `json:"instance_id,omitempty" bson:"resource_id,omitempty"` + + ResourceType tools.DataType `json:"resource_type,omitempty" bson:"resource_type,omitempty"` } func (abs *PricedResource) GetQuantity() int { diff --git a/models/resources/resource.go b/models/resources/resource.go index 90f5b90..d0ed42d 100755 --- a/models/resources/resource.go +++ b/models/resources/resource.go @@ -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,