private static Konto createAccount(HBCIDialog dialog, BankAccount bankAccount) { Konto account = dialog.getPassport().findAccountByAccountNumber(bankAccount.getAccountNumber()); account.iban = bankAccount.getIban(); account.bic = bankAccount.getBic(); return account; }
private void filterAccounts(BankAccessEntity bankAccess, OnlineBankingService onlineBankingService, List<BankAccount> bankAccounts) { UserData userData = uds.load(); List<BankAccountData> userBankAccounts = userData.bankAccessDataOrException(bankAccess.getId()).getBankAccounts(); // List<BankAccountEntity> userBankAccounts = loadForBankAccess(bankAccess.getId()); //filter out previous created accounts Iterator<BankAccount> accountIterator = bankAccounts.iterator(); while (accountIterator.hasNext()) { BankAccount newAccount = accountIterator.next(); userBankAccounts.stream().filter(bankAccountData -> { String newAccountExternalID = newAccount.getExternalIdMap().get(onlineBankingService.bankApi()); String existingAccountExternalID = bankAccountData.getBankAccount().getExternalIdMap().get(onlineBankingService.bankApi()); return newAccountExternalID.equals(existingAccountExternalID); }).findFirst().ifPresent(bankAccountEntity -> { accountIterator.remove(); }); } //all accounts created in the past if (bankAccounts.size() == 0) { throw new BankAccessAlreadyExistException(bankAccess.getId()); } bankAccess.setBankName(bankAccounts.get(0).getBankName()); }
public void updateSearchIndex(List<BookingEntity> bookings) { bookingIdSearchList = new HashMap<>(); new LinkedList<>(bookings) .descendingIterator() .forEachRemaining(booking -> { List<String> search = new ArrayList(); if (booking.getBookingCategory() != null) { if (StringUtils.hasText(booking.getBookingCategory().getReceiver())) { search.add(booking.getBookingCategory().getReceiver()); } } if (booking.getOtherAccount() != null) { if (StringUtils.hasText(booking.getOtherAccount().getName())) { search.add(booking.getOtherAccount().getName()); } if (StringUtils.hasText(booking.getOtherAccount().getOwner())) { search.add(booking.getOtherAccount().getOwner()); } } bookingIdSearchList.put(booking.getId(), search); }); } }
public static BankAccount toBankAccount(Konto konto) { BankAccount bankAccount = new BankAccount(); bankAccount.accountNumber(konto.number); bankAccount.bic(konto.bic); bankAccount.blz(konto.blz); bankAccount.country(konto.country); bankAccount.currency(konto.curr); bankAccount.iban(konto.iban); bankAccount.owner((konto.name + (konto.name2 != null ? konto.name2 : "")).trim()); bankAccount.name(konto.type); bankAccount.type(BankAccountType.fromHbciType(NumberUtils.toInt(konto.acctype))); return bankAccount; }
public static BankAccount mapBookingAccount(Transaction transaction) { BankAccount bankAccount = new BankAccount(); bankAccount.setName(transaction.getName()); bankAccount.setBankName(transaction.getBankName()); bankAccount.setCurrency(transaction.getCurrency()); bankAccount.setAccountNumber(transaction.getAccountNumber()); bankAccount.setBlz(transaction.getBankCode()); bankAccount.setIban(Utils.extractIban(transaction.getPurposeText())); return bankAccount; }
public static BankAccount mapBankAccount(Account account, BankApi bankApi) { return new BankAccount() .externalId(bankApi, account.getAccountId()) .owner(account.getOwner()) .accountNumber(account.getAccountNumber()) .name(account.getName()) .bankName(account.getBankName()) .bic(account.getBIC()) .blz(account.getBankCode()) .iban(account.getIBAN()) .type(BankAccountType.fromFigoType(account.getType())) .bankAccountBalance(new BalancesReport() .readyHbciBalance(Balance.builder().amount(account.getBalance().getBalance()).build())); }
static List<Booking> convertInput(Collection<BookingEntity> bookings) { List<Booking> interfaceBookings = new ArrayList<>(); for (BookingEntity booking : bookings) { Booking smartanalyticsBooking = new Booking(); smartanalyticsBooking.setBookingId(booking.getExternalId()); smartanalyticsBooking.setCreditorId(booking.getCreditorId()); smartanalyticsBooking.setPurpose(booking.getUsage()); smartanalyticsBooking.setIban(booking.getOtherAccount() != null ? booking.getOtherAccount().getIban() : null); smartanalyticsBooking.setAccountNumber(booking.getOtherAccount() != null ? booking.getOtherAccount().getAccountNumber() : null); smartanalyticsBooking.setBankCode(booking.getOtherAccount() != null ? booking.getOtherAccount().getBlz() : null); smartanalyticsBooking.setAmount(booking.getAmount()); smartanalyticsBooking.setExecutionDate(booking.getValutaDate()); smartanalyticsBooking.setStandingOrder(booking.isStandingOrder()); smartanalyticsBooking.setMandateReference(booking.getMandateReference()); if (booking.getOtherAccount() != null) { if (booking.getOtherAccount().getOwner() != null) { smartanalyticsBooking.setReferenceName(booking.getOtherAccount().getOwner()); } else { smartanalyticsBooking.setReferenceName(booking.getOtherAccount().getName()); } } interfaceBookings.add(smartanalyticsBooking); } return interfaceBookings; }
LOG.debug("load bookings for account [{}]", bankAccount.getAccountNumber()); ApiClient apiClient = createUserApiClient(); apiClient.setAccessToken(authorizeUser(loadBookingsRequest.getBankApiUser())); List<Long> accountIds = Arrays.asList(Long.parseLong(bankAccount.getExternalIdMap().get(bankApi()))); List<String> order = Arrays.asList("id,desc"); booking.setOtherAccount(new BankAccount()); booking.getOtherAccount().setName(transaction.getCounterpartName()); booking.getOtherAccount().setAccountNumber(transaction.getCounterpartAccountNumber()); booking.getOtherAccount().setIban(Utils.extractIban(transaction.getPurpose())); LOG.info("loaded [{}] bookings for account [{}]", bookingList.size(), bankAccount.getAccountNumber());
public static domain.StandingOrder mapStandingOrder(StandingOrder figoStandingOrder) { domain.StandingOrder standingOrder = new domain.StandingOrder(); standingOrder.setOrderId(figoStandingOrder.getStandingOrderId()); standingOrder.setExecutionDay(figoStandingOrder.getExecutionDay()); standingOrder.setAmount(figoStandingOrder.getAmount()); standingOrder.setUsage(figoStandingOrder.getPurposeText()); standingOrder.setCycle(Cycle.valueOf(figoStandingOrder.getInterval().toString())); standingOrder.setOtherAccount(new BankAccount() .owner(figoStandingOrder.getName()) .accountNumber(figoStandingOrder.getAccountNumber()) .blz(figoStandingOrder.getBankCode()) .currency(figoStandingOrder.getCurrency()) ); return standingOrder; }
@Override protected AbstractSEPAGV createHbciJob(AbstractScaTransaction transaction, PinTanPassport passport, String rawData) { StandingOrder standingOrder = (StandingOrder) transaction; Konto src = getDebtorAccount(transaction, passport); Konto dst = new Konto(); dst.name = standingOrder.getOtherAccount().getOwner(); dst.iban = standingOrder.getOtherAccount().getIban(); dst.bic = standingOrder.getOtherAccount().getBic(); GVDauerSEPANew gvDauerSEPANew = new GVDauerSEPANew(passport, rawData); gvDauerSEPANew.setParam("src", src); gvDauerSEPANew.setParam("dst", dst); gvDauerSEPANew.setParam("btg", new Value(standingOrder.getAmount())); gvDauerSEPANew.setParam("usage", standingOrder.getUsage()); // standing order specific parameter if (standingOrder.getFirstExecutionDate() != null) { gvDauerSEPANew.setParam("firstdate", standingOrder.getFirstExecutionDate().toString()); } if (standingOrder.getCycle() != null) { gvDauerSEPANew.setParam("timeunit", HbciMapping.cycleToTimeunit(standingOrder.getCycle())); // M month, W week gvDauerSEPANew.setParam("turnus", HbciMapping.cycleToTurnus(standingOrder.getCycle())); // 1W = every week, 2M = every two months } gvDauerSEPANew.setParam("execday", standingOrder.getExecutionDay()); // W: 1-7, M: 1-31 if (standingOrder.getLastExecutionDate() != null) { gvDauerSEPANew.setParam("lastdate", standingOrder.getLastExecutionDate().toString()); } gvDauerSEPANew.verifyConstraints(); return gvDauerSEPANew; }
/** * Anonymizes and stores booking in the user object space. * * @param bookings */ public List<AnonymizedBookingEntity> anonymizeAndStoreBookingsAsync(List<BookingEntity> bookingEntities) { List<BookingEntity> uncategorizedBookings = bookingEntities.stream() .filter(bookingEntity -> bookingEntity.getBookingCategory() == null && (bookingEntity.getCreditorId() != null || (bookingEntity.getOtherAccount()!=null && bookingEntity.getOtherAccount().getIban()!=null) || bookingEntity.getUsage()!=null)) .collect(Collectors.toList()); return uncategorizedBookings.stream() .map(bookingEntity -> anonymizeBooking(bookingEntity)) .collect(Collectors.toList()); }
dbBankAccounts.forEach(dbBankAccountData -> { BankAccountEntity dbBankAccount = dbBankAccountData.getBankAccount(); if (apiBankAccount.getAccountNumber().equals(dbBankAccount.getAccountNumber())) { dbBankAccount.externalId(onlineBankingService.bankApi(), apiBankAccount.getExternalIdMap().get(onlineBankingService.bankApi())); if (bankAccess.getId().equals(dbBankAccount.getId())) { bankAccess.externalId(onlineBankingService.bankApi(), apiBankAccount.getExternalIdMap().get(onlineBankingService.bankApi()));
BankAccountEntity target = new BankAccountEntity(); target.id(source.getIban()); String idToBeUsed = source.getIban(); if (idToBeUsed == null) { idToBeUsed = source.getAccountNumber(); if (idToBeUsed == null) { idToBeUsed = UUID.randomUUID().toString();
private Account waitAccountSynced(BankAccount bankAccount, ApiClient apiClient) throws ApiException { Account account = new AccountsApi(apiClient).getAccount(Long.parseLong(bankAccount.getExternalIdMap().get(bankApi()))); while (account.getStatus() == Account.StatusEnum.DOWNLOAD_IN_PROGRESS) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } account = new AccountsApi(apiClient).getAccount(Long.parseLong(bankAccount.getExternalIdMap().get(bankApi()))); } return account; }
for (Konto konto : dialog.getPassport().getAccounts()) { BankAccount bankAccount = HbciMapping.toBankAccount(konto); bankAccount.externalId(BankApi.HBCI, UUID.randomUUID().toString()); bankAccount.bankName(request.getBankAccess().getBankName()); hbciAccounts.add(bankAccount);
new BankAccount() .externalId(bankApi(), account.getId().toString()) .owner(account.getAccountHolderName()) .bankName(bankAccess.getBankName()) .accountNumber(account.getAccountNumber()) .name(account.getAccountTypeName()) .iban(account.getIban()) .blz(bankAccess.getBankCode()) .type(BankAccountType.fromFinapiType(account.getAccountTypeId().intValue())) .bankAccountBalance(new BalancesReport() .readyHbciBalance(Balance.builder().amount(account.getBalance()).build()))) .collect(Collectors.toList()))
static List<Booking> convertInput(Collection<BookingEntity> bookings) { List<Booking> interfaceBookings = new ArrayList<>(); for (BookingEntity booking : bookings) { Booking smartanalyticsBooking = new Booking(); smartanalyticsBooking.setBookingId(booking.getExternalId()); smartanalyticsBooking.setCreditorId(booking.getCreditorId()); smartanalyticsBooking.setPurpose(booking.getUsage()); smartanalyticsBooking.setIban(booking.getOtherAccount() != null ? booking.getOtherAccount().getIban() : null); smartanalyticsBooking.setAccountNumber(booking.getOtherAccount() != null ? booking.getOtherAccount().getAccountNumber() : null); smartanalyticsBooking.setBankCode(booking.getOtherAccount() != null ? booking.getOtherAccount().getBlz() : null); smartanalyticsBooking.setAmount(booking.getAmount()); smartanalyticsBooking.setExecutionDate(booking.getValutaDate()); smartanalyticsBooking.setStandingOrder(booking.isStandingOrder()); smartanalyticsBooking.setMandateReference(booking.getMandateReference()); if (booking.getOtherAccount() != null) { if (booking.getOtherAccount().getOwner() != null) { smartanalyticsBooking.setReferenceName(booking.getOtherAccount().getOwner()); } else { smartanalyticsBooking.setReferenceName(booking.getOtherAccount().getName()); } } interfaceBookings.add(smartanalyticsBooking); } return interfaceBookings; }
@Override protected AbstractSEPAGV createHbciJob(AbstractScaTransaction transaction, PinTanPassport passport, String rawData) { StandingOrder standingOrder = (StandingOrder) transaction; Konto src = getDebtorAccount(transaction, passport); Konto dst = new Konto(); dst.name = standingOrder.getOtherAccount().getOwner(); dst.iban = standingOrder.getOtherAccount().getIban(); dst.bic = standingOrder.getOtherAccount().getBic(); GVDauerSEPADel gvDauerSEPADel = new GVDauerSEPADel(passport, rawData); gvDauerSEPADel.setParam("src", src); gvDauerSEPADel.setParam("dst", dst); gvDauerSEPADel.setParam("btg", new Value(standingOrder.getAmount())); gvDauerSEPADel.setParam("usage", standingOrder.getUsage()); gvDauerSEPADel.setParam("orderid", standingOrder.getOrderId()); // standing order specific parameter if (standingOrder.getFirstExecutionDate() != null) { gvDauerSEPADel.setParam("firstdate", standingOrder.getFirstExecutionDate().toString()); } if (standingOrder.getCycle() != null) { gvDauerSEPADel.setParam("timeunit", HbciMapping.cycleToTimeunit(standingOrder.getCycle())); // M month, W week gvDauerSEPADel.setParam("turnus", HbciMapping.cycleToTurnus(standingOrder.getCycle())); // 1W = every week, 2M = every two months } gvDauerSEPADel.setParam("execday", standingOrder.getExecutionDay()); // W: 1-7, M: 1-31 if (standingOrder.getLastExecutionDate() != null) { gvDauerSEPADel.setParam("lastdate", standingOrder.getLastExecutionDate().toString()); } gvDauerSEPADel.verifyConstraints(); return gvDauerSEPADel; }
/** * Anonymizes and stores booking in the user object space. * * @param bookings */ public List<AnonymizedBookingEntity> anonymizeAndStoreBookingsAsync(List<BookingEntity> bookingEntities) { List<BookingEntity> uncategorizedBookings = bookingEntities.stream() .filter(bookingEntity -> bookingEntity.getBookingCategory() == null && (bookingEntity.getCreditorId() != null || (bookingEntity.getOtherAccount()!=null && bookingEntity.getOtherAccount().getIban()!=null) || bookingEntity.getUsage()!=null)) .collect(Collectors.toList()); return uncategorizedBookings.stream() .map(bookingEntity -> anonymizeBooking(bookingEntity)) .collect(Collectors.toList()); }