diff --git a/cmd/backoffice/main.go b/cmd/backoffice/main.go index 396549a..80637c1 100644 --- a/cmd/backoffice/main.go +++ b/cmd/backoffice/main.go @@ -124,7 +124,7 @@ func main() { http.Error(w, "failed to update inventory", http.StatusInternalServerError) return } - err := inventoryService.SendInventoryChanged(r.Context(), inventorySku, inventoryLocationId) + err = inventoryService.SendInventoryChanged(r.Context(), inventorySku, inventoryLocationId) if err != nil { w.WriteHeader(http.StatusBadRequest) return diff --git a/go.mod b/go.mod index 8b3be00..2572924 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/google/uuid v1.6.0 github.com/matst80/go-redis-inventory v0.0.0-20251125181530-7ebbc97e3841 - github.com/matst80/slask-finder v0.0.0-20251118173753-f66c21cfbda4 + github.com/matst80/slask-finder v0.0.0-20251125182907-9e57f193127a github.com/prometheus/client_golang v1.23.2 github.com/rabbitmq/amqp091-go v1.10.0 github.com/redis/go-redis/v9 v9.17.0 @@ -30,7 +30,6 @@ require ( ) require ( - git.tornberg.me/mats/go-redis-inventory v0.0.0-20251113201741-8bf0efac50ee // indirect github.com/RoaringBitmap/roaring/v2 v2.14.4 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.24.4 // indirect @@ -47,18 +46,18 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.22.3 // indirect github.com/go-openapi/jsonreference v0.21.3 // indirect - github.com/go-openapi/swag v0.25.3 // indirect - github.com/go-openapi/swag/cmdutils v0.25.3 // indirect - github.com/go-openapi/swag/conv v0.25.3 // indirect - github.com/go-openapi/swag/fileutils v0.25.3 // indirect - github.com/go-openapi/swag/jsonname v0.25.3 // indirect - github.com/go-openapi/swag/jsonutils v0.25.3 // indirect - github.com/go-openapi/swag/loading v0.25.3 // indirect - github.com/go-openapi/swag/mangling v0.25.3 // indirect - github.com/go-openapi/swag/netutils v0.25.3 // indirect - github.com/go-openapi/swag/stringutils v0.25.3 // indirect - github.com/go-openapi/swag/typeutils v0.25.3 // indirect - github.com/go-openapi/swag/yamlutils v0.25.3 // indirect + github.com/go-openapi/swag v0.25.4 // indirect + github.com/go-openapi/swag/cmdutils v0.25.4 // indirect + github.com/go-openapi/swag/conv v0.25.4 // indirect + github.com/go-openapi/swag/fileutils v0.25.4 // indirect + github.com/go-openapi/swag/jsonname v0.25.4 // indirect + github.com/go-openapi/swag/jsonutils v0.25.4 // indirect + github.com/go-openapi/swag/loading v0.25.4 // indirect + github.com/go-openapi/swag/mangling v0.25.4 // indirect + github.com/go-openapi/swag/netutils v0.25.4 // indirect + github.com/go-openapi/swag/stringutils v0.25.4 // indirect + github.com/go-openapi/swag/typeutils v0.25.4 // indirect + github.com/go-openapi/swag/yamlutils v0.25.4 // indirect github.com/google/gnostic-models v0.7.1 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/gorilla/schema v1.4.1 // indirect diff --git a/go.sum b/go.sum index ddf0af1..81475de 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -git.tornberg.me/mats/go-redis-inventory v0.0.0-20251113201741-8bf0efac50ee h1:9K/INdO9y/hAjlERsYkJWAla6BUEAPXtChVLfYtWdGI= -git.tornberg.me/mats/go-redis-inventory v0.0.0-20251113201741-8bf0efac50ee/go.mod h1:jrDU55O7sdN2RJr99upmig/FAla/mW1Cdju7834TXug= github.com/RoaringBitmap/roaring/v2 v2.14.4 h1:4aKySrrg9G/5oRtJ3TrZLObVqxgQ9f1znCRBwEwjuVw= github.com/RoaringBitmap/roaring/v2 v2.14.4/go.mod h1:oMvV6omPWr+2ifRdeZvVJyaz+aoEUopyv5iH0u/+wbY= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -117,8 +115,8 @@ github.com/mailru/easyjson v0.9.1 h1:LbtsOm5WAswyWbvTEOqhypdPeZzHavpZx96/n553mR8 github.com/mailru/easyjson v0.9.1/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/matst80/go-redis-inventory v0.0.0-20251125181530-7ebbc97e3841 h1:CCHa+LuxwGOPPbIpuFYNT7VtC5rHjSulB337Y+Yyys8= github.com/matst80/go-redis-inventory v0.0.0-20251125181530-7ebbc97e3841/go.mod h1:d42+bHxhmMg73OQM+5i5U7vyEQfuVLJkt7QPsEbr8kI= -github.com/matst80/slask-finder v0.0.0-20251118173753-f66c21cfbda4 h1:yWwWkCaXhwrp5EAd6Z2Rd/n823K0Fz/A3+bqcAcn0qk= -github.com/matst80/slask-finder v0.0.0-20251118173753-f66c21cfbda4/go.mod h1:aqCC0Y1Jv+DhL36YHXf+0bZZkpQNMe9yFMcwgRSJ+Rc= +github.com/matst80/slask-finder v0.0.0-20251125182907-9e57f193127a h1:EfUO5BNDK3a563zQlwJYTNNv46aJFT9gbSItAwZOZ/Y= +github.com/matst80/slask-finder v0.0.0-20251125182907-9e57f193127a/go.mod h1:VIPNkIvU0dZKwbSuv75zZcB93MXISm2UyiIPly/ucXQ= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/pkg/cart/cart-grain.go b/pkg/cart/cart-grain.go index 8428849..050cf57 100644 --- a/pkg/cart/cart-grain.go +++ b/pkg/cart/cart-grain.go @@ -41,18 +41,18 @@ type CartItem struct { OrgPrice *Price `json:"orgPrice,omitempty"` Cgm string `json:"cgm,omitempty"` Tax int - Stock StockStatus `json:"stock"` - Quantity int `json:"qty"` - Discount *Price `json:"discount,omitempty"` - Disclaimer string `json:"disclaimer,omitempty"` - ArticleType string `json:"type,omitempty"` - StoreId *string `json:"storeId,omitempty"` - Meta *ItemMeta `json:"meta,omitempty"` - SaleStatus string `json:"saleStatus"` - Marking *Marking `json:"marking,omitempty"` - SubscriptionDetailsId string `json:"subscriptionDetailsId,omitempty"` - OrderReference string `json:"orderReference,omitempty"` - IsSubscribed bool `json:"isSubscribed,omitempty"` + Stock uint16 `json:"stock"` + Quantity int `json:"qty"` + Discount *Price `json:"discount,omitempty"` + Disclaimer string `json:"disclaimer,omitempty"` + ArticleType string `json:"type,omitempty"` + StoreId *string `json:"storeId,omitempty"` + Meta *ItemMeta `json:"meta,omitempty"` + SaleStatus string `json:"saleStatus"` + Marking *Marking `json:"marking,omitempty"` + SubscriptionDetailsId string `json:"subscriptionDetailsId,omitempty"` + OrderReference string `json:"orderReference,omitempty"` + IsSubscribed bool `json:"isSubscribed,omitempty"` } type CartDelivery struct { @@ -240,9 +240,9 @@ func (c *CartGrain) Notify(event actor.Event) { // Update stock status based on payload, e.g., if payload is bool available if available, ok := event.Payload.(bool); ok { if available { - item.Stock = StockStatus(1) // assuming 1 is in stock + item.Stock = 1 // assuming 1 is in stock } else { - item.Stock = StockStatus(0) // out of stock + item.Stock = 0 // out of stock } } break diff --git a/pkg/cart/mutation_add_item.go b/pkg/cart/mutation_add_item.go index 2631389..b286abb 100644 --- a/pkg/cart/mutation_add_item.go +++ b/pkg/cart/mutation_add_item.go @@ -39,7 +39,7 @@ func AddItem(g *CartGrain, m *messages.AddItem) error { continue } existing.Quantity += int(m.Quantity) - existing.Stock = StockStatus(m.Stock) + existing.Stock = uint16(m.Stock) // If existing had nil store but new has one, adopt it. if existing.StoreId == nil && m.StoreId != nil { existing.StoreId = m.StoreId @@ -84,7 +84,7 @@ func AddItem(g *CartGrain, m *messages.AddItem) error { Price: *pricePerItem, TotalPrice: *MultiplyPrice(*pricePerItem, int64(m.Quantity)), - Stock: StockStatus(m.Stock), + Stock: uint16(m.Stock), Disclaimer: m.Disclaimer, OrgPrice: getOrgPrice(m.OrgPrice, taxRate),