mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
FIX[BE]: Fix wrong calculation avg sales on report penjualan harian
This commit is contained in:
@@ -190,16 +190,13 @@ func ToSummaryFromDTOItems(items []RepportMarketingItemDTO) *Summary {
|
|||||||
totalWeightKg += item.TotalWeightKg
|
totalWeightKg += item.TotalWeightKg
|
||||||
totalSalesAmount += int64(item.SalesAmount)
|
totalSalesAmount += int64(item.SalesAmount)
|
||||||
totalHppAmount += int64(item.HppAmount)
|
totalHppAmount += int64(item.HppAmount)
|
||||||
avgSalesPrice += item.SalesPricePerKg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalHppPricePerKg := float64(0)
|
totalHppPricePerKg := float64(0)
|
||||||
|
|
||||||
if totalWeightKg > 0 {
|
if totalWeightKg > 0 {
|
||||||
totalHppPricePerKg = float64(totalHppAmount) / totalWeightKg
|
totalHppPricePerKg = float64(totalHppAmount) / totalWeightKg
|
||||||
}
|
avgSalesPrice = float64(totalSalesAmount) / totalWeightKg
|
||||||
|
|
||||||
if len(items) > 0 {
|
|
||||||
avgSalesPrice = avgSalesPrice / float64(len(items))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if totalQty > 0 {
|
if totalQty > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user