private BigDecimal validateTransfer()

in service/src/main/java/org/apache/fineract/cn/interoperation/service/internal/service/InteropService.java [665:689]


    private BigDecimal validateTransfer(@NotNull InteropTransferRequestData request, @NotNull AccountWrapper accountWrapper) {
        BigDecimal amount = request.getAmount().getAmount();

        boolean isDebit = request.getTransactionRole().isWithdraw();
        Currency currency = accountWrapper.productDefinition.getCurrency();

        BigDecimal total = isDebit ? amount : MathUtil.negate(amount);
        MoneyData fspFee = request.getFspFee();
        if (fspFee != null) {
            if (!currency.getCode().equals(fspFee.getCurrency()))
                throw new UnsupportedOperationException();
            //TODO: compare with calculated quote fee
            total = MathUtil.add(total, fspFee.getAmount());
        }
        MoneyData fspCommission = request.getFspCommission();
        if (fspCommission != null) {
            if (!currency.getCode().equals(fspCommission.getCurrency()))
                throw new UnsupportedOperationException();
            //TODO: compare with calculated quote commission
            total = MathUtil.subtractToZero(total, fspCommission.getAmount());
        }
        if (isDebit && accountWrapper.withdrawableBalance < request.getAmount().getAmount().doubleValue())
            throw new UnsupportedOperationException();
        return total;
    }