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;
  }
Beispiel #2
0
  public List<TicketLineInfo> getAffectedLinesUnit() {
    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;

      if (line.getMultiply() > 1.0) {
        line.setMultiply(line.getMultiply() - 1.0);
        ticketlines.setTicketLine(i, line);
        line = line.copyTicketLine();
        line.setMultiply(1.0);
        lines.add(line);
        i++;
      } else if (line.getMultiply() == 1.0) {
        lines.add(new TicketLineInfo(line));
        ticket.removeLine(i);
        ticketlines.removeTicketLine(i);
      }

      /* 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())) {
          if (line.getMultiply() > 1.0) {
            line.setMultiply(line.getMultiply() - 1.0);
            ticketlines.setTicketLine(i, line);
            line = line.copyTicketLine();
            line.setMultiply(1.0);
            lines.add(line);
            i++;
          } else if (line.getMultiply() == 1.0) {
            ticket.removeLine(i);
            ticketlines.removeTicketLine(i);
            lines.add(line);
          }
        }
      }
      printTotals();
    }
    return lines;
  }
Beispiel #3
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();
  }