private OrderCost getOrderCost(final Transportable transportable,
final BigDecimal basisCost,
final Map<ITransportCostAddition, BigDecimal> additionalCost,
final Supplier supplier, final String orderCostComment)
throws ProTransException {
OrderCost orderCost = null;
StringBuilder costDetails = new StringBuilder();
BigDecimal additionValue = BigDecimal.valueOf(0);
if (additionalCost != null) {
additionValue = generateCostDetailsAndGetAdditionValue(basisCost,
additionalCost, costDetails, additionValue);
}
String comment = "";
if (orderCostComment != null) {
comment = orderCostComment;
} else if (costDetails.length() > 0) {
comment = costDetails.substring(0, costDetails.length() - 1);
}
if (transportable.getPostShipment() != null) {
comment = "Etterlevering:" + comment;
}
BigDecimal cost = basisCost.add(additionValue);
Order order = transportable.getOrder();
orderCost = new OrderCost();
orderCost.setComment(comment);
orderCost.setCostAmount(cost);
orderCost.setCostType(getCostType());
orderCost.setCostUnit(getCostUnit());
orderCost.setSupplier(supplier);
orderCost.setPostShipment(transportable.getPostShipment());
order.addOrderCost(orderCost);
return orderCost;
}