Search in sources :

Example 6 with FRTransactionData

use of com.forgerock.openbanking.common.model.openbanking.domain.account.FRTransactionData in project openbanking-aspsp by OpenBankingToolkit.

the class AcceptInternationalPaymentTask method createTransaction.

private FRTransaction createTransaction(Account account, FRInternationalConsent payment, FRCreditDebitIndicator creditDebitCode, Balance balance, FRAmount amount) {
    log.info("Create transaction");
    String transactionId = UUID.randomUUID().toString();
    DateTime bookingDate = new DateTime(payment.getCreated());
    FRTransactionData transactionData = FRTransactionData.builder().transactionId(transactionId).status(FRTransactionData.FREntryStatus.BOOKED).valueDateTime(DateTime.now()).accountId(account.getId()).amount(amount).creditDebitIndicator(creditDebitCode).bookingDateTime(bookingDate).statementReferences(new ArrayList<>()).balance(FRTransactionData.FRTransactionCashBalance.builder().amount(balance.getCurrencyAndAmount()).creditDebitIndicator(balance.getCreditDebitIndicator()).type(FRBalanceType.INTERIMBOOKED).build()).build();
    if (payment.getInitiation().getRemittanceInformation() != null) {
        transactionData.setTransactionReference(payment.getInitiation().getRemittanceInformation().getReference());
        transactionData.setTransactionInformation(payment.getInitiation().getRemittanceInformation().getUnstructured());
    }
    FRTransaction transaction = FRTransaction.builder().id(transactionId).bookingDateTime(bookingDate).accountId(account.getId()).transaction(transactionData).build();
    log.info("Transaction created {}", transaction);
    return transaction;
}
Also used : FRTransactionData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRTransactionData) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) DateTime(org.joda.time.DateTime)

Aggregations

FRTransactionData (com.forgerock.openbanking.common.model.openbanking.domain.account.FRTransactionData)6 FRTransaction (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction)6 DateTime (org.joda.time.DateTime)6 ArrayList (java.util.ArrayList)1