feat[BE]:: add totalHppPricePerKg to marketing report summary

This commit is contained in:
aguhh18
2025-12-17 11:34:08 +07:00
parent 40f192660d
commit d9a1372077
@@ -33,10 +33,11 @@ type RepportMarketingItemDTO struct {
} }
type Summary struct { 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"`
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"`
} }
type RepportMarketingResponseDTO struct { type RepportMarketingResponseDTO struct {
@@ -130,11 +131,17 @@ func ToSummary(mdps []entity.MarketingDeliveryProduct, hppPricePerKg float64) *S
totalHppAmount += int64(calculatedTotalWeight * hppPricePerKg) totalHppAmount += int64(calculatedTotalWeight * hppPricePerKg)
} }
totalHppPricePerKg := float64(0)
if totalWeightKg > 0 {
totalHppPricePerKg = float64(totalHppAmount) / totalWeightKg
}
return &Summary{ return &Summary{
TotalQty: totalQty, TotalQty: totalQty,
TotalWeightKg: totalWeightKg, TotalWeightKg: totalWeightKg,
TotalSalesAmount: totalSalesAmount, TotalSalesAmount: totalSalesAmount,
TotalHppAmount: totalHppAmount, TotalHppAmount: totalHppAmount,
TotalHppPricePerKg: totalHppPricePerKg,
} }
} }