mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
adjust value hpp
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
commonRepo "gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
@@ -238,10 +239,10 @@ func (s *hppService) GetHppEstimationDanRealisasi(totalProductionCost float64, p
|
||||
Butir: estimPieces,
|
||||
}
|
||||
if estimWeightKg > 0 {
|
||||
estimation.HargaKg = totalProductionCost / estimWeightKg
|
||||
estimation.HargaKg = roundToTwoDecimals(totalProductionCost / estimWeightKg)
|
||||
}
|
||||
if estimPieces > 0 {
|
||||
estimation.HargaButir = totalProductionCost / estimPieces
|
||||
estimation.HargaButir = roundToTwoDecimals(totalProductionCost / estimPieces)
|
||||
}
|
||||
|
||||
real := HppCostDetail{
|
||||
@@ -250,10 +251,10 @@ func (s *hppService) GetHppEstimationDanRealisasi(totalProductionCost float64, p
|
||||
Butir: realPieces,
|
||||
}
|
||||
if realWeightKg > 0 {
|
||||
real.HargaKg = totalProductionCost / realWeightKg
|
||||
real.HargaKg = roundToTwoDecimals(totalProductionCost / realWeightKg)
|
||||
}
|
||||
if realPieces > 0 {
|
||||
real.HargaButir = totalProductionCost / realPieces
|
||||
real.HargaButir = roundToTwoDecimals(totalProductionCost / realPieces)
|
||||
}
|
||||
|
||||
return &HppCostResponse{
|
||||
@@ -261,3 +262,7 @@ func (s *hppService) GetHppEstimationDanRealisasi(totalProductionCost float64, p
|
||||
Real: real,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func roundToTwoDecimals(value float64) float64 {
|
||||
return math.Round(value*100) / 100
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user