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 actionPerformed(ActionEvent evt) { // Get button clicked JButton buttonClicked = (JButton) evt.getSource(); String actionCommand = new String(buttonClicked.getActionCommand()); if (actionCommand.equals("Submit")) { System.out.println(clientUser.getLogon() + ": updating ticket..."); // Recover ticket and update it Ticket ticketToUpdate = ticket; ticketToUpdate.setDesc(clientTicketDialog.getSummaryDescriptionField()); ticketToUpdate.setResolution(clientTicketDialog.getResolutionDescriptionField()); // Call checkInTicket() on the RMI object to update the ticket on the server try { ticketServerObject.checkInTicket(ticketToUpdate); // Refresh the activeTickets HashMap owner.getActiveTickets(); } catch (RemoteException re) { System.out.println(re.getMessage()); } // Close the ClientTicketDialog clientTicketDialog.setVisible(false); clientTicketDialog.dispose(); } }
private void doSplitTicket() { try { Ticket selectedTicket = getFirstSelectedTicket(); if (selectedTicket == null) { return; } if (!selectedTicket.getTotalAmount().equals(selectedTicket.getDueAmount())) { POSMessageDialog.showMessage(POSConstants.PARTIAL_PAID_VOID_ERROR); return; } // initialize the ticket. Ticket ticket = TicketDAO.getInstance().loadFullTicket(selectedTicket.getId()); SplitTicketDialog dialog = new SplitTicketDialog(); dialog.setTicket(ticket); dialog.open(); updateView(); } catch (Exception e) { POSMessageDialog.showError(POSConstants.ERROR_MESSAGE, e); } }
protected void doCloseOrder() { Ticket ticket = getFirstSelectedTicket(); if (orderServiceExtension.finishOrder(ticket.getId())) { updateTicketList(); } }
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); } }
private void editTicket(Ticket ticket) { if (ticket.isPaid()) { POSMessageDialog.showMessage("Tiket yang sudah terbayar tidak dapat diedit lagi"); return; } Ticket ticketToEdit = TicketDAO.getInstance().loadFullTicket(ticket.getId()); OrderView.getInstance().setCurrentTicket(ticketToEdit); RootView.getInstance().showView(OrderView.VIEW_NAME); }
private void doSettleTicket() { try { List<Ticket> selectedTickets = openTicketList.getSelectedTickets(); if (selectedTickets.size() == 0 || selectedTickets.size() > 1) { POSMessageDialog.showMessage(POSConstants.SELECT_ONE_TICKET_TO_SETTLE); return; } Ticket ticket = selectedTickets.get(0); new SettleTicketAction(ticket.getId()).execute(); updateTicketList(); } catch (Exception e) { POSMessageDialog.showError(POSConstants.ERROR_MESSAGE, e); } }
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); // } }
private void doGroupSettle() { List<Ticket> selectedTickets = getSelectedTickets(); if (selectedTickets == null) { return; } List<Ticket> ticketsToSettle = new ArrayList<Ticket>(); for (int i = 0; i < selectedTickets.size(); i++) { Ticket ticket = selectedTickets.get(i); Ticket fullTicket = TicketDAO.getInstance().loadFullTicket(ticket.getId()); ticketsToSettle.add(fullTicket); } SettleTicketView posDialog = new SettleTicketView(); posDialog.setTicketsToSettle(ticketsToSettle); posDialog.setSize(800, 600); posDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); posDialog.open(); }
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); } }
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); }