public TellerTransactionCosts process()

in service/src/main/java/org/apache/fineract/cn/teller/service/internal/command/handler/TellerTransactionAggregate.java [76:109]


  public TellerTransactionCosts process(final InitializeTellerTransactionCommand initializeTellerTransactionCommand) {
    final String tellerCode = initializeTellerTransactionCommand.tellerCode();
    final TellerTransaction tellerTransaction = initializeTellerTransactionCommand.tellerTransaction();

    final Optional<TellerEntity> optionalTeller = this.tellerRepository.findByIdentifier(tellerCode);
    if (optionalTeller.isPresent()) {
      tellerTransaction.setIdentifier(RandomStringUtils.randomAlphanumeric(32));
      tellerTransaction.setState(TellerTransaction.State.PENDING.name());
      final TellerTransactionEntity tellerTransactionEntity = TellerTransactionMapper.map(tellerTransaction);
      tellerTransactionEntity.setTeller(optionalTeller.get());
      final TellerTransactionEntity savedTellerTransaction = this.tellerTransactionRepository.save(tellerTransactionEntity);

      if (tellerTransaction.getTransactionType().equals(ServiceConstants.TX_CHEQUE)) {
        final Cheque cheque = tellerTransaction.getCheque();
        final ChequeEntity chequeEntity = new ChequeEntity();
        chequeEntity.setTellerTransactionId(savedTellerTransaction.getId());
        chequeEntity.setChequeNumber(cheque.getMicr().getChequeNumber());
        chequeEntity.setBranchSortCode(cheque.getMicr().getBranchSortCode());
        chequeEntity.setAccountNumber(cheque.getMicr().getAccountNumber());
        chequeEntity.setDrawee(cheque.getDrawee());
        chequeEntity.setDrawer(cheque.getDrawer());
        chequeEntity.setPayee(cheque.getPayee());
        chequeEntity.setDateIssued(Date.valueOf(DateConverter.dateFromIsoString(cheque.getDateIssued())));
        chequeEntity.setAmount(cheque.getAmount());
        chequeEntity.setOpenCheque(cheque.isOpenCheque());
        this.chequeRepository.save(chequeEntity);
      }

      return this.tellerTransactionProcessor.getCosts(tellerTransaction);
    } else {
      this.logger.warn("Teller {} not found.", tellerCode);
    }
    return null;
  }