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; } } }
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); } }
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); } }
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; } } }
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(); }