ResponseEntity confirm()

in service/src/main/java/org/apache/fineract/cn/teller/service/rest/TellerOperationRestController.java [203:238]


  ResponseEntity<Void> confirm(@PathVariable("tellerCode") final String tellerCode,
                               @PathVariable("identifier") final String tellerTransactionIdentifier,
                               @RequestParam(value = "command", required = true) final String command,
                               @RequestParam(value = "charges", required = false, defaultValue = "excluded") final String charges) {
    final Teller teller = this.verifyTeller(tellerCode);

    if (!teller.getState().equals(Teller.State.ACTIVE.name())) {
      throw ServiceException.conflict("Teller {0} ist not active.", tellerCode);
    }

    this.verifyEmployee(teller);

    switch (command.toUpperCase()) {
      case "CONFIRM" :
        final ConfirmTellerTransactionCommand confirmTellerTransactionCommand =
            new ConfirmTellerTransactionCommand(tellerTransactionIdentifier, charges);

        final TellerTransaction tellerTransaction =
            this.tellerOperationService.getTellerTransaction(tellerTransactionIdentifier)
                .orElseThrow(() -> ServiceException.notFound("Transaction {0} not found.", tellerTransactionIdentifier));

        this.verifyAccounts(tellerTransaction);
        this.verifyDepositTransaction(tellerTransaction, confirmTellerTransactionCommand);
        this.verifyWithdrawalTransaction(tellerTransaction, confirmTellerTransactionCommand);

        this.commandGateway.process(confirmTellerTransactionCommand);
        break;
      case "CANCEL" :
        this.commandGateway.process(new CancelTellerTransactionCommand(tellerTransactionIdentifier));
        break;
      default :
        throw ServiceException.badRequest("Unsupported teller transaction command {0}.", command);
    }

    return ResponseEntity.accepted().build();
  }