Пример #1
0
  public void updateCouponView(Discount coupon) {
    if (coupon == null) {
      tfName.setText(""); // $NON-NLS-1$
      tfNumber.setText(""); // $NON-NLS-1$
      tfType.setText(""); // $NON-NLS-1$
      tfValue.setText(""); // $NON-NLS-1$
      return;
    }

    btnEditValue.setEnabled(false);

    tfName.setText(coupon.getName());
    if (coupon.getType() == Discount.FREE_AMOUNT) {
      btnEditValue.setEnabled(true);
    }

    tfNumber.setText(String.valueOf(coupon.getId()));
    tfType.setText(Discount.COUPON_TYPE_NAMES[coupon.getType()]);
    tfValue.setText(NumberUtil.formatNumber(coupon.getValue()));

    double totalDiscount = 0;
    double subtotal = ticket.getSubtotalAmount();

    ticketCoupon.setDiscountId(coupon.getId());
    ticketCoupon.setName(coupon.getName());
    ticketCoupon.setType(coupon.getType());
    ticketCoupon.setValue(coupon.getValue());

    totalDiscount = ticket.calculateDiscountFromType(ticketCoupon, subtotal);
    ticketCoupon.setValue(totalDiscount);

    lblTotalDiscount.setText(NumberUtil.formatNumber(totalDiscount));
  }
  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);
    }
  }
  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);
    }
  }
Пример #4
0
  public Ticket loadFullTicket(int id) {
    Session session = createNewSession();

    Ticket ticket = (Ticket) session.get(getReferenceClass(), id);

    if (ticket == null) return null;

    Hibernate.initialize(ticket.getTicketItems());
    Hibernate.initialize(ticket.getCouponAndDiscounts());
    Hibernate.initialize(ticket.getTransactions());

    List<TicketItem> ticketItems = ticket.getTicketItems();
    if (ticketItems != null) {
      for (TicketItem ticketItem : ticketItems) {
        List<TicketItemModifierGroup> ticketItemModifierGroups =
            ticketItem.getTicketItemModifierGroups();
        Hibernate.initialize(ticketItemModifierGroups);
        if (ticketItemModifierGroups != null) {
          for (TicketItemModifierGroup ticketItemModifierGroup : ticketItemModifierGroups) {
            Hibernate.initialize(ticketItemModifierGroup.getTicketItemModifiers());
          }
        }
      }
    }

    session.close();

    return ticket;
  }
  protected void doCloseOrder() {
    Ticket ticket = getFirstSelectedTicket();

    if (orderServiceExtension.finishOrder(ticket.getId())) {
      updateTicketList();
    }
  }
Пример #6
0
 private void doAddToleranceToTicketDiscount(double discountAmount) {
   TicketDiscount ticketDiscount = new TicketDiscount();
   ticketDiscount.setName("Tolerance");
   ticketDiscount.setValue(NumberUtil.roundToThreeDigit(discountAmount));
   ticketDiscount.setAutoApply(true);
   ticketDiscount.setTicket(ticket);
   ticket.addTodiscounts(ticketDiscount);
   ticket.calculatePrice();
 }
  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);
    }
  }
Пример #8
0
 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();
 }
  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);
  }
Пример #10
0
  public Ticket loadCouponsAndTransactions(int id) {
    Session session = createNewSession();

    Ticket ticket = (Ticket) session.get(getReferenceClass(), id);

    Hibernate.initialize(ticket.getCouponAndDiscounts());
    Hibernate.initialize(ticket.getTransactions());

    session.close();

    return ticket;
  }
  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);
    }
  }
Пример #12
0
  @Override
  public void captureAuthAmount(PosTransaction transaction) throws Exception {
    String xml =
        StreamUtils.toString(
            MercuryPayProcessor.class.getResourceAsStream(
                "/com/mercurypay/ws/sdk/mercuryPreAuthCapture.xml")); //$NON-NLS-1$
    Ticket ticket = transaction.getTicket();

    // String merchantId = "118725340908147";
    String laneId = "01"; // $NON-NLS-1$
    String invoiceNo = String.valueOf(ticket.getId());
    String amount = String.valueOf(transaction.getAmount());

    xml = xml.replace($merchantId, CardConfig.getMerchantAccount());
    xml = xml.replace($laneId, laneId);
    xml = xml.replace($invoiceNo, invoiceNo);
    xml = xml.replace($refNo, invoiceNo);
    xml = xml.replace($amount, amount);
    xml = xml.replace($authorizeAmount, amount);
    xml = xml.replace("$gratuity", String.valueOf(transaction.getTipsAmount())); // $NON-NLS-1$
    xml = xml.replace("$recordNo", transaction.getCardTransactionId()); // $NON-NLS-1$
    xml = xml.replace("$authCode", transaction.getCardAuthCode()); // $NON-NLS-1$
    xml =
        xml.replace(
            "$AcqRefData", transaction.getProperty("AcqRefData")); // $NON-NLS-1$ //$NON-NLS-2$

    //		System.out.println(xml);

    MercuryWebRequest mpswr =
        new MercuryWebRequest("https://w1.mercurydev.net/ws/ws.asmx"); // $NON-NLS-1$
    mpswr.addParameter(
        "tran",
        xml); // Set WebServices 'tran' parameter to the XML transaction request //$NON-NLS-1$
    mpswr.addParameter(
        "pw", CardConfig.getMerchantPass()); // Set merchant's WebServices password //$NON-NLS-1$
    mpswr.setWebMethodName(
        "CreditTransaction"); // Set WebServices webmethod to selected type //$NON-NLS-1$
    mpswr.setTimeout(10); // Set request timeout to 10 seconds

    String mpsResponse = mpswr.sendRequest();

    MercuryResponse result = new MercuryResponse(mpsResponse);
    if (!result.isApproved()) {
      throw new PosException("Error authorizing transaction."); // $NON-NLS-1$
    }

    transaction.setCardTransactionId(result.getTransactionId());
    transaction.setCardAuthCode(result.getAuthCode());
  }
  private void closeTicketIfApplicable(Ticket ticket, Date currentDate) {
    OrderType ticketType = ticket.getType();

    switch (ticketType) {
      case DINE_IN:
      case BAR_TAB:
      case TAKE_OUT:
        ticket.setClosed(true);
        ticket.setClosingDate(currentDate);
        break;

      default:
        break;
    }
  }
Пример #14
0
 public MultiCurrencyTenderDialog(Ticket ticket, List<Currency> currencyList) {
   super();
   this.ticket = ticket;
   this.currencyList = currencyList;
   this.dueAmount = ticket.getDueAmount();
   init();
 }
Пример #15
0
  @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();
  }
Пример #16
0
    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 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();
  }
Пример #20
0
  public List<Gratuity> getServerGratuities(Terminal terminal, String transactionType) {
    Session session = null;
    ArrayList<Gratuity> gratuities = new ArrayList<Gratuity>();

    try {
      session = getSession();
      Criteria criteria = session.createCriteria(getReferenceClass());
      criteria.add(Restrictions.eq(Ticket.PROP_DRAWER_RESETTED, Boolean.FALSE));
      criteria.add(Restrictions.eq(Ticket.PROP_TERMINAL, terminal));
      criteria.createAlias(Ticket.PROP_GRATUITY, "gratuity");
      criteria.add(Restrictions.eq("gratuity.paid", Boolean.FALSE));

      List list = criteria.list();
      for (Iterator iter = list.iterator(); iter.hasNext(); ) {
        Ticket ticket = (Ticket) iter.next();
        gratuities.add(ticket.getGratuity());
      }
      return gratuities;
    } finally {
      closeSession(session);
    }
  }
  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);
    }
  }
Пример #22
0
  @Override
  public void preAuth(PosTransaction transaction) throws Exception {
    Ticket ticket = transaction.getTicket();

    if (ticket.getOrderType().name() == OrderType.BAR_TAB
        && ticket.hasProperty("AcqRefData")) { // $NON-NLS-1$ //fix
      captureAuthAmount(transaction);
      return;
    }

    String mpsResponse = doPreAuth(ticket, transaction.getCardTrack(), transaction.getAmount());

    MercuryResponse result = new MercuryResponse(mpsResponse);
    if (!result.isApproved()) {
      throw new PosException(Messages.getString("MercuryPayProcessor.13")); // $NON-NLS-1$
    }

    System.out.println(mpsResponse);

    transaction.setCardTransactionId(result.getTransactionId());
    transaction.setCardAuthCode(result.getAuthCode());
    transaction.addProperty("AcqRefData", result.getAcqRefData()); // $NON-NLS-1$
  }
  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);
  }
Пример #24
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);
    }
  }
Пример #25
0
  private String doPreAuth(Ticket ticket, String cardTrack, double amount)
      throws IOException, Exception {
    String xml =
        StreamUtils.toString(
            MercuryPayProcessor.class.getResourceAsStream(
                "/com/mercurypay/ws/sdk/mercuryAuth.xml")); //$NON-NLS-1$

    String[] strings = cardTrack.split("\\|"); // $NON-NLS-1$

    // String merchantId = "118725340908147";
    String laneId = "01"; // $NON-NLS-1$
    String tranCode = "PreAuth"; // $NON-NLS-1$
    String invoiceNo = String.valueOf(ticket.getId());
    String amountStrng = NumberUtil.formatNumber(amount);
    String encryptedBlock = strings[3];
    String encryptedKey = strings[9];

    xml = xml.replace($merchantId, CardConfig.getMerchantAccount());
    xml = xml.replace($laneId, laneId);
    xml = xml.replace($tranCode, tranCode);
    xml = xml.replace($invoiceNo, invoiceNo);
    xml = xml.replace($refNo, invoiceNo);
    xml = xml.replace($encryptedBlock, encryptedBlock);
    xml = xml.replace($encryptedKey, encryptedKey);
    xml = xml.replace($amount, amountStrng);
    xml = xml.replace($authorizeAmount, amountStrng);

    System.out.println(xml);

    MercuryWebRequest mpswr =
        new MercuryWebRequest("https://w1.mercurydev.net/ws/ws.asmx"); // $NON-NLS-1$
    mpswr.addParameter(
        "tran",
        xml); // Set WebServices 'tran' parameter to the XML transaction request //$NON-NLS-1$
    mpswr.addParameter(
        "pw", CardConfig.getMerchantPass()); // Set merchant's WebServices password //$NON-NLS-1$
    mpswr.setWebMethodName(
        "CreditTransaction"); // Set WebServices webmethod to selected type //$NON-NLS-1$
    mpswr.setTimeout(10); // Set request timeout to 10 seconds

    String mpsResponse = mpswr.sendRequest();
    return mpsResponse;
  }
  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);
  }
Пример #27
0
  @Override
  public void saveOrUpdate(Ticket ticket, Session s) {
    ticket.setActiveDate(Calendar.getInstance().getTime());

    super.saveOrUpdate(ticket, s);
  }