diff --git a/internal/contract/analytics_contract.go b/internal/contract/analytics_contract.go index 89c3327..f7d019a 100644 --- a/internal/contract/analytics_contract.go +++ b/internal/contract/analytics_contract.go @@ -162,6 +162,7 @@ type ProductAnalyticsData struct { ProductID uuid.UUID `json:"product_id"` ProductName string `json:"product_name"` ProductSku string `json:"product_sku"` + ProductPrice float64 `json:"product_price"` CategoryID uuid.UUID `json:"category_id"` CategoryName string `json:"category_name"` CategoryOrder int `json:"category_order"` diff --git a/internal/entities/analytics.go b/internal/entities/analytics.go index 8cea304..0fa8bda 100644 --- a/internal/entities/analytics.go +++ b/internal/entities/analytics.go @@ -76,6 +76,7 @@ type ProductAnalytics struct { ProductID uuid.UUID `json:"product_id"` ProductName string `json:"product_name"` ProductSku string `json:"product_sku"` + ProductPrice float64 `json:"product_price"` CategoryID uuid.UUID `json:"category_id"` CategoryName string `json:"category_name"` CategoryOrder int `json:"category_order"` diff --git a/internal/models/analytics.go b/internal/models/analytics.go index 4b94cba..ec8858d 100644 --- a/internal/models/analytics.go +++ b/internal/models/analytics.go @@ -172,6 +172,7 @@ type ProductAnalyticsData struct { ProductID uuid.UUID `json:"product_id"` ProductName string `json:"product_name"` ProductSku string `json:"product_sku"` + ProductPrice float64 `json:"product_price"` CategoryID uuid.UUID `json:"category_id"` CategoryName string `json:"category_name"` CategoryOrder int `json:"category_order"` diff --git a/internal/processor/analytics_processor.go b/internal/processor/analytics_processor.go index c8e41f6..d08a523 100644 --- a/internal/processor/analytics_processor.go +++ b/internal/processor/analytics_processor.go @@ -264,6 +264,7 @@ func (p *AnalyticsProcessorImpl) GetProductAnalytics(ctx context.Context, req *m ProductID: data.ProductID, ProductName: data.ProductName, ProductSku: data.ProductSku, + ProductPrice: data.ProductPrice, CategoryID: data.CategoryID, CategoryName: data.CategoryName, CategoryOrder: data.CategoryOrder, diff --git a/internal/repository/analytics_repository.go b/internal/repository/analytics_repository.go index b250dc9..62a9a90 100644 --- a/internal/repository/analytics_repository.go +++ b/internal/repository/analytics_repository.go @@ -284,6 +284,7 @@ func (r *AnalyticsRepositoryImpl) GetProductAnalytics(ctx context.Context, organ Select(` p.id as product_id, p.name as product_name, + p.price as product_price, c.id as category_id, c.name as category_name, c.order as category_order, @@ -342,7 +343,7 @@ func (r *AnalyticsRepositoryImpl) GetProductAnalytics(ctx context.Context, organ query = r.resolveOutletID(query, outletID, "o.outlet_id") err := query. - Group("p.id, p.name, p.cost, c.id, c.name, c.order, mahpp.hpp_per_unit"). + Group("p.id, p.name, p.price, p.cost, c.id, c.name, c.order, mahpp.hpp_per_unit"). Order("revenue DESC"). Limit(limit). Scan(&results).Error diff --git a/internal/transformer/analytics_transformer.go b/internal/transformer/analytics_transformer.go index f0538c4..f157598 100644 --- a/internal/transformer/analytics_transformer.go +++ b/internal/transformer/analytics_transformer.go @@ -257,6 +257,7 @@ func ProductAnalyticsModelToContract(resp *models.ProductAnalyticsResponse) *con ProductID: item.ProductID, ProductName: item.ProductName, ProductSku: item.ProductSku, + ProductPrice: item.ProductPrice, CategoryID: item.CategoryID, CategoryName: item.CategoryName, CategoryOrder: item.CategoryOrder, @@ -367,6 +368,7 @@ func DashboardAnalyticsModelToContract(resp *models.DashboardAnalyticsResponse) topProducts = append(topProducts, contract.ProductAnalyticsData{ ProductID: item.ProductID, ProductName: item.ProductName, + ProductPrice: item.ProductPrice, CategoryID: item.CategoryID, CategoryName: item.CategoryName, QuantitySold: item.QuantitySold,