Esempio n. 1
0
  private void printTotals() {

    if (m_bunitsok && m_bpriceok) {
      m_jSubtotal.setText(m_oLine.printSubValue());
      m_jTotal.setText(m_oLine.printValue());
      m_jButtonOK.setEnabled(true);
    } else {
      m_jSubtotal.setText(null);
      m_jTotal.setText(null);
      m_jButtonOK.setEnabled(false);
    }
  }
Esempio n. 2
0
  public List<TicketLineInfo> getAffectedLines() {
    List<TicketLineInfo> lines = new ArrayList<TicketLineInfo>();

    int i = ticketlines.getSelectedIndex();
    if (i >= 0) {
      TicketLineInfo line = ticket.getLine(i);

      /* Si el producto seleccionado es axuliar o descuento, no podemos transferirlo */
      if (line.isProductCom() || line.isDiscount()) return lines;

      ticket.removeLine(i);
      ticketlines.removeTicketLine(i);
      lines.add(line);

      /* Comprobamos si la linea corresponde a un producto con productos auxiliares
       * como puede ser un menu o si tiene algun descuento por linea asociado
       */
      if (!line.isProductCom() && !line.isDiscount()) {
        while (i < ticket.getLinesCount()
            && ((line = (TicketLineInfo) ticket.getLine(i)).isProductCom() || line.isDiscount())) {
          lines.add(new TicketLineInfo(line));
          ticket.removeLine(i);
          ticketlines.removeTicketLine(i);
        }
      }
      printTotals();
    }
    return lines;
  }
Esempio n. 3
0
  private TicketLineInfo init(AppView app, TicketLineInfo oLine) throws BasicException {
    // Inicializo los componentes
    initComponents();

    if (oLine.getTaxInfo() == null) {
      throw new BasicException(AppLocal.getIntString("message.cannotcalculatetaxes"));
    }

    m_oLine = new TicketLineInfo(oLine);
    m_bunitsok = true;
    m_bpriceok = true;

    m_jName.setEnabled(
        m_oLine.getProductID() == null
            && app.getAppUserView()
                .getUser()
                .hasPermission("com.openbravo.pos.sales.JPanelTicketEdits"));
    m_jPrice.setEnabled(
        app.getAppUserView().getUser().hasPermission("com.openbravo.pos.sales.JPanelTicketEdits"));
    m_jPriceTax.setEnabled(
        app.getAppUserView().getUser().hasPermission("com.openbravo.pos.sales.JPanelTicketEdits"));

    m_jName.setText(m_oLine.getProperty("product.name"));
    m_jUnits.setDoubleValue(oLine.getMultiply());
    m_jPrice.setDoubleValue(oLine.getPrice());
    m_jPriceTax.setDoubleValue(oLine.getPriceTax());
    m_jTaxrate.setText(oLine.getTaxInfo().getName());

    m_jName.addPropertyChangeListener("Edition", new RecalculateName());
    m_jUnits.addPropertyChangeListener("Edition", new RecalculateUnits());
    m_jPrice.addPropertyChangeListener("Edition", new RecalculatePrice());
    m_jPriceTax.addPropertyChangeListener("Edition", new RecalculatePriceTax());

    m_jName.addEditorKeys(m_jKeys);
    m_jUnits.addEditorKeys(m_jKeys);
    m_jPrice.addEditorKeys(m_jKeys);
    m_jPriceTax.addEditorKeys(m_jKeys);

    if (m_jName.isEnabled()) {
      m_jName.activate();
    } else {
      m_jUnits.activate();
    }

    printTotals();

    getRootPane().setDefaultButton(m_jButtonOK);
    returnLine = null;
    setVisible(true);

    return returnLine;
  }
Esempio n. 4
0
  public void addAffectedLines(List<TicketLineInfo> lines) {

    int i = ticketlines.getSelectedIndex();
    int e = 0;
    for (e = 0; e < lines.size(); e++, i++) {
      TicketLineInfo line = lines.get(e);
      if (i >= 0
          && ticket.getLine(i).getProduct().getId() != null
          && line.getProduct().getId() != null
          && ticket.getLine(i).getProduct().getId().equals(line.getProduct().getId())
          && ticket.getLine(i).getTaxInfo().getId().equals(line.getTaxInfo().getId())
          && ticket.getLine(i).getPrice() == line.getPrice()) {
        // inc the line
        ticket.getLine(i).setMultiply(ticket.getLine(i).getMultiply() + line.getMultiply());
        ticketlines.setTicketLine(i, ticket.getLine(i));
      } else {
        ticket.addLine(line);
        ticketlines.addTicketLine(line);
      }
    }
    printTotals();
  }