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; }
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(); }