diff --git a/internal/modules/repports/dto/repportMarketing.dto.go b/internal/modules/repports/dto/repportMarketing.dto.go index 336b6576..b12fdfeb 100644 --- a/internal/modules/repports/dto/repportMarketing.dto.go +++ b/internal/modules/repports/dto/repportMarketing.dto.go @@ -190,16 +190,13 @@ func ToSummaryFromDTOItems(items []RepportMarketingItemDTO) *Summary { totalWeightKg += item.TotalWeightKg totalSalesAmount += int64(item.SalesAmount) totalHppAmount += int64(item.HppAmount) - avgSalesPrice += item.SalesPricePerKg } totalHppPricePerKg := float64(0) + if totalWeightKg > 0 { totalHppPricePerKg = float64(totalHppAmount) / totalWeightKg - } - - if len(items) > 0 { - avgSalesPrice = avgSalesPrice / float64(len(items)) + avgSalesPrice = float64(totalSalesAmount) / totalWeightKg } if totalQty > 0 {