mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
FIX[BE] fix wrong calculation on summary report marketing
This commit is contained in:
@@ -90,19 +90,22 @@ func ToSalesDTO(e entity.MarketingDeliveryProduct) SalesDTO {
|
|||||||
|
|
||||||
func ToSummaryDto(e []entity.MarketingDeliveryProduct) SummaryDTO {
|
func ToSummaryDto(e []entity.MarketingDeliveryProduct) SummaryDTO {
|
||||||
|
|
||||||
var totalSalesPrice, totalActualPrice float64
|
var totalSalesPrice, totalActualPrice, sumSales, sumActual float64
|
||||||
count := len(e)
|
count := len(e)
|
||||||
|
|
||||||
for _, item := range e {
|
for _, item := range e {
|
||||||
totalSalesPrice += item.MarketingProduct.TotalPrice
|
totalSalesPrice += item.MarketingProduct.TotalPrice
|
||||||
totalActualPrice += item.TotalPrice
|
totalActualPrice += item.TotalPrice
|
||||||
|
sumSales += item.MarketingProduct.UnitPrice
|
||||||
|
sumActual += item.UnitPrice
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SummaryDTO{
|
return SummaryDTO{
|
||||||
TotalSalesPrice: totalSalesPrice,
|
TotalSalesPrice: totalSalesPrice,
|
||||||
TotalActualPrice: totalActualPrice,
|
TotalActualPrice: totalActualPrice,
|
||||||
AvgSalesPrice: totalSalesPrice / float64(count),
|
AvgSalesPrice: sumSales / float64(count),
|
||||||
AvgActualPrice: totalActualPrice / float64(count),
|
AvgActualPrice: sumActual / float64(count),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user