in service/src/main/java/org/apache/fineract/cn/interoperation/service/internal/service/InteropService.java [751:775]
private InteropTransactionEntity validateAndGetTransaction(@NotNull InteropRequestData request, @NotNull AccountWrapper accountWrapper,
@NotNull LocalDateTime createdOn, boolean create) {
//TODO: error handling
String transactionCode = request.getTransactionCode();
InteropTransactionEntity transaction = transactionRepository.findOneByIdentifier(request.getTransactionCode());
InteropState state = InteropStateMachine.handleTransition(transaction == null ? null : transaction.getState(), request.getActionType());
LocalDateTime now = getNow();
if (transaction == null) {
if (!create)
throw new UnsupportedOperationException("Interperation transaction " + request.getTransactionCode() + " does not exist ");
transaction = new InteropTransactionEntity(transactionCode, accountWrapper.account.getIdentifier(), getLoginUser(), now);
transaction.setState(state);
transaction.setAmount(request.getAmount().getAmount());
transaction.setName(request.getNote());
transaction.setTransactionType(request.getTransactionRole().getTransactionType());
Account payableAccount = validateAndGetPayableAccount(request, accountWrapper);
transaction.setPrepareAccountIdentifier(payableAccount == null ? null : payableAccount.getIdentifier());
transaction.setNostroAccountIdentifier(validateAndGetNostroAccount(request).getIdentifier());
transaction.setExpirationDate(request.getExpiration());
}
LocalDateTime expirationDate = transaction.getExpirationDate();
if (expirationDate != null && expirationDate.isBefore(now))
throw new UnsupportedOperationException("Interperation transaction expired on " + expirationDate);
return transaction;
}