Skip to content
Permalink
Browse files
Merge pull request #20 from markusgeiss/develop
removed costs from validating open account transaction
  • Loading branch information
markusgeiss committed Oct 9, 2017
2 parents be0c5c2 + 7e177b0 commit 691a14eae3e13e8339dc6fd743fcee8786806611
Showing 1 changed file with 2 additions and 14 deletions.
@@ -340,26 +340,14 @@ private void verifyTellerTransaction(final Teller teller, final TellerTransactio
if (transactionType.equals(ServiceConstants.TX_OPEN_ACCOUNT)) {
final ProductDefinition productDefinition =
this.depositAccountManagementService.findProductDefinition(tellerTransaction.getProductIdentifier());
if (productDefinition.getMinimumBalance() != null && productDefinition.getMinimumBalance() > 0.00D) {
if (productDefinition.getMinimumBalance() != null
&& productDefinition.getMinimumBalance() > 0.00D) {
final BigDecimal minimumBalance = BigDecimal.valueOf(productDefinition.getMinimumBalance());
if (transactionAmount.compareTo(minimumBalance) < 0) {
throw ServiceException.conflict(
"Amount {0} must be equals or greater than minimum balance {1}.",
transactionAmount, minimumBalance);
}

final TellerTransactionCosts tellerTransactionCosts =
this.tellerTransactionProcessor.getCosts(tellerTransaction);
final BigDecimal costs = tellerTransactionCosts.getCharges()
.stream()
.map(Charge::getAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
final BigDecimal amountExcludingCosts = transactionAmount.subtract(costs != null ? costs : BigDecimal.ZERO);
if (amountExcludingCosts.compareTo(minimumBalance) < 0) {
throw ServiceException.conflict(
"Amount {0} excluding costs {1} must be equals or greater than minimum balance {2}.",
transactionAmount, costs, minimumBalance);
}
}
}

0 comments on commit 691a14e

Please sign in to comment.