Search in sources :

Example 11 with FRTransaction

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getAccountStatementTransactions.

@Override
public ResponseEntity<OBReadTransaction4> getAccountStatementTransactions(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "A unique identifier used to identify the statement resource.", required = true) @PathVariable("StatementId") String statementId, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions FROM  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = FROM_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime fromBookingDateTime, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions TO  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = TO_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime toBookingDateTime, @ApiParam(value = "The time when the PSU last logged in with the TPP.  " + "All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below:  " + "Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-first-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime firstAvailableDate, @RequestHeader(value = "x-ob-last-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime lastAvailableDate, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    LOGGER.info("Reading transations from account id {}, statement id {}, fromBookingDate {} toBookingDate {} " + "minimumPermissions {} pageNumber {} ", accountId, statementId, fromBookingDateTime, toBookingDateTime, permissions, page);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> response = FRTransactionRepository.byAccountIdAndStatementIdAndBookingDateTimeBetweenWithPermissions(accountId, statementId, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_TRANSACTIONS, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction4> transactions = response.getContent().stream().map(FRTransaction::getTransaction).map(FRTransactionConverter::toOBTransaction4).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction4().data(new OBReadTransaction4Data().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) FROM_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME) RequestParam(org.springframework.web.bind.annotation.RequestParam) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) AVAILABLE_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.AVAILABLE_DATE_FORMAT) Value(org.springframework.beans.factory.annotation.Value) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) OBReadTransaction4(uk.org.openbanking.datamodel.account.OBReadTransaction4) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) Sort(org.springframework.data.domain.Sort) BOOKED_TIME_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.BOOKED_TIME_DATE_FORMAT) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) Logger(org.slf4j.Logger) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) OBTransaction4(uk.org.openbanking.datamodel.account.OBTransaction4) List(java.util.List) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) OBReadTransaction4Data(uk.org.openbanking.datamodel.account.OBReadTransaction4Data) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) TO_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME) OBTransaction4(uk.org.openbanking.datamodel.account.OBTransaction4) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) OBReadTransaction4Data(uk.org.openbanking.datamodel.account.OBReadTransaction4Data) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction4(uk.org.openbanking.datamodel.account.OBReadTransaction4)

Example 12 with FRTransaction

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getAccountTransactions.

@Override
public ResponseEntity<OBReadTransaction3> getAccountTransactions(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions FROM  NB Time component is optional - set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = FROM_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime fromBookingDateTime, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions TO  NB Time component is optional - set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = TO_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime toBookingDateTime, @ApiParam(value = "The time when the PSU last logged in with the TPP.  All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below:  Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-first-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime firstAvailableDate, @RequestHeader(value = "x-ob-last-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime lastAvailableDate, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    LOGGER.info("Read transactions for account  {} with minimumPermissions {}", accountId, permissions);
    LOGGER.debug("transactionStore request transactionFrom {} transactionTo {} ", fromBookingDateTime, toBookingDateTime);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> response = frTransactionRepository.byAccountIdAndBookingDateTimeBetweenWithPermissions(accountId, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_TRANSACTIONS, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction3> transactions = response.getContent().stream().map(t -> toOBTransaction3(t.getTransaction())).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction3().data(new OBReadTransaction3Data().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) FROM_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME) RequestParam(org.springframework.web.bind.annotation.RequestParam) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) AVAILABLE_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.AVAILABLE_DATE_FORMAT) Value(org.springframework.beans.factory.annotation.Value) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) OBReadTransaction3(uk.org.openbanking.datamodel.account.OBReadTransaction3) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) Sort(org.springframework.data.domain.Sort) BOOKED_TIME_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.BOOKED_TIME_DATE_FORMAT) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) Logger(org.slf4j.Logger) FRTransactionConverter.toOBTransaction3(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter.toOBTransaction3) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) OBReadTransaction3Data(uk.org.openbanking.datamodel.account.OBReadTransaction3Data) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) OBTransaction3(uk.org.openbanking.datamodel.account.OBTransaction3) List(java.util.List) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) TO_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME) FRTransactionConverter.toOBTransaction3(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter.toOBTransaction3) OBTransaction3(uk.org.openbanking.datamodel.account.OBTransaction3) OBReadTransaction3Data(uk.org.openbanking.datamodel.account.OBReadTransaction3Data) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction3(uk.org.openbanking.datamodel.account.OBReadTransaction3)

Example 13 with FRTransaction

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getAccountTransactions.

@Override
public ResponseEntity<OBReadTransaction5> getAccountTransactions(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions FROM  NB Time component is optional - set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = FROM_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime fromBookingDateTime, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions TO  NB Time component is optional - set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = TO_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime toBookingDateTime, @ApiParam(value = "The time when the PSU last logged in with the TPP.  All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below:  Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-first-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime firstAvailableDate, @RequestHeader(value = "x-ob-last-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime lastAvailableDate, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    log.info("Read transactions for account  {} with minimumPermissions {}", accountId, permissions);
    log.debug("transactionStore request transactionFrom {} transactionTo {} ", fromBookingDateTime, toBookingDateTime);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> response = FRTransactionRepository.byAccountIdAndBookingDateTimeBetweenWithPermissions(accountId, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_TRANSACTIONS, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction5> transactions = response.getContent().stream().map(FRTransaction::getTransaction).map(FRTransactionConverter::toOBTransaction5).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction5().data(new OBReadTransaction5Data().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) FROM_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME) RequestParam(org.springframework.web.bind.annotation.RequestParam) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction5Data(uk.org.openbanking.datamodel.account.OBReadTransaction5Data) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) AVAILABLE_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.AVAILABLE_DATE_FORMAT) Value(org.springframework.beans.factory.annotation.Value) OBReadTransaction5(uk.org.openbanking.datamodel.account.OBReadTransaction5) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) Sort(org.springframework.data.domain.Sort) BOOKED_TIME_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.BOOKED_TIME_DATE_FORMAT) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) OBTransaction5(uk.org.openbanking.datamodel.account.OBTransaction5) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) TO_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME) OBReadTransaction5Data(uk.org.openbanking.datamodel.account.OBReadTransaction5Data) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) OBReadTransaction5(uk.org.openbanking.datamodel.account.OBReadTransaction5) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBTransaction5(uk.org.openbanking.datamodel.account.OBTransaction5)

Example 14 with FRTransaction

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction in project openbanking-aspsp by OpenBankingToolkit.

the class AcceptDomesticPaymentTask method createTransaction.

private FRTransaction createTransaction(Account account, FRDomesticConsent payment, FRCreditDebitIndicator creditDebitIndicator, 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(creditDebitIndicator).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)

Example 15 with FRTransaction

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction in project openbanking-aspsp by OpenBankingToolkit.

the class AcceptDueStandingOrderTask method createTransaction.

private FRTransaction createTransaction(Account account, FRStandingOrder payment, FRCreditDebitIndicator creditDebitCode, Balance balance, FRAmount amount) {
    log.debug("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.getStandingOrder().getReference() != null) {
        transactionData.setTransactionReference(payment.getStandingOrder().getReference());
    }
    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

FRTransaction (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction)26 DateTime (org.joda.time.DateTime)23 FRTransactionRepository (com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository)17 PaginationUtil (com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil)17 FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList (com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList)17 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)17 List (java.util.List)17 Collectors (java.util.stream.Collectors)17 Value (org.springframework.beans.factory.annotation.Value)17 Page (org.springframework.data.domain.Page)17 PageRequest (org.springframework.data.domain.PageRequest)17 Sort (org.springframework.data.domain.Sort)17 ResponseEntity (org.springframework.http.ResponseEntity)17 Controller (org.springframework.stereotype.Controller)17 OBExternalPermissions1Code (uk.org.openbanking.datamodel.account.OBExternalPermissions1Code)17 FROM_BOOKING_DATE_TIME (com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME)14 TO_BOOKING_DATE_TIME (com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME)14 ApiParam (io.swagger.annotations.ApiParam)14 Autowired (org.springframework.beans.factory.annotation.Autowired)14 DateTimeFormat (org.springframework.format.annotation.DateTimeFormat)14