public String process()

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


  public String process(final CloseTellerCommand closeTellerCommand) {
    final String tellerCode = closeTellerCommand.tellerCode();
    final TellerManagementCommand tellerManagementCommand = closeTellerCommand.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(null);
        tellerEntity.setState(Teller.State.CLOSED.name());
        tellerEntity.setLastModifiedBy(UserContextHolder.checkedGetUser());
        tellerEntity.setLastModifiedOn(LocalDateTime.now(Clock.systemUTC()));

        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.");
    }
  }