in service/src/main/java/org/apache/fineract/cn/teller/service/rest/TellerOperationRestController.java [377:400]
private void verifyChequeTransaction(final TellerTransaction tellerTransaction) {
if (tellerTransaction.getTransactionType().equals(ServiceConstants.TX_CHEQUE)) {
final LocalDate dateIssued = DateConverter.dateFromIsoString(tellerTransaction.getCheque().getDateIssued());
final LocalDate sixMonth = LocalDate.now(Clock.systemUTC()).minusMonths(6);
if (dateIssued.isBefore(sixMonth)) {
throw ServiceException.conflict("Cheque is older than 6 months.");
}
final MICR micr = tellerTransaction.getCheque().getMicr();
final String chequeIdentifier = MICRParser.toIdentifier(micr);
if (this.chequeService.chequeExists(chequeIdentifier)) {
throw ServiceException.conflict("Cheque {0} already used.", chequeIdentifier);
}
if (this.organizationService.officeExists(micr.getBranchSortCode())) {
this.accountingService.findAccount(micr.getAccountNumber()).ifPresent(account -> {
final BigDecimal balance = BigDecimal.valueOf(account.getBalance());
if (tellerTransaction.getAmount().compareTo(balance) > 0) {
throw ServiceException.conflict("Cheque not covered.");
}
});
}
}
}