public MultiCurrencyTenderDialog(Ticket ticket, List<Currency> currencyList) { super(); this.ticket = ticket; this.currencyList = currencyList; this.dueAmount = ticket.getDueAmount(); init(); }
public Object getValueAt(int rowIndex, int columnIndex) { Ticket ticket = (Ticket) rows.get(rowIndex); switch (columnIndex) { case 0: return Integer.valueOf(ticket.getId()); case 1: return Integer.valueOf(ticket.getTableNumber()); case 2: return String.valueOf(ticket.getOwner()); case 3: return ticket.getCreateDate(); case 4: return ticket.getTotalAmount(); case 5: return ticket.getDueAmount(); } return null; }
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); } }
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 MultiCurrencyTenderDialog(List<Ticket> tickets, List<Currency> currencyList) { super(); this.currencyList = currencyList; this.ticket = tickets.get(tickets.size() - 1); dueAmount = 0; for (Ticket ticket : tickets) { dueAmount += ticket.getDueAmount(); } init(); }
public void settleTicket(Ticket ticket, PosTransaction transaction) throws Exception { Application application = Application.getInstance(); User currentUser = Application.getCurrentUser(); Terminal terminal = application.refreshAndGetTerminal(); Session session = null; Transaction tx = null; GenericDAO dao = new GenericDAO(); try { Date currentDate = new Date(); session = dao.createNewSession(); tx = session.beginTransaction(); ticket.setVoided(false); ticket.setDrawerResetted(false); ticket.setTerminal(terminal); ticket.setPaidAmount(ticket.getPaidAmount() + transaction.getAmount()); ticket.calculatePrice(); if (ticket.getDueAmount() == 0.0) { ticket.setPaid(true); closeTicketIfApplicable(ticket, currentDate); } else { ticket.setPaid(false); ticket.setClosed(false); } transaction.setTransactionType(TransactionType.CREDIT.name()); // transaction.setPaymentType(transaction.getPaymentType()); transaction.setTerminal(terminal); transaction.setUser(currentUser); transaction.setTransactionTime(currentDate); ticket.addTotransactions(transaction); if (ticket.getType() == OrderType.BAR_TAB) { ticket.removeProperty(Ticket.PROPERTY_PAYMENT_METHOD); ticket.removeProperty(Ticket.PROPERTY_CARD_NAME); ticket.removeProperty(Ticket.PROPERTY_CARD_TRANSACTION_ID); ticket.removeProperty(Ticket.PROPERTY_CARD_TRACKS); ticket.removeProperty(Ticket.PROPERTY_CARD_READER); ticket.removeProperty(Ticket.PROPERTY_ADVANCE_PAYMENT); ticket.removeProperty(Ticket.PROPERTY_CARD_NUMBER); ticket.removeProperty(Ticket.PROPERTY_CARD_EXP_YEAR); ticket.removeProperty(Ticket.PROPERTY_CARD_EXP_MONTH); ticket.removeProperty(Ticket.PROPERTY_CARD_AUTH_CODE); } adjustTerminalBalance(transaction); session.update(terminal); // session.saveOrUpdate(ticket); TicketDAO.getInstance().saveOrUpdate(ticket, session); // User assignedDriver = ticket.getAssignedDriver(); // if(assignedDriver != null) { // assignedDriver.setAvailableForDelivery(true); // UserDAO.getInstance().saveOrUpdate(assignedDriver, session); // } tx.commit(); } catch (Exception e) { try { tx.rollback(); } catch (Exception x) { } throw e; } finally { dao.closeSession(session); } // SETTLE ACTION String actionMessage = com.floreantpos.POSConstants.RECEIPT_REPORT_TICKET_NO_LABEL + ":" + ticket.getId(); // $NON-NLS-1$ actionMessage += ";" + com.floreantpos.POSConstants.TOTAL + ":" + NumberUtil.formatNumber(ticket.getTotalAmount()); // $NON-NLS-1$ //$NON-NLS-2$ ActionHistoryDAO.getInstance() .saveHistory(Application.getCurrentUser(), ActionHistory.SETTLE_CHECK, actionMessage); }