@@ -232,7 +232,9 @@ func (i orderManager) GenerateOrder(packageKeyname, location string, itemKeyname
232232 }
233233
234234 for _ , item := range presetItems .Prices {
235- if item .Item != nil && item .Item .ItemCategory != nil && item .Item .ItemCategory .CategoryCode != nil && * item .Item .ItemCategory .CategoryCode == "guest_core" {
235+ if item .Item != nil && item .Item .ItemCategory != nil &&
236+ item .Item .ItemCategory .CategoryCode != nil &&
237+ * item .Item .ItemCategory .CategoryCode == "guest_core" {
236238 if item .Item .Capacity != nil {
237239 presetCore = float64 (* item .Item .Capacity )
238240 }
@@ -317,8 +319,9 @@ func (i orderManager) GetPresetbyKey(packageKeyname, presetKeyname string) (data
317319 return activePresets [0 ], nil
318320}
319321
322+ // Makes an API call to get packageKeyName
323+ // Finds the given itemKeynames in the result, checking any capacity restrictions for the items if needed
320324func (i orderManager ) GetPriceIdList (packageKeyname string , itemKeynames []string , presetCore float64 ) ([]int , error ) {
321-
322325 mask := "id, itemCategory, keyName, prices[categories]"
323326 packages , err := i .GetPackageByKey (packageKeyname , "id" )
324327 if err != nil {
@@ -343,16 +346,22 @@ func (i orderManager) GetPriceIdList(packageKeyname string, itemKeynames []strin
343346 if len (newItems ) != 0 {
344347 matchingItem = newItems [0 ]
345348 } else {
346- return nil , errors .New (T ("Item {{.Item}} does not exist for package {{.Package}}" , map [string ]interface {}{"Item" : itemKeyname , "Package" : packageKeyname }))
349+ subs := map [string ]interface {}{"Item" : itemKeyname , "Package" : packageKeyname }
350+ return nil , errors .New (T ("Item {{.Item}} does not exist for package {{.Package}}" , subs ))
347351 }
352+
348353 var itemCategory string
349354 if matchingItem .ItemCategory != nil && matchingItem .ItemCategory .CategoryCode != nil {
350355 itemCategory = * matchingItem .ItemCategory .CategoryCode
351356 }
357+
352358 if _ , ok := categoryDict [itemCategory ]; ! ok {
353359 for _ , p := range matchingItem .Prices {
354- if ((p .LocationGroupId != nil && * p .LocationGroupId == 0 ) || p .LocationGroupId == nil ) && p .Id != nil {
355- var capacityMin , capacityMax int
360+ if ((p .LocationGroupId != nil && * p .LocationGroupId == 0 ) ||
361+ p .LocationGroupId == nil ) && p .Id != nil {
362+
363+ capacityMin := - 1
364+ capacityMax := - 1
356365 if p .CapacityRestrictionMinimum != nil {
357366 capacityMin , err = strconv .Atoi (* p .CapacityRestrictionMinimum )
358367 if err != nil {
@@ -375,15 +384,17 @@ func (i orderManager) GetPriceIdList(packageKeyname string, itemKeynames []strin
375384 priceId = * p .Id
376385 }
377386 }
378-
379387 }
380388 }
381389 } else {
382390 var PriceIdList []int
383391 categoryDict [itemCategory ] += 1
384392 categoryCode := itemCategory [:len (itemCategory )- 1 ] + strconv .Itoa (categoryDict [itemCategory ])
385393 for _ , p := range matchingItem .Prices {
386- if p .LocationGroupId != nil && * p .LocationGroupId == 0 && len (p .Categories ) > 0 && p .Categories [0 ].CategoryCode != nil && * p .Categories [0 ].CategoryCode == categoryCode {
394+ if p .LocationGroupId != nil && * p .LocationGroupId == 0 &&
395+ len (p .Categories ) > 0 && p .Categories [0 ].CategoryCode != nil &&
396+ * p .Categories [0 ].CategoryCode == categoryCode {
397+
387398 PriceIdList = append (PriceIdList , * p .Id )
388399 }
389400 }
0 commit comments