Bugfix shippingfrequency
This commit is contained in:
parent
d606e3e33a
commit
eb5aecb1b5
2 changed files with 5 additions and 19 deletions
|
|
@ -213,7 +213,10 @@ public class CalculationExecutionService {
|
|||
destinationCalculationJob.setHuCount(sections.getFirst().containerResult().getHuUnitCount());
|
||||
|
||||
destinationCalculationJob.setAnnualAmount(BigDecimal.valueOf(destination.getAnnualAmount()));
|
||||
destinationCalculationJob.setShippingFrequency(shippingFrequencyCalculationService.doCalculation(setId, destination.getAnnualAmount(), selectedContainerCalculation.getHuPerContainer(),!premise.getHuMixable()));
|
||||
|
||||
|
||||
double huAnnualAmount = BigDecimal.valueOf(destination.getAnnualAmount()).divide(BigDecimal.valueOf(premise.getHuUnitCount()),4, RoundingMode.UP ).doubleValue();
|
||||
destinationCalculationJob.setShippingFrequency(Double.valueOf(shippingFrequencyCalculationService.doCalculation(setId, huAnnualAmount, selectedContainerCalculation.getHuPerContainer(),!premise.getHuMixable())).intValue());
|
||||
|
||||
var commonCost = destinationCalculationJob.getAnnualHandlingCost()
|
||||
.add(destinationCalculationJob.getAnnualDisposalCost())
|
||||
|
|
|
|||
|
|
@ -13,23 +13,6 @@ public class ShippingFrequencyCalculationService {
|
|||
this.propertyRepository = propertyRepository;
|
||||
}
|
||||
|
||||
public int doCalculation(Integer setId, int huAnnualAmount, int maxHuPerContainer, boolean fillContainer) {
|
||||
var minAnnualFrequency = Integer.parseInt(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.FREQ_MIN, setId).orElseThrow().getCurrentValue());
|
||||
var maxAnnualFrequency = Integer.parseInt(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.FREQ_MAX, setId).orElseThrow().getCurrentValue());
|
||||
|
||||
var fullContainers = huAnnualAmount / maxHuPerContainer;
|
||||
|
||||
|
||||
if(fillContainer && huAnnualAmount > maxAnnualFrequency)
|
||||
return fullContainers;
|
||||
|
||||
if (huAnnualAmount > maxAnnualFrequency)
|
||||
return maxAnnualFrequency;
|
||||
|
||||
return Math.max(huAnnualAmount, minAnnualFrequency);
|
||||
|
||||
}
|
||||
|
||||
public double doCalculation(Integer setId, double huAnnualAmount, int maxHuPerContainer, boolean fillContainer) {
|
||||
int minAnnualFrequency = Integer.parseInt(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.FREQ_MIN, setId).orElseThrow().getCurrentValue());
|
||||
int maxAnnualFrequency = Integer.parseInt(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.FREQ_MAX, setId).orElseThrow().getCurrentValue());
|
||||
|
|
@ -42,7 +25,7 @@ public class ShippingFrequencyCalculationService {
|
|||
if (huAnnualAmount > (double) maxAnnualFrequency)
|
||||
return maxAnnualFrequency;
|
||||
|
||||
return Math.max(huAnnualAmount, (double) minAnnualFrequency);
|
||||
return Math.max(huAnnualAmount, minAnnualFrequency);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue