FIX[BE]: Fix wrong calculation avg sales on report penjualan harian

This commit is contained in:
aguhh18
2026-01-23 11:07:11 +07:00
parent 6b4eb758e4
commit f1787d3375
@@ -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 {