public List getCharges()

in service/src/main/java/org/apache/fineract/cn/teller/service/internal/service/helper/DepositAccountManagementService.java [63:97]


  public List<Charge> getCharges(final TellerTransaction tellerTransaction) {
    final List<Charge> charges = new ArrayList<>();
    final ProductDefinition productDefinition =
        this.depositAccountManager.findProductDefinition(tellerTransaction.getProductIdentifier());
    final List<Action> actions = this.depositAccountManager.fetchActions();

    final HashMap<String, Action> mappedActions = new HashMap<>(actions.size());
    actions.forEach(action -> mappedActions.put(action.getIdentifier(), action));

    final MathContext mathContext = new MathContext(2, RoundingMode.HALF_EVEN);
    final Set<org.apache.fineract.cn.deposit.api.v1.definition.domain.Charge> productCharges = productDefinition.getCharges();
    productCharges.forEach(productCharge -> {
      if (productCharge.getAmount() > 0.00D) {
        final Action action = mappedActions.get(productCharge.getActionIdentifier());
        if (action != null
            && action.getTransactionType().equals(tellerTransaction.getTransactionType())) {
          final Charge charge = new Charge();
          charge.setCode(productCharge.getActionIdentifier());
          charge.setIncomeAccountIdentifier(productCharge.getIncomeAccountIdentifier());
          charge.setName(productCharge.getName());
          if (productCharge.getProportional()) {
            charge.setAmount(
                tellerTransaction.getAmount().multiply(
                    BigDecimal.valueOf(productCharge.getAmount()).divide(BigDecimal.valueOf(100.00D), mathContext)
                )
            );
          } else {
            charge.setAmount(BigDecimal.valueOf(productCharge.getAmount()));
          }
          charges.add(charge);
        }
      }
    });
    return charges;
  }