/** Creates new form ManagerDialog */
  public ManagerDialog() {
    super();
    initComponents();

    setIconImage(Application.getPosWindow().getIconImage());
    setTitle(Application.getTitle() + ": Manager Functions");

    glassPane = new GlassPane();
    setGlassPane(glassPane);
  }
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == btnNew) {
      OrderUtil.createNewTakeOutOrder(OrderType.TAKE_OUT);
    } else if (e.getSource() == btnLogout) {
      Application.getInstance().doLogout();
    } else if (e.getSource() == btnOpen) {
      OpenTicketsListDialog dialog = new OpenTicketsListDialog();
      dialog.open();
    }

    Application.getPosWindow().setGlassPaneVisible(false);
    dispose();
  }
  public CashierModeNextActionDialog(String message) {
    setTitle("SELECT NEXT ACTION");

    JPanel contentPane = new JPanel(new BorderLayout(10, 20));
    contentPane.setBorder(BorderFactory.createEmptyBorder(20, 10, 20, 10));
    contentPane.add(messageLabel, BorderLayout.NORTH);

    JPanel buttonPanel = new JPanel(new GridLayout(1, 0, 5, 5));

    buttonPanel.add(btnNew);
    buttonPanel.add(btnOpen);
    buttonPanel.add(btnLogout);
    contentPane.add(buttonPanel);

    setContentPane(contentPane);

    btnNew.addActionListener(this);
    btnOpen.addActionListener(this);
    btnLogout.addActionListener(this);

    messageLabel.setFont(messageLabel.getFont().deriveFont(Font.BOLD, 16));
    messageLabel.setText(message);

    setSize(550, 180);
    setResizable(false);

    Application.getPosWindow().setGlassPaneVisible(true);
  }
  private void doCreateNewTicket(final String ticketType) {
    try {

      OrderServiceExtension orderService = new DefaultOrderServiceExtension();

      orderService.createNewTicket(ticketType);

    } catch (TicketAlreadyExistsException e) {

      int option =
          JOptionPane.showOptionDialog(
              Application.getPosWindow(),
              POSConstants.EDIT_TICKET_CONFIRMATION,
              POSConstants.CONFIRM,
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              null,
              null);
      if (option == JOptionPane.YES_OPTION) {
        editTicket(e.getTicket());
        return;
      }
    }
  }
  public ShiftEntryDialog(Shift shift) {
    super(Application.getInstance().getBackOfficeWindow(), true);
    setTitle(com.floreantpos.POSConstants.NEW_SHIFT);

    setContentPane(contentPane);
    getRootPane().setDefaultButton(buttonOK);

    hours = new Vector<Integer>();
    for (int i = 1; i <= 12; i++) {
      hours.add(Integer.valueOf(i));
    }

    mins = new Vector<Integer>();
    for (int i = 0; i < 60; i++) {
      mins.add(Integer.valueOf(i));
    }

    startHour.setModel(new DefaultComboBoxModel(hours));
    endHour.setModel(new DefaultComboBoxModel(hours));

    startMin.setModel(new DefaultComboBoxModel(mins));
    endMin.setModel(new DefaultComboBoxModel(mins));

    buttonOK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onOK();
          }
        });

    buttonCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        });

    // call onCancel() when cross is clicked
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });

    // call onCancel() on ESCAPE
    contentPane.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    setSize(350, 250);

    setShift(shift);
  }
  /** Creates new form MiscTicketItemDialog */
  public MiscTicketItemDialog() {
    super(Application.getPosWindow(), true);

    setTitle("Miscellaneous item entry");

    initComponents();
  }
  /** Creates new form NumericDialog */
  public NumberSelectionDialog() {
    super(Application.getPosWindow(), true);
    initComponents();

    setResizable(false);
    setValue(0);
  }
  private void doVoidTicket() {
    try {
      Ticket selectedTicket = getFirstSelectedTicket();

      if (selectedTicket == null) {
        return;
      }

      if (!selectedTicket.getTotalAmount().equals(selectedTicket.getDueAmount())) {
        POSMessageDialog.showMessage(POSConstants.PARTIAL_PAID_VOID_ERROR);
        return;
      }

      Ticket ticketToVoid = TicketDAO.getInstance().loadFullTicket(selectedTicket.getId());

      VoidTicketDialog voidTicketDialog = new VoidTicketDialog(Application.getPosWindow(), true);
      voidTicketDialog.setTicket(ticketToVoid);
      voidTicketDialog.open();

      if (!voidTicketDialog.isCanceled()) {
        updateView();
      }
    } catch (Exception e) {
      POSMessageDialog.showError(POSConstants.ERROR_MESSAGE, e);
    }
  }
  public void refundTicket(Ticket ticket, final double refundAmount) throws Exception {
    User currentUser = Application.getCurrentUser();
    Terminal terminal = ticket.getTerminal();

    Session session = null;
    Transaction tx = null;

    GenericDAO dao = new GenericDAO();

    try {
      Double currentBalance = terminal.getCurrentBalance();
      Double totalPrice = ticket.getTotalAmount();
      double newBalance = currentBalance - totalPrice;
      terminal.setCurrentBalance(newBalance);

      //			double refundAmount = ticket.getPaidAmount();
      //			if(ticket.getGratuity() != null) {
      //				refundAmount -= ticket.getGratuity().getAmount();
      //			}

      RefundTransaction posTransaction = new RefundTransaction();
      posTransaction.setTicket(ticket);
      posTransaction.setPaymentType(PaymentType.CASH.name());
      posTransaction.setTransactionType(TransactionType.DEBIT.name());
      posTransaction.setAmount(refundAmount);
      posTransaction.setTerminal(terminal);
      posTransaction.setUser(currentUser);
      posTransaction.setTransactionTime(new Date());

      ticket.setVoided(false);
      ticket.setRefunded(true);
      ticket.setClosed(true);
      ticket.setDrawerResetted(false);
      ticket.setClosingDate(new Date());

      ticket.addTotransactions(posTransaction);

      session = dao.getSession();
      tx = session.beginTransaction();

      dao.saveOrUpdate(ticket, session);

      tx.commit();

      // String title = "- REFUND RECEIPT -";
      // String data = "Ticket #" + ticket.getId() + ", amount " + refundAmount + " was refunded.";

      ReceiptPrintService.printRefundTicket(ticket, posTransaction);

    } catch (Exception e) {
      try {
        tx.rollback();
      } catch (Exception x) {
      }

      throw e;
    } finally {
      dao.closeSession(session);
    }
  }
Beispiel #10
0
  public void voidTicket(Ticket ticket) throws Exception {
    Session session = null;
    Transaction tx = null;

    try {
      session = createNewSession();
      tx = session.beginTransaction();

      Terminal terminal = Application.getInstance().getTerminal();

      ticket.setVoided(true);
      ticket.setClosed(true);
      ticket.setClosingDate(new Date());
      ticket.setTerminal(terminal);

      if (ticket.isPaid()) {
        VoidTransaction transaction = new VoidTransaction();
        transaction.setTicket(ticket);
        transaction.setTerminal(terminal);
        transaction.setTransactionTime(new Date());
        transaction.setTransactionType(TransactionType.DEBIT.name());
        transaction.setPaymentType(PaymentType.CASH.name());
        transaction.setAmount(ticket.getPaidAmount());
        transaction.setTerminal(Application.getInstance().getTerminal());
        transaction.setCaptured(true);

        PosTransactionService.adjustTerminalBalance(transaction);

        ticket.addTotransactions(transaction);
      }

      session.update(ticket);
      session.update(terminal);

      session.flush();
      tx.commit();
    } catch (Exception x) {
      try {
        tx.rollback();
      } catch (Exception e) {
      }
      throw x;
    } finally {
      closeSession(session);
    }
  }
  private void doTakeout(String titcketType) {
    Application application = Application.getInstance();

    Ticket ticket = new Ticket();
    // ticket.setPriceIncludesTax(application.isPriceIncludesTax());
    ticket.setTableNumber(-1);
    ticket.setTicketType(titcketType);
    ticket.setTerminal(application.getTerminal());
    ticket.setOwner(Application.getCurrentUser());
    ticket.setShift(application.getCurrentShift());

    Calendar currentTime = Calendar.getInstance();
    ticket.setCreateDate(currentTime.getTime());
    ticket.setCreationHour(currentTime.get(Calendar.HOUR_OF_DAY));

    OrderView.getInstance().setCurrentTicket(ticket);
    RootView.getInstance().showView(OrderView.VIEW_NAME);
  }
 private synchronized void doShowBackoffice() {
   BackOfficeWindow window = BackOfficeWindow.getInstance();
   if (window == null) {
     window = new BackOfficeWindow();
     Application.getInstance().setBackOfficeWindow(window);
   }
   window.setVisible(true);
   window.toFront();
 }
Beispiel #13
0
  public KitchenDisplayWindow() {
    setTitle(Messages.getString("KitchenDisplayWindow.0")); // $NON-NLS-1$
    setIconImage(Application.getApplicationIcon().getImage());

    add(view);

    setSize(Toolkit.getDefaultToolkit().getScreenSize());
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  }
  private void doReopenTicket() {
    try {

      int ticketId = NumberSelectionDialog2.takeIntInput(POSConstants.ENTER_TICKET_ID);

      if (ticketId == -1) {
        return;
      }

      Ticket ticket = TicketService.getTicket(ticketId);

      if (ticket == null) {
        throw new PosException(
            POSConstants.NO_TICKET_WITH_ID + " " + ticketId + " " + POSConstants.FOUND);
      }

      if (!ticket.isClosed()) {
        throw new PosException(POSConstants.TICKET_IS_NOT_CLOSED);
      }

      String ticketTotalAmount =
          Application.getCurrencySymbol()
              + " "
              + NumberUtil.formatToCurrency(ticket.getTotalAmount());
      String amountMessage =
          "<span style='color: red; font-weight: bold;'>" + ticketTotalAmount + "</span>";
      String message =
          "<html><body>Ticket amount is "
              + ticketTotalAmount
              + ". To reopen ticket, you need to refund that amount to system.<br/>Please press <b>OK</b> after you refund amount "
              + amountMessage
              + "</body></html>";

      int option =
          JOptionPane.showOptionDialog(
              this,
              message,
              "Alert!",
              JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.INFORMATION_MESSAGE,
              null,
              null,
              null);
      if (option != JOptionPane.OK_OPTION) {
        return;
      }

      TicketService.refundTicket(ticket);
      editTicket(ticket);

    } catch (PosException e) {
      POSMessageDialog.showError(this, e.getLocalizedMessage());
    } catch (Exception e) {
      POSMessageDialog.showError(this, POSConstants.ERROR_MESSAGE, e);
    }
  }
 public void actionPerformed(ActionEvent e) {
   try {
     MenuModifierGroupForm editor = new MenuModifierGroupForm();
     BeanEditorDialog dialog =
         new BeanEditorDialog(editor, Application.getInstance().getBackOfficeWindow(), true);
     dialog.open();
   } catch (Exception x) {
     MessageDialog.showError(com.floreantpos.POSConstants.ERROR_MESSAGE, x);
   }
 }
  public MenuItemExplorer() {
    tableModel = new BeanTableModel<MenuItem>(MenuItem.class);
    tableModel.addColumn(POSConstants.ID.toUpperCase(), "id"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.NAME.toUpperCase(), "name"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.TRANSLATED_NAME.toUpperCase(), "translatedName"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.PRICE.toUpperCase() + " (" + Application.getCurrencySymbol() + ")",
        "price"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    tableModel.addColumn(POSConstants.VISIBLE.toUpperCase(), "visible"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.DISCOUNT.toUpperCase() + "(%)", "discountRate"); // $NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(POSConstants.FOOD_GROUP.toUpperCase(), "parent"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TAX.toUpperCase(), "tax"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.SORT_ORDER.toUpperCase(), "sortOrder"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.BUTTON_COLOR.toUpperCase(), "buttonColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TEXT_COLOR.toUpperCase(), "textColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.IMAGE.toUpperCase(), "imageData"); // $NON-NLS-1$

    tableModel.addRows(MenuItemDAO.getInstance().findAll());

    table = new JXTable(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);

    table.setDefaultRenderer(Object.class, new CustomCellRenderer());
    table
        .getColumnModel()
        .getColumn(10)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                if (value instanceof Color) {
                  JLabel lblColor = new JLabel("TEXT COLOR", JLabel.CENTER);
                  lblColor.setForeground((Color) value);
                  return lblColor;
                }
                return super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
              }
            });

    setLayout(new BorderLayout(5, 5));
    add(new JScrollPane(table));

    add(createButtonPanel(), BorderLayout.SOUTH);
    add(buildSearchForm(), BorderLayout.NORTH);
  }
  private void updatePanelCount() {
    Dimension size = Application.getInstance().getRootView().getSize();

    horizontalPanelCount = getCount(size.width, 330);
    int verticalPanelCount = getCount(size.height, 280);

    int totalItem = horizontalPanelCount * verticalPanelCount;

    previousBlockIndex = currentBlockIndex - totalItem;
    nextBlockIndex = currentBlockIndex + totalItem;
  }
Beispiel #18
0
  private void btnAddNoteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnAddNoteActionPerformed
    NotesDialog dialog = new NotesDialog(Application.getPosWindow(), true);
    dialog.setTitle(com.floreantpos.POSConstants.ENTER_PAYOUT_NOTE);
    dialog.pack();
    dialog.open();

    if (!dialog.isCanceled()) {
      tfNote.setText(dialog.getNote());
    }
  } // GEN-LAST:event_btnAddNoteActionPerformed
  /** Creates new form SwitchboardView */
  public SwitchboardView() {
    initComponents();

    btnSalesReport.addActionListener(this);
    btnBackOffice.addActionListener(this);
    btnClockOut.addActionListener(this);
    btnEditTicket.addActionListener(this);

    if (!"false".equals(AppConfig.getFeatureGroupTicketFlag())) {
      btnGroupSettle.addActionListener(this);
    }

    btnLogout.addActionListener(this);

    if (!"false".equals(AppConfig.getManagerMenuFlag())) {
      btnManager.addActionListener(this);
    }

    btnNewTicket.addActionListener(this);

    if (!"false".equals(AppConfig.getFeaturePenarikanFlag())) {
      btnPayout.addActionListener(this);
    }

    btnOrderInfo.addActionListener(this);
    btnReopenTicket.addActionListener(this);
    btnSettleTicket.addActionListener(this);
    btnShutdown.addActionListener(this);

    if (!"false".equals(AppConfig.getFeatureSplitTicketFlag())) {
      btnSplitTicket.addActionListener(this);
    }

    btnTakeout.addActionListener(this);
    btnVoidTicket.addActionListener(this);

    orderServiceExtension = Application.getPluginManager().getPlugin(OrderServiceExtension.class);

    if (orderServiceExtension == null) {
      //            btnHomeDelivery.setEnabled(false);
      //            btnPickup.setEnabled(false);
      //            btnDriveThrough.setEnabled(false);
      //            btnAssignDriver.setEnabled(false);
      //            btnCloseOrder.setEnabled(false);

      orderServiceExtension = new DefaultOrderServiceExtension();
    }
    //		ticketListUpdater = new Timer(30 * 1000, new TicketListUpdaterTask());

    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    instance = this;
  }
Beispiel #20
0
  private void doLogin() throws RuntimeException {

    Application application = Application.getInstance();

    UserDAO dao = new UserDAO();
    User user = dao.findUser(Integer.valueOf(userId));
    if (!user.getPassword().equals(PasswordHasher.hashPassword(userPassword))) {
      throw new RuntimeException(POSConstants.WRONG_PASSWORD);
    }

    Shift currentShift = ShiftUtil.getCurrentShift();
    if (currentShift == null) {
      throw new RuntimeException(POSConstants.NO_SHIFT_CONFIGURED);
    }

    adjustUserShift(user, currentShift);

    application.setCurrentUser(user);
    application.setCurrentShift(currentShift);

    application.getRootView().showView(SwitchboardView.VIEW_NAME);
  }
Beispiel #21
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand() != null
       && e.getActionCommand().equalsIgnoreCase("log out")) { // $NON-NLS-1$
     Application.getInstance().doLogout();
   }
   if (e.getSource() == viewUpdateTimer) {
     updateTicketView();
   } else {
     ticketPanel.removeAll();
     updateTicketView();
   }
 }
Beispiel #22
0
  private void reClockInUser(Calendar currentTime, User user, Shift currentShift) {
    POSMessageDialog.showMessage("You will be clocked out from previous Shift");

    Application application = Application.getInstance();
    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.valueOf((short) c.get(Calendar.HOUR)));
      attendenceHistory.setUser(user);
      attendenceHistory.setTerminal(application.getTerminal());
      attendenceHistory.setShift(user.getCurrentShift());
    }

    user.doClockOut(attendenceHistory, currentShift, currentTime);

    user.doClockIn(application.getTerminal(), currentShift, currentTime);
  }
  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();
  }
  private void doFinish(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_doFinish
    double amount = tfItemPrice.getDouble();
    String itemName = tfItemName.getText();

    if (StringUtils.isEmpty(itemName)) {
      POSMessageDialog.showError(Application.getPosWindow(), "Please intsert item name");
      return;
    }

    if (amount < 0 || Double.isNaN(amount)) {
      POSMessageDialog.showError(Application.getPosWindow(), "Please intsert valid item price");
      return;
    }

    setCanceled(false);

    ticketItem = new TicketItem();
    ticketItem.setItemCount(1);
    ticketItem.setUnitPrice(amount);
    ticketItem.setName(itemName);
    ticketItem.setCategoryName(com.floreantpos.POSConstants.MISC_BUTTON_TEXT);
    ticketItem.setGroupName(com.floreantpos.POSConstants.MISC_BUTTON_TEXT);
    ticketItem.setShouldPrintToKitchen(true);

    Tax tax = (Tax) cbTax.getSelectedItem();
    if (tax != null) {
      ticketItem.setTaxRate(tax.getRate());
      TerminalConfig.setMiscItemDefaultTaxId(tax.getId());
    }

    PrinterGroup printerGroup = (PrinterGroup) cbPrinterGroup.getSelectedItem();
    if (printerGroup != null) {
      ticketItem.setPrinterGroup(printerGroup);
    }

    dispose();
  } // GEN-LAST:event_doFinish
Beispiel #25
0
  private void adjustUserShift(User user, Shift currentShift) {
    Application application = Application.getInstance();
    Calendar currentTime = Calendar.getInstance();

    if (user.isClockedIn() != null && user.isClockedIn().booleanValue()) {
      Shift userShift = user.getCurrentShift();
      Date userLastClockInTime = user.getLastClockInTime();
      long elaspedTimeSinceLastLogin =
          Math.abs(currentTime.getTimeInMillis() - userLastClockInTime.getTime());

      if (userShift != null) {
        if (!userShift.equals(currentShift)) {
          reClockInUser(currentTime, user, currentShift);
        } else if (userShift.getShiftLength() != null
            && (elaspedTimeSinceLastLogin >= userShift.getShiftLength())) {
          reClockInUser(currentTime, user, currentShift);
        }
      } else {
        user.doClockIn(application.getTerminal(), currentShift, currentTime);
      }
    } else {
      user.doClockIn(application.getTerminal(), currentShift, currentTime);
    }
  }
  @Override
  public void doOk() {
    updateView();

    if (!isValidAmount()) {
      POSMessageDialog.showMessage(POSUtil.getFocusedWindow(), "Invalid Amount"); // $NON-NLS-1$
      return;
    }

    Terminal terminal = Application.getInstance().getTerminal();

    cashDrawer = CashDrawerDAO.getInstance().findByTerminal(terminal);
    if (cashDrawer == null) {
      cashDrawer = new CashDrawer();
      cashDrawer.setTerminal(terminal);

      if (cashDrawer.getCurrencyBalanceList() == null) {
        cashDrawer.setCurrencyBalanceList(new HashSet());
      }
    }

    for (CurrencyRow rowItem : currencyRows) {
      CurrencyBalance item = cashDrawer.getCurrencyBalance(rowItem.currency);
      if (item == null) {
        item = new CurrencyBalance();
        item.setCurrency(rowItem.currency);
        item.setCashDrawer(cashDrawer);
        cashDrawer.addTocurrencyBalanceList(item);
      }
      double tenderAmount = rowItem.getTenderAmount();
      double cashBackAmount = rowItem.getCashBackAmount();

      if (tenderAmount > 0) {
        ticket.addProperty(rowItem.currency.getName(), String.valueOf(tenderAmount));
      }
      if (cashBackAmount > 0) {
        ticket.addProperty(
            rowItem.currency.getName() + "_CASH_BACK", String.valueOf(cashBackAmount));
      }
      item.setBalance(
          NumberUtil.roundToThreeDigit(item.getBalance() + tenderAmount - cashBackAmount));
    }

    setCanceled(false);
    dispose();
  }
  private void doShowOrderInfo() {
    try {
      List<Ticket> selectedTickets = openTicketList.getSelectedTickets();
      if (selectedTickets.size() == 0) {
        POSMessageDialog.showMessage(POSConstants.SELECT_ONE_TICKET_TO_PRINT);
        return;
      }

      List<Ticket> ticketsToShow = new ArrayList<Ticket>();

      for (int i = 0; i < selectedTickets.size(); i++) {
        Ticket ticket = selectedTickets.get(i);
        ticketsToShow.add(TicketDAO.getInstance().loadFullTicket(ticket.getId()));
      }

      OrderInfoView view = new OrderInfoView(ticketsToShow);
      OrderInfoDialog dialog = new OrderInfoDialog(view);
      dialog.setSize(400, 600);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      dialog.setLocationRelativeTo(Application.getPosWindow());
      dialog.setVisible(true);

    } catch (Exception e) {
      e.printStackTrace();
    }

    //		Ticket ticket = selectedTickets.get(0);
    //		try {
    //			ticket = TicketDAO.getInstance().initializeTicket(ticket);
    //			ticket.calculateDefaultGratutity();
    //
    //			PosPrintService.printTicket(ticket, 0);
    //
    //			// PRINT ACTION
    //			String actionMessage = "CHK#" + ":" + ticket.getId();
    //			ActionHistoryDAO.getInstance().saveHistory(Application.getCurrentUser(),
    // ActionHistory.PRINT_CHECK, actionMessage);
    //		} catch (Exception e) {
    //			POSMessageDialog.showError(this, e.getMessage(), e);
    //		}
  }
  protected void doAssignDriver() {
    try {

      Ticket ticket = getFirstSelectedTicket();

      //			if(ticket == null) {
      //				return;
      //			}

      if (!Ticket.HOME_DELIVERY.equals(ticket.getTicketType())) {
        POSMessageDialog.showError("Driver can be assigned only for Home Delivery");
        return;
      }

      User assignedDriver = ticket.getAssignedDriver();
      if (assignedDriver != null) {
        int option =
            JOptionPane.showOptionDialog(
                Application.getPosWindow(),
                "Driver already assigned. Do you want to reassign?",
                "Confirm",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                null,
                null);

        if (option != JOptionPane.YES_OPTION) {
          return;
        }
      }

      orderServiceExtension.assignDriver(ticket.getId());
    } catch (Exception e) {
      e.printStackTrace();
      POSMessageDialog.showError(e.getMessage());
      LogFactory.getLog(SwitchboardView.class).error(e);
    }
  }
  public void updateTicketList() {
    User user = Application.getCurrentUser();

    TicketDAO dao = TicketDAO.getInstance();
    List<Ticket> openTickets;

    boolean showAllOpenTicket = false;
    if (user.getNewUserType() != null) {
      Set<UserPermission> permissions = user.getNewUserType().getPermissions();
      if (permissions != null) {
        for (UserPermission permission : permissions) {
          if (permission.equals(UserPermission.VIEW_ALL_OPEN_TICKET)) {
            showAllOpenTicket = true;
            break;
          }
        }
      }
    }

    if (showAllOpenTicket) {
      openTickets = dao.findOpenTickets();
    } else {
      openTickets = dao.findOpenTicketsForUser(user);
    }
    openTicketList.setTickets(openTickets);

    lblUserName.setText(
        POSConstants.WELCOME
            + " "
            + user.toString()
            + ". "
            + POSConstants.YOU
            + " "
            + POSConstants.HAVE
            + " "
            + openTickets.size()
            + " "
            + POSConstants.TICKETS);
  }
  protected void doHomeDelivery(String ticketType) {
    try {

      orderServiceExtension.createNewTicket(ticketType);

    } catch (TicketAlreadyExistsException e) {

      int option =
          JOptionPane.showOptionDialog(
              Application.getPosWindow(),
              POSConstants.EDIT_TICKET_CONFIRMATION,
              POSConstants.CONFIRM,
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              null,
              null);
      if (option == JOptionPane.YES_OPTION) {
        editTicket(e.getTicket());
        return;
      }
    }
  }