mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 14:55:42 +00:00
FIX[BE]: fixing report penjualan add avg weight and price to response
This commit is contained in:
@@ -41,7 +41,7 @@ type Summary struct {
|
|||||||
TotalQty int `json:"total_qty"`
|
TotalQty int `json:"total_qty"`
|
||||||
TotalWeightKg float64 `json:"total_weight_kg"`
|
TotalWeightKg float64 `json:"total_weight_kg"`
|
||||||
AverageWeightKg float64 `json:"average_weight_kg"`
|
AverageWeightKg float64 `json:"average_weight_kg"`
|
||||||
AverageSalesAmount float64 `json:"average_sales_amount"`
|
AverageSalesPrice float64 `json:"average_sales_price"`
|
||||||
TotalSalesAmount int64 `json:"total_sales_amount"`
|
TotalSalesAmount int64 `json:"total_sales_amount"`
|
||||||
TotalHppAmount int64 `json:"total_hpp_amount"`
|
TotalHppAmount int64 `json:"total_hpp_amount"`
|
||||||
TotalHppPricePerKg float64 `json:"total_hpp_price_per_kg"`
|
TotalHppPricePerKg float64 `json:"total_hpp_price_per_kg"`
|
||||||
@@ -180,7 +180,7 @@ func ToSummaryFromDTOItems(items []RepportMarketingItemDTO) *Summary {
|
|||||||
|
|
||||||
totalQty := 0
|
totalQty := 0
|
||||||
totalWeightKg := 0.0
|
totalWeightKg := 0.0
|
||||||
avgSalesAmount := 0.0
|
avgSalesPrice := 0.0
|
||||||
avgWeightKg := 0.0
|
avgWeightKg := 0.0
|
||||||
totalSalesAmount := int64(0)
|
totalSalesAmount := int64(0)
|
||||||
totalHppAmount := int64(0)
|
totalHppAmount := int64(0)
|
||||||
@@ -190,6 +190,7 @@ 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)
|
||||||
@@ -197,16 +198,19 @@ func ToSummaryFromDTOItems(items []RepportMarketingItemDTO) *Summary {
|
|||||||
totalHppPricePerKg = float64(totalHppAmount) / totalWeightKg
|
totalHppPricePerKg = float64(totalHppAmount) / totalWeightKg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(items) > 0 {
|
||||||
|
avgSalesPrice = avgSalesPrice / float64(len(items))
|
||||||
|
}
|
||||||
|
|
||||||
if totalQty > 0 {
|
if totalQty > 0 {
|
||||||
avgWeightKg = totalWeightKg / float64(totalQty)
|
avgWeightKg = totalWeightKg / float64(totalQty)
|
||||||
avgSalesAmount = float64(totalSalesAmount) / float64(totalQty)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Summary{
|
return &Summary{
|
||||||
TotalQty: totalQty,
|
TotalQty: totalQty,
|
||||||
TotalWeightKg: totalWeightKg,
|
TotalWeightKg: totalWeightKg,
|
||||||
AverageWeightKg: avgWeightKg,
|
AverageWeightKg: avgWeightKg,
|
||||||
AverageSalesAmount: avgSalesAmount,
|
AverageSalesPrice: avgSalesPrice,
|
||||||
TotalSalesAmount: totalSalesAmount,
|
TotalSalesAmount: totalSalesAmount,
|
||||||
TotalHppAmount: totalHppAmount,
|
TotalHppAmount: totalHppAmount,
|
||||||
TotalHppPricePerKg: totalHppPricePerKg,
|
TotalHppPricePerKg: totalHppPricePerKg,
|
||||||
|
|||||||
Reference in New Issue
Block a user