public String process()

in service/src/main/java/org/apache/fineract/cn/teller/service/internal/command/handler/TellerAggregate.java [162:193]


  public String process(final OpenTellerCommand openTellerCommand) {
    final String tellerCode = openTellerCommand.tellerCode();
    final TellerManagementCommand tellerManagementCommand = openTellerCommand.tellerManagementCommand();

    final Optional<TellerEntity> optionalTellerEntity = this.tellerRepository.findByIdentifier(tellerCode);
    if (optionalTellerEntity.isPresent()) {
      final TellerEntity tellerEntity = optionalTellerEntity.get();

      if (this.checkPreconditions(tellerEntity.getOfficeIdentifier(), TellerMapper.map(tellerEntity))) {

        if (!tellerManagementCommand.getAdjustment().equals(TellerManagementCommand.Adjustment.NONE.name())
            && tellerManagementCommand.getAmount() != null
            && tellerManagementCommand.getAmount().compareTo(BigDecimal.ZERO) > 0) {
          this.accountingService.postJournalEntry(this.createJournalEntry(tellerEntity, tellerManagementCommand));
        }

        tellerEntity.setAssignedEmployeeIdentifier(tellerManagementCommand.getAssignedEmployeeIdentifier());
        tellerEntity.setState(Teller.State.OPEN.name());
        tellerEntity.setLastModifiedBy(UserContextHolder.checkedGetUser());
        tellerEntity.setLastModifiedOn(LocalDateTime.now(Clock.systemUTC()));
        tellerEntity.setLastOpenedBy(tellerEntity.getLastModifiedBy());
        tellerEntity.setLastOpenedOn(tellerEntity.getLastModifiedOn());

        this.tellerRepository.save(tellerEntity);
        return tellerCode;
      } else {
        throw new IllegalStateException("Preconditions not met, see log file for further information.");
      }
    } else {
      throw new IllegalStateException("Teller " + tellerCode + " not found.");
    }
  }