private void doClockOut() {
    int option =
        JOptionPane.showOptionDialog(
            this,
            POSConstants.CONFIRM_CLOCK_OUT,
            POSConstants.CONFIRM,
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            null,
            null);
    if (option != JOptionPane.YES_OPTION) {
      return;
    }

    User user = Application.getCurrentUser();
    AttendenceHistoryDAO attendenceHistoryDAO = new AttendenceHistoryDAO();
    AttendenceHistory attendenceHistory = attendenceHistoryDAO.findHistoryByClockedInTime(user);
    if (attendenceHistory == null) {
      attendenceHistory = new AttendenceHistory();
      Date lastClockInTime = user.getLastClockInTime();
      Calendar c = Calendar.getInstance();
      c.setTime(lastClockInTime);
      attendenceHistory.setClockInTime(lastClockInTime);
      attendenceHistory.setClockInHour((short) c.get(Calendar.HOUR));
      attendenceHistory.setUser(user);
      attendenceHistory.setTerminal(Application.getInstance().getTerminal());
      attendenceHistory.setShift(user.getCurrentShift());
    }

    Shift shift = user.getCurrentShift();
    Calendar calendar = Calendar.getInstance();

    user.doClockOut(attendenceHistory, shift, calendar);

    Application.getInstance().logout();
  }