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
|
|
@ -257,27 +257,29 @@ public class ValidityPeriodRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
String validityPeriodSql = """
|
String validityPeriodSql = """
|
||||||
SELECT
|
SELECT
|
||||||
cj.validity_period_id,
|
cj.validity_period_id,
|
||||||
cj.property_set_id
|
cj.property_set_id
|
||||||
FROM
|
FROM
|
||||||
premise p
|
premise p
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
calculation_job cj ON p.id = cj.premise_id
|
calculation_job cj ON p.id = cj.premise_id
|
||||||
WHERE
|
INNER JOIN
|
||||||
p.material_id = ?
|
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 + """
|
+ whereClause + """
|
||||||
|
GROUP BY
|
||||||
GROUP BY
|
cj.validity_period_id,
|
||||||
cj.validity_period_id,
|
cj.property_set_id
|
||||||
cj.property_set_id
|
HAVING
|
||||||
HAVING
|
COUNT(DISTINCT COALESCE(p.supplier_node_id, p.user_supplier_node_id)) = ?
|
||||||
COUNT(DISTINCT COALESCE(p.supplier_node_id, p.user_supplier_node_id)) = ?
|
ORDER BY
|
||||||
ORDER BY
|
ps.start_date DESC, vp.start_date DESC
|
||||||
(SELECT start_date FROM validity_period WHERE id = cj.validity_period_id) DESC
|
""";
|
||||||
LIMIT 1
|
|
||||||
""";
|
|
||||||
|
|
||||||
// Build parameters array
|
// Build parameters array
|
||||||
Object[] params = new Object[1 + totalNodeCount + 1];
|
Object[] params = new Object[1 + totalNodeCount + 1];
|
||||||
|
|
|
||||||
|
|
@ -176,9 +176,12 @@ public class RouteSectionCostCalculationService {
|
||||||
|
|
||||||
var chanceRiskFactors = changeRiskFactorCalculationService.getChanceRiskFactors(setId, periodId);
|
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 annualCost = (containerCalculation.isWeightExceeded() ? prices.weightPrice.multiply(annualWeight) : prices.volumePrice.multiply(annualVolume));
|
||||||
BigDecimal annualRiskCost = RateType.MATRIX != section.getRateType() ? annualCost.multiply(chanceRiskFactors.getRiskFactor()) : annualCost;
|
BigDecimal annualRiskCost = useRiskChange ? annualCost.multiply(chanceRiskFactors.getRiskFactor()) : annualCost;
|
||||||
BigDecimal annualChanceCost = RateType.MATRIX != section.getRateType() ? annualCost.multiply(chanceRiskFactors.getChanceFactor()): annualCost;
|
BigDecimal annualChanceCost = useRiskChange ? annualCost.multiply(chanceRiskFactors.getChanceFactor()): annualCost;
|
||||||
|
|
||||||
result.setAnnualRiskCost(annualRiskCost);
|
result.setAnnualRiskCost(annualRiskCost);
|
||||||
result.setAnnualChanceCost(annualChanceCost);
|
result.setAnnualChanceCost(annualChanceCost);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue