Skip to content
Permalink
Browse files
Merge pull request #16 from markusgeiss/develop
added trap for empty or not existing charges for cost components
  • Loading branch information
markusgeiss committed Oct 3, 2017
2 parents 082579a + 815b7db commit 8cb0b0ef9fc1e6d209fef14e29f0aad7bca3dad0
Showing 1 changed file with 14 additions and 8 deletions.
@@ -68,14 +68,20 @@ public List<Charge> getCharges(final String productIdentifier, final String case
final List<CostComponent> costComponents = payment.getCostComponents();

costComponents.forEach(costComponent -> {
final ChargeDefinition chargeDefinition =
this.portfolioManager.getChargeDefinition(productIdentifier, costComponent.getChargeIdentifier());

final Charge charge = new Charge();
charge.setCode(chargeDefinition.getIdentifier());
charge.setName(chargeDefinition.getName());
charge.setAmount(costComponent.getAmount());
charges.add(charge);
if (costComponent.getAmount() != null
&& costComponent.getAmount().compareTo(BigDecimal.ZERO) > 0) {
try {
final ChargeDefinition chargeDefinition =
this.portfolioManager.getChargeDefinition(productIdentifier, costComponent.getChargeIdentifier());
final Charge charge = new Charge();
charge.setCode(chargeDefinition.getIdentifier());
charge.setName(chargeDefinition.getName());
charge.setAmount(costComponent.getAmount());
charges.add(charge);
} catch (final NotFoundException nfex) {
this.logger.warn("Charge {} not found.", costComponent.getChargeIdentifier());
}
}
});
} catch (final NotFoundException | BadRequestException ex) {
throw ServiceException.internalError(

0 comments on commit 8cb0b0e

Please sign in to comment.