public List getCharges()

in service/src/main/java/org/apache/fineract/cn/teller/service/internal/service/helper/PortfolioService.java [61:95]


  public List<Charge> getCharges(final String productIdentifier, final String caseIdentifier, final BigDecimal paymentSize) {

    final List<Charge> charges =  new ArrayList<>();

    try {
      final Payment payment = this.portfolioManager.getCostComponentsForAction(
          productIdentifier, caseIdentifier, Action.ACCEPT_PAYMENT.name(), Sets.newHashSet(), paymentSize);

      final List<CostComponent> costComponents = payment.getCostComponents();

      costComponents.forEach(costComponent -> {
        if (costComponent.getAmount() != null
            && costComponent.getAmount().compareTo(BigDecimal.ZERO) > 0) {
          final Charge charge = new Charge();
          charge.setCode(costComponent.getChargeIdentifier());
          charge.setAmount(costComponent.getAmount());
          try {
            final ChargeDefinition chargeDefinition =
                this.portfolioManager.getChargeDefinition(productIdentifier, costComponent.getChargeIdentifier());
            charge.setName(chargeDefinition.getName());
          } catch (final NotFoundException nfex) {
            this.logger.warn("Charge {} not found.", costComponent.getChargeIdentifier());
            charge.setName(costComponent.getChargeIdentifier());
          }
          charges.add(charge);
        }
      });
    } catch (final NotFoundException | BadRequestException ex) {
      throw ServiceException.internalError(
          "Could not fetch portfolio information, reason: {0}", ex.getCause() + " - " + ex.getMessage()
      );
    }

    return charges;
  }