in service/src/main/java/org/apache/fineract/cn/interoperation/service/internal/service/InteropService.java [182:213]
public InteropQuoteResponseData createQuote(@NotNull InteropQuoteRequestData request) {
//TODO: error handling
AccountWrapper accountWrapper = validateAndGetAccount(request);
//TODO: transaction expiration separated from action expiration
InteropTransactionEntity transaction = validateAndGetTransaction(request, accountWrapper);
TransactionType transactionType = request.getTransactionRole().getTransactionType();
String accountId = accountWrapper.account.getIdentifier();
List<Charge> charges = depositService.getCharges(accountId, transactionType);
BigDecimal amount = request.getAmount().getAmount();
BigDecimal fee = MathUtil.normalize(calcTotalCharges(charges, amount), MathUtil.DEFAULT_MATH_CONTEXT);
Double withdrawableBalance = getWithdrawableBalance(accountWrapper.account, accountWrapper.productDefinition);
boolean withdraw = request.getTransactionRole().isWithdraw();
BigDecimal total = MathUtil.nullToZero(withdraw ? MathUtil.add(amount, fee) : fee);
if (withdraw && withdrawableBalance < total.doubleValue())
throw new UnsupportedOperationException("Account balance is not enough to pay the fee " + accountId);
// TODO add action and set the status to failed in separated transaction
InteropActionEntity action = addAction(transaction, request);
action.setFee(fee);
// TODO: extend Charge with a property that could be stored in charges
transactionRepository.save(transaction);
InteropQuoteResponseData build = InteropQuoteResponseData.build(request.getTransactionCode(), action.getState(),
action.getExpirationDate(), request.getExtensionList(), request.getQuoteCode(),
MoneyData.build(fee, accountWrapper.productDefinition.getCurrency()), null);
return build;
}