private void readTicket() {

    try {
      Integer ticketid = m_jTicketEditor.getValueInteger();
      TicketInfo ticket = m_dlSales.loadTicket(TicketInfo.RECEIPT_NORMAL, ticketid);
      if (ticket == null) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.notexiststicket"));
        msg.show(this);
      } else {
        m_ticket = ticket;
        m_ticketCopy = null; // se asigna al pulsar el boton de editar o devolver
        printTicket();
      }

    } catch (BasicException e) {
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadticket"), e);
      msg.show(this);
    }

    m_jTicketEditor.reset();
  }
  private void printTicket(String resname, TicketInfo ticket, CustomerInfoExt customer) {

    String resource = dlsystem.getResourceAsXML(resname);
    if (resource == null) {
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"));
      msg.show(this);
    } else {
      try {
        ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);
        script.put("ticket", ticket);
        script.put("customer", customer);
        ttp.printTicket(script.eval(resource).toString());
      } catch (ScriptException e) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e);
        msg.show(this);
      } catch (TicketPrinterException e) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e);
        msg.show(this);
      }
    }
  }
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    m_jName = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    m_jQuantity = new javax.swing.JTextField();
    m_jPercentage = new javax.swing.JCheckBox();

    setLayout(null);
    add(m_jName);
    m_jName.setBounds(100, 20, 200, 20);

    jLabel2.setText(AppLocal.getIntString("Label.Name")); // NOI18N
    add(jLabel2);
    jLabel2.setBounds(20, 20, 80, 17);

    jLabel3.setText(AppLocal.getIntString("label.quantity")); // NOI18N
    add(jLabel3);
    jLabel3.setBounds(20, 50, 80, 17);
    add(m_jQuantity);
    m_jQuantity.setBounds(100, 50, 60, 20);

    m_jPercentage.setText(AppLocal.getIntString("label.percentage")); // NOI18N
    add(m_jPercentage);
    m_jPercentage.setBounds(170, 50, 97, 22);
  } // </editor-fold>//GEN-END:initComponents
  private void btnCustomerActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnCustomerActionPerformed

    JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlcustomers);
    finder.search(null);
    finder.setVisible(true);
    CustomerInfo customer = finder.getSelectedCustomer();
    if (customer != null) {
      try {
        CustomerInfoExt c = dlsales.loadCustomerExt(customer.getId());
        if (c == null) {
          MessageInf msg =
              new MessageInf(
                  MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"));
          msg.show(this);
        } else {
          editCustomer(c);
        }
      } catch (BasicException ex) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex);
        msg.show(this);
      }
    }
    editorcard.reset();
    editorcard.activate();
  } // GEN-LAST:event_btnCustomerActionPerformed
  private void jEditAttributesActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jEditAttributesActionPerformed

    if (productid == null) {
      // first select the product.
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_WARNING, AppLocal.getIntString("message.productnotselected"));
      msg.show(this);
    } else {
      try {
        JProductAttEdit attedit = JProductAttEdit.getAttributesEditor(this, m_App.getSession());
        attedit.editAttributes(attsetid, attsetinstid);
        attedit.setVisible(true);

        if (attedit.isOK()) {
          // The user pressed OK
          attsetinstid = attedit.getAttributeSetInst();
          attsetinstdesc = attedit.getAttributeSetInstDescription();
          jattributes.setText(attsetinstdesc);
        }
      } catch (BasicException ex) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindattributes"), ex);
        msg.show(this);
      }
    }
  } // GEN-LAST:event_jEditAttributesActionPerformed
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanel2 = new javax.swing.JPanel();
    jcmdOK = new javax.swing.JButton();
    jcmdCancel = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(AppLocal.getIntString("caption.upload")); // NOI18N
    setResizable(false);

    jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

    jcmdOK.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N
    jcmdOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N
    jcmdOK.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdOKActionPerformed(evt);
          }
        });
    jPanel2.add(jcmdOK);

    jcmdCancel.setIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/com/openbravo/images/cancel.png"))); // NOI18N
    jcmdCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N
    jcmdCancel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdCancelActionPerformed(evt);
          }
        });
    jPanel2.add(jcmdCancel);

    getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);

    jPanel1.setLayout(null);

    jLabel1.setText(AppLocal.getIntString("message.preparescanner")); // NOI18N
    jPanel1.add(jLabel1);
    jLabel1.setBounds(20, 30, 420, 14);

    getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 474) / 2, (screenSize.height - 161) / 2, 474, 161);
  } // </editor-fold>//GEN-END:initComponents
  private void m_jDelTicketActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_m_jDelTicketActionPerformed

    int res =
        JOptionPane.showConfirmDialog(
            this,
            AppLocal.getIntString("message.wannadelete"),
            AppLocal.getIntString("title.editor"),
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    if (res == JOptionPane.YES_OPTION) {
      deleteTicket();
    }
  } // GEN-LAST:event_m_jDelTicketActionPerformed
  private void readTicket(int iTicketid, int iTickettype) {
    Integer findTicket = 0;
    try {
      findTicket = m_jTicketEditor.getValueInteger();
    } catch (BasicException e) {
    }

    try {

      TicketInfo ticket =
          (iTicketid == -1)
              ? m_dlSales.loadTicket(iTickettype, findTicket)
              : m_dlSales.loadTicket(iTickettype, iTicketid);

      if (ticket == null) {
        // MessageInf msg = new MessageInf(MessageInf.SGN_WARNING,
        // AppLocal.getIntString("message.notexiststicket"));
        // msg.show(this);
        JFrame frame = new JFrame();
        JOptionPane.showMessageDialog(
            frame,
            AppLocal.getIntString("message.notexiststicket"),
            AppLocal.getIntString("message.notexiststickettitle"),
            JOptionPane.WARNING_MESSAGE);

      } else {
        m_ticket = ticket;
        m_ticketCopy = null; // se asigna al pulsar el boton de editar o devolver

        try {
          taxeslogic.calculateTaxes(m_ticket);
          TicketTaxInfo[] taxlist = m_ticket.getTaxLines();
          //  taxcollection = new ListKeyed<TaxInfo>(taxlist);
        } catch (TaxesException ex) {
        }
        printTicket();
      }

    } catch (BasicException e) {
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadticket"), e);
      msg.show(this);
    }

    m_jTicketEditor.reset();
    m_jTicketEditor.activate();
  }
  private void setActiveTicket(String id) throws BasicException {

    currentTicket = panelticket.getActiveTicket().getId();

    // save current ticket
    //        if (currentTicket != null) {
    //            try {
    //                dataLogicReceipts.insertSharedTicket(currentTicket,
    // panelticket.getActiveTicket());
    //            } catch (BasicException e) {
    //                new MessageInf(e).show(this);
    //            }
    //        }
    // set ticket
    // BEGIN TRANSACTION
    TicketInfo ticket = dataLogicReceipts.getSharedTicket(id);
    if (ticket == null) {
      // Does not exists ???
      throw new BasicException(AppLocal.getIntString("message.noticket"));
    } else {
      dataLogicReceipts.deleteSharedTicket(id);
      currentTicket = id;
      panelticket.setActiveTicket(ticket, null);
      fireTicketSelectionChanged(ticket.getId());
    }
    // END TRANSACTION
  }
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel3 = new javax.swing.JLabel();
    m_jName = new javax.swing.JTextField();
    jPanel3 = new javax.swing.JPanel();
    m_jImage = new com.openbravo.data.gui.JImageEditor();

    setMinimumSize(new java.awt.Dimension(91, 125));
    setLayout(new java.awt.BorderLayout());

    jPanel1.setPreferredSize(new java.awt.Dimension(150, 100));
    jPanel1.setLayout(null);

    jLabel3.setText(AppLocal.getIntString("Label.Name")); // NOI18N
    jPanel1.add(jLabel3);
    jLabel3.setBounds(20, 20, 90, 20);
    jPanel1.add(m_jName);
    m_jName.setBounds(110, 20, 180, 22);

    add(jPanel1, java.awt.BorderLayout.NORTH);

    jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 0));
    jPanel3.setLayout(new java.awt.BorderLayout());
    jPanel3.add(m_jImage, java.awt.BorderLayout.CENTER);

    add(jPanel3, java.awt.BorderLayout.CENTER);
  } // </editor-fold>//GEN-END:initComponents
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    m_jTitle = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    m_jQuantity = new javax.swing.JTextField();
    jLabel4 = new javax.swing.JLabel();
    m_jMinimum = new javax.swing.JTextField();
    jLabel5 = new javax.swing.JLabel();
    m_jMaximum = new javax.swing.JTextField();

    setLayout(null);

    m_jTitle.setFont(new java.awt.Font("SansSerif", 3, 18)); // NOI18N
    add(m_jTitle);
    m_jTitle.setBounds(10, 10, 320, 30);

    jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel3.setText(AppLocal.getIntString("label.units")); // NOI18N
    add(jLabel3);
    jLabel3.setBounds(10, 50, 150, 25);

    m_jQuantity.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    m_jQuantity.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    m_jQuantity.setEnabled(false);
    add(m_jQuantity);
    m_jQuantity.setBounds(160, 50, 80, 25);

    jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel4.setText(AppLocal.getIntString("label.minimum")); // NOI18N
    add(jLabel4);
    jLabel4.setBounds(10, 80, 150, 25);

    m_jMinimum.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    m_jMinimum.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    add(m_jMinimum);
    m_jMinimum.setBounds(160, 80, 80, 25);

    jLabel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel5.setText(AppLocal.getIntString("label.maximum")); // NOI18N
    add(jLabel5);
    jLabel5.setBounds(10, 110, 150, 25);

    m_jMaximum.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    m_jMaximum.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    add(m_jMaximum);
    m_jMaximum.setBounds(160, 110, 80, 25);
  } // </editor-fold>//GEN-END:initComponents
Beispiel #12
0
  // <editor-fold defaultstate="collapsed" desc="Generated
  // Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel3 = new javax.swing.JLabel();
    m_jName = new javax.swing.JTextField();
    jPanel3 = new javax.swing.JPanel();
    m_jImage = new com.openbravo.data.gui.JImageEditor(m_App);

    setLayout(new java.awt.BorderLayout());

    // jPanel1.setPreferredSize(new java.awt.Dimension(150, 100));
    GridBagLayout gbl_panel = new GridBagLayout();
    gbl_panel.columnWeights = new double[] {0.0, 1.0, 0.0};
    gbl_panel.rowWeights =
        new double[] {
          0.0,
        };
    jPanel1.setLayout(gbl_panel);

    jLabel3.setText(AppLocal.getIntString("Label.Name")); // NOI18N
    GridBagConstraints lbl1 = new GridBagConstraints();
    lbl1.anchor = GridBagConstraints.WEST;
    lbl1.insets = new Insets(5, 5, 0, 0);
    lbl1.gridx = 0;
    lbl1.gridy = 0;
    jPanel1.add(jLabel3, lbl1);

    GridBagConstraints gbc_textPane = new GridBagConstraints();
    gbc_textPane.fill = GridBagConstraints.HORIZONTAL;
    gbc_textPane.insets = new Insets(5, 5, 0, 0);
    gbc_textPane.weightx = 1.0;
    gbc_textPane.gridx = 1;
    gbc_textPane.gridy = 0;
    jPanel1.add(m_jName, gbc_textPane);

    JLabel lblSpace1 = new JLabel("");
    GridBagConstraints gbc_space1 = new GridBagConstraints();
    gbc_space1.insets = new Insets(5, 5, 0, 0);
    gbc_space1.weightx = 1.0;
    gbc_space1.gridx = 2;
    gbc_space1.gridy = 0;
    jPanel1.add(lblSpace1, gbc_space1);

    JLabel lblSpace2 = new JLabel("");
    GridBagConstraints gbc_space2 = new GridBagConstraints();
    gbc_space2.insets = new Insets(5, 5, 0, 0);
    gbc_space2.gridx = 0;
    gbc_space2.gridy = 1;
    jPanel1.add(lblSpace2, gbc_space2);

    add(jPanel1, java.awt.BorderLayout.NORTH);

    jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 0, 0));
    jPanel3.setLayout(new java.awt.BorderLayout());
    jPanel3.add(m_jImage, java.awt.BorderLayout.CENTER);

    add(jPanel3, java.awt.BorderLayout.CENTER);
  } // </editor-fold>//GEN-END:initComponents
 @Override
 public Vectorer getVectorer() {
   return new VectorerBasic(
       new String[] {
         "ID",
         AppLocal.getIntString("label.prodref"),
         AppLocal.getIntString("label.prodbarcode"),
         AppLocal.getIntString("label.prodname"),
         "ISCOM",
         "ISSCALE",
         AppLocal.getIntString("label.prodpricebuy"),
         AppLocal.getIntString("label.prodpricesell"),
         AppLocal.getIntString("label.prodcategory"),
         AppLocal.getIntString("label.prodtax"),
         "IMAGE",
         "STOCKCOST",
         "STOCKVOLUME"
       },
       new Formats[] {
         Formats.STRING,
         Formats.STRING,
         Formats.STRING,
         Formats.STRING,
         Formats.BOOLEAN,
         Formats.BOOLEAN,
         Formats.CURRENCY,
         Formats.CURRENCY,
         Formats.STRING,
         Formats.STRING,
         Formats.NULL,
         Formats.CURRENCY,
         Formats.DOUBLE
       },
       new int[] {1, 2, 3, 7});
 }
Beispiel #14
0
 public boolean deactivate() {
   if (dirty.isDirty()) {
     int res =
         JOptionPane.showConfirmDialog(
             this,
             AppLocal.getIntString("message.wannasave"),
             AppLocal.getIntString("title.editor"),
             JOptionPane.YES_NO_CANCEL_OPTION,
             JOptionPane.QUESTION_MESSAGE);
     if (res == JOptionPane.YES_OPTION) {
       save();
       return true;
     } else {
       return res == JOptionPane.NO_OPTION;
     }
   } else {
     return true;
   }
 }
  private void jcmdOKActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jcmdOKActionPerformed

    // Ponemos el estado de leyendo productos
    String stext = jLabel1.getText();
    jLabel1.setText(AppLocal.getIntString("label.uploadingproducts"));
    jcmdOK.setEnabled(false);
    jcmdCancel.setEnabled(false);

    // Ejecutamos la descarga...
    try {
      m_scanner.connectDevice();
      m_scanner.startUploadProduct();

      ListModel l = m_bd.getListModel();
      for (int i = 0; i < l.getSize(); i++) {
        Object[] myprod = (Object[]) l.getElementAt(i);
        m_scanner.sendProduct(
            (String) myprod[3], // name
            (String) myprod[2], // barcode
            (Double) myprod[6] // buy price
            );
      }
      m_scanner.stopUploadProduct();
      MessageInf msg =
          new MessageInf(MessageInf.SGN_SUCCESS, AppLocal.getIntString("message.scannerok"));
      msg.show(this);
    } catch (DeviceScannerException e) {
      MessageInf msg =
          new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.scannerfail"), e);
      msg.show(this);
    } finally {
      m_scanner.disconnectDevice();
    }

    // Deshacemos el estado de leyendo productos
    jLabel1.setText(stext);
    jcmdOK.setEnabled(true);
    jcmdCancel.setEnabled(true);

    dispose();
  } // GEN-LAST:event_jcmdOKActionPerformed
  private void printTicket() {

    // imprimo m_ticket

    try {
      m_jEdit.setEnabled(
          m_ticket != null
              && (m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL
                  || m_ticket.getTicketType() == TicketInfo.RECEIPT_REFUND)
              && m_dlSales.isCashActive(m_ticket.getActiveCash()));
    } catch (BasicException e) {
      m_jEdit.setEnabled(false);
    }
    m_jRefund.setEnabled(m_ticket != null && m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL);
    m_jPrint.setEnabled(m_ticket != null);

    // Este deviceticket solo tiene una impresora, la de pantalla
    m_TP.getDevicePrinter("1").reset();

    if (m_ticket == null) {
      m_jTicketId.setText(null);
    } else {
      m_jTicketId.setText(m_ticket.getName());

      try {
        ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);
        script.put("ticket", m_ticket);
        m_TTP.printTicket(
            script.eval(m_dlSystem.getResourceAsXML("Printer.TicketPreview")).toString());
      } catch (ScriptException e) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e);
        msg.show(this);
      } catch (TicketPrinterException eTP) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), eTP);
        msg.show(this);
      }
    }
  }
  /** Creates new form JInventoryLines */
  public JInventoryLines() {

    initComponents();

    DefaultTableColumnModel columns = new DefaultTableColumnModel();
    TableColumn c;

    c =
        new TableColumn(
            0,
            200,
            new DataCellRenderer(javax.swing.SwingConstants.LEFT),
            new DefaultCellEditor(new JTextField()));
    c.setHeaderValue(AppLocal.getIntString("label.item"));
    columns.addColumn(c);
    c =
        new TableColumn(
            1,
            75,
            new DataCellRenderer(javax.swing.SwingConstants.RIGHT),
            new DefaultCellEditor(new JTextField()));
    c.setHeaderValue(AppLocal.getIntString("label.units"));
    columns.addColumn(c);
    c =
        new TableColumn(
            2,
            75,
            new DataCellRenderer(javax.swing.SwingConstants.RIGHT),
            new DefaultCellEditor(new JTextField()));
    c.setHeaderValue(AppLocal.getIntString("label.price"));
    columns.addColumn(c);

    m_tableinventory.setColumnModel(columns);

    m_tableinventory.getTableHeader().setReorderingAllowed(false);
    m_tableinventory.setRowHeight(40);
    m_tableinventory.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_tableinventory.setIntercellSpacing(new java.awt.Dimension(0, 1));

    m_inventorylines = new InventoryTableModel();
    m_tableinventory.setModel(m_inventorylines);
  }
  private void m_jPrintActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_m_jPrintActionPerformed

    if (m_ticket != null) {
      try {
        ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);
        script.put("ticket", m_ticket);
        m_TTP2.printTicket(
            script.eval(m_dlSystem.getResourceAsXML("Printer.TicketPreview")).toString());
      } catch (ScriptException e) {
        JMessageDialog.showMessage(
            this,
            new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotprint"), e));
      } catch (TicketPrinterException e) {
        JMessageDialog.showMessage(
            this,
            new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotprint"), e));
      }
    }
  } // GEN-LAST:event_m_jPrintActionPerformed
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    m_jContainer = new javax.swing.JPanel();

    setTitle(AppLocal.getIntString("Display.Window")); // NOI18N

    m_jContainer.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    m_jContainer.setLayout(new java.awt.BorderLayout());
    getContentPane().add(m_jContainer, java.awt.BorderLayout.CENTER);

    setSize(new java.awt.Dimension(767, 245));
  } // </editor-fold>//GEN-END:initComponents
  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 #21
0
  private void save() {

    customerext.setNotes(txtNotes.getText());

    try {
      dlcustomers.updateCustomerExt(customerext);
      editCustomer(customerext);
    } catch (BasicException e) {
      MessageInf msg =
          new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosave"), e);
      msg.show(this);
    }
  }
  private void printPayments(String report) {

    String sresource = m_dlSystem.getResourceAsXML(report);
    if (sresource == null) {
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"));
      msg.show(this);
    } else {
      try {
        ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);
        script.put("payments", m_PaymentsToClose);
        m_TTP.printTicket(script.eval(sresource).toString());
        // JG 16 May 2012 use multicatch
      } catch (ScriptException | TicketPrinterException e) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e);
        msg.show(this);
      }
    }
  }
Beispiel #23
0
  private void readCustomer() {

    try {
      CustomerInfoExt customer = dlsales.findCustomerExt(editorcard.getText());
      if (customer == null) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"));
        msg.show(this);
      } else {
        editCustomer(customer);
      }

    } catch (BasicException ex) {
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex);
      msg.show(this);
    }

    editorcard.reset();
    editorcard.activate();
  }
 @Override
 public void writeValueInsert() {
   m_jTitle.setText(AppLocal.getIntString("label.recordnew"));
   id = null;
   prodid = null;
   prodref = null;
   prodname = null;
   location = null;
   m_jQuantity.setText(null);
   m_jMinimum.setText(null);
   m_jMaximum.setText(null);
   m_jMinimum.setEnabled(true);
   m_jMaximum.setEnabled(true);
 }
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jLabel2 = new javax.swing.JLabel();
    jValue = new javax.swing.JTextField();

    jLabel2.setText(AppLocal.getIntString("label.value")); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 316, Short.MAX_VALUE)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jLabel2,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        80,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jValue,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        200,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 43, Short.MAX_VALUE)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(
                                jValue,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
  } // </editor-fold>//GEN-END:initComponents
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jLabel8 = new javax.swing.JLabel();
    jAttr = new javax.swing.JComboBox();

    jLabel8.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel8.setText(AppLocal.getIntString("label.attribute")); // NOI18N

    jAttr.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jLabel8,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        110,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jAttr,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        220,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(
                                jAttr, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                            .addComponent(
                                jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE))
                    .addContainerGap(22, Short.MAX_VALUE)));
  } // </editor-fold>//GEN-END:initComponents
  private void setActiveTicket(String id) throws BasicException {

    TicketInfo ticket = dlReceipts.getSharedTicket(id);
    if (ticket == null) {
      m_jListTickets.setText("");
      throw new BasicException(AppLocal.getIntString("message.noticket"));
    } else {
      dlReceipts.getPickupId(id);
      Integer pickUp = dlReceipts.getPickupId(id);
      dlReceipts.deleteSharedTicket(id);
      m_sCurrentTicket = id;
      m_panelticket.setActiveTicket(ticket, null);
      ticket.setPickupId(pickUp);
    }
    // END TRANSACTION
  }
Beispiel #28
0
  @Override
  public Component getToolbarExtrasDevicePLUs() {

    JButton btnDevicePLUs = new JButton();
    btnDevicePLUs.setText(AppLocal.getIntString("button.uploadplu"));
    btnDevicePLUs.setVisible(app.getDevicePLUs() != null);
    btnDevicePLUs.addActionListener(
        new java.awt.event.ActionListener() {
          @Override
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnExtrasDevicePLUsActionPerformed(evt);
          }
        });

    return btnDevicePLUs;
  }
Beispiel #29
0
  protected void addTabPayment(JPaymentCreator jpay) {
    if (app.getAppUserView().getUser().hasPermission(jpay.getKey())) {

      JPaymentInterface jpayinterface = payments.get(jpay.getKey());
      if (jpayinterface == null) {
        jpayinterface = jpay.createJPayment();
        payments.put(jpay.getKey(), jpayinterface);
      }

      jpayinterface.getComponent().applyComponentOrientation(getComponentOrientation());
      m_jTabPayment.addTab(
          AppLocal.getIntString(jpay.getLabelKey()),
          new javax.swing.ImageIcon(getClass().getResource(jpay.getIconKey())),
          jpayinterface.getComponent());
    }
  }
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
      if ("button".equals(qName)) {

        // The button title text
        String titlekey = attributes.getValue("titlekey");
        if (titlekey == null) {
          titlekey = attributes.getValue("name");
        }
        String title =
            titlekey == null ? attributes.getValue("title") : AppLocal.getIntString(titlekey);

        // adding the button to the panel
        JButton btn =
            new JButtonFunc(attributes.getValue("key"), attributes.getValue("image"), title);

        // The template resource or the code resource
        final String template = attributes.getValue("template");
        if (template == null) {
          final String code = attributes.getValue("code");
          btn.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  panelticket.evalScriptAndRefresh(code);
                }
              });
        } else {
          btn.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  panelticket.printTicket(template);
                }
              });
        }
        add(btn);

      } else if ("event".equals(qName)) {
        events.put(attributes.getValue("key"), attributes.getValue("code"));
      } else {
        String value = attributes.getValue("value");
        if (value != null) {
          props.setProperty(qName, attributes.getValue("value"));
        }
      }
    }