Skip to content
Permalink
Browse files
removed costs from validating open account transaction
  • Loading branch information
mgeiss committed Oct 9, 2017
1 parent be0c5c2 commit 7e177b0ff0773ef9ac87301cb5d769f2f160fb2b
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 7e177b0

Please sign in to comment.