adjust calculate hpp filter delivery date marketing delivery

This commit is contained in:
giovanni
2026-01-26 11:44:22 +07:00
parent fdd8e3ec31
commit 7a8f813e1f
3 changed files with 56 additions and 45 deletions
@@ -1617,7 +1617,7 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
var avgWeight float64
eggHpp := 0.0
if s.HppSvc != nil {
hppCost, err := s.HppSvc.CalculateHppCost(row.ProjectFlockKandangID, &endOfDay)
hppCost, err := s.HppSvc.CalculateHppCost(row.ProjectFlockKandangID, &periodDate)
if err != nil {
return nil, nil, err
}
@@ -1626,7 +1626,9 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
eggHpp = hppCost.Estimation.HargaKg
eggTotalPiecesFloat = hppCost.Estimation.Butir
eggWeightFloat = hppCost.Estimation.Kg
avgWeight = eggWeightFloat / eggTotalPiecesFloat
if eggTotalPiecesFloat > 0 {
avgWeight = eggWeightFloat / eggTotalPiecesFloat
}
eggRemainingWeightFloatRemaining = avgWeight * eggPiecesFloatRemaining
}
}
@@ -1642,6 +1644,9 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
if math.IsNaN(eggWeightFloat) || math.IsInf(eggWeightFloat, 0) {
eggWeightFloat = 0
}
if math.IsNaN(avgWeight) || math.IsInf(avgWeight, 0) {
avgWeight = 0
}
if params.WeightMin != nil && avgWeight < *params.WeightMin {
continue