Bugfix:
- taking the newest validity tuple, when fetching reports - risk and changes are only calculated for main run (and not all sections)
This commit is contained in:
parent
0c88c5ed0f
commit
2aaf820bdc
2 changed files with 27 additions and 22 deletions
|
|
@ -264,19 +264,21 @@ public class ValidityPeriodRepository {
|
|||
premise p
|
||||
INNER JOIN
|
||||
calculation_job cj ON p.id = cj.premise_id
|
||||
INNER JOIN
|
||||
validity_period vp ON cj.validity_period_id = vp.id
|
||||
INNER JOIN
|
||||
property_set ps ON cj.property_set_id = ps.id
|
||||
WHERE
|
||||
p.material_id = ?
|
||||
"""
|
||||
+ whereClause + """
|
||||
|
||||
GROUP BY
|
||||
cj.validity_period_id,
|
||||
cj.property_set_id
|
||||
HAVING
|
||||
COUNT(DISTINCT COALESCE(p.supplier_node_id, p.user_supplier_node_id)) = ?
|
||||
ORDER BY
|
||||
(SELECT start_date FROM validity_period WHERE id = cj.validity_period_id) DESC
|
||||
LIMIT 1
|
||||
ps.start_date DESC, vp.start_date DESC
|
||||
""";
|
||||
|
||||
// Build parameters array
|
||||
|
|
|
|||
|
|
@ -176,9 +176,12 @@ public class RouteSectionCostCalculationService {
|
|||
|
||||
var chanceRiskFactors = changeRiskFactorCalculationService.getChanceRiskFactors(setId, periodId);
|
||||
|
||||
var useRiskChange = (RateType.MATRIX != section.getRateType()) && (TransportType.RAIL == section.getTransportType() || TransportType.SEA == section.getTransportType());
|
||||
|
||||
|
||||
BigDecimal annualCost = (containerCalculation.isWeightExceeded() ? prices.weightPrice.multiply(annualWeight) : prices.volumePrice.multiply(annualVolume));
|
||||
BigDecimal annualRiskCost = RateType.MATRIX != section.getRateType() ? annualCost.multiply(chanceRiskFactors.getRiskFactor()) : annualCost;
|
||||
BigDecimal annualChanceCost = RateType.MATRIX != section.getRateType() ? annualCost.multiply(chanceRiskFactors.getChanceFactor()): annualCost;
|
||||
BigDecimal annualRiskCost = useRiskChange ? annualCost.multiply(chanceRiskFactors.getRiskFactor()) : annualCost;
|
||||
BigDecimal annualChanceCost = useRiskChange ? annualCost.multiply(chanceRiskFactors.getChanceFactor()): annualCost;
|
||||
|
||||
result.setAnnualRiskCost(annualRiskCost);
|
||||
result.setAnnualChanceCost(annualChanceCost);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue