@Override
  public void init(AppView app) throws BeanFactoryException {

    m_App = app;
    m_dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem");
    m_TTP = new TicketParser(m_App.getDeviceTicket(), m_dlSystem);

    m_jTicketTable.setDefaultRenderer(
        Object.class,
        new TableRendererBasic(new Formats[] {new FormatsPayment(), Formats.CURRENCY}));
    m_jTicketTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    m_jScrollTableTicket.getVerticalScrollBar().setPreferredSize(new Dimension(25, 25));
    m_jTicketTable.getTableHeader().setReorderingAllowed(false);
    m_jTicketTable.setRowHeight(25);
    m_jTicketTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    m_jsalestable.setDefaultRenderer(
        Object.class,
        new TableRendererBasic(
            new Formats[] {Formats.STRING, Formats.CURRENCY, Formats.CURRENCY, Formats.CURRENCY}));
    m_jsalestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    m_jScrollSales.getVerticalScrollBar().setPreferredSize(new Dimension(25, 25));
    m_jsalestable.getTableHeader().setReorderingAllowed(false);
    m_jsalestable.setRowHeight(25);
    m_jsalestable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  }
Пример #2
0
 public void init(AppView app) {
   this.app = app;
   dlSystem = (DataLogicSystem) app.getBean("com.openbravo.pos.forms.DataLogicSystem");
   printselected = true;
   // MSL
   dlSales = (DataLogicSales) app.getBean("com.openbravo.pos.forms.DataLogicSales");
 }
Пример #3
0
  public void init(AppView app) throws BeanFactoryException {

    this.app = app;
    dlcustomers =
        (DataLogicCustomers) app.getBean("com.openbravo.pos.customers.DataLogicCustomers");
    dlsales = (DataLogicSales) app.getBean("com.openbravo.pos.forms.DataLogicSales");
    dlsystem = (DataLogicSystem) app.getBean("com.openbravo.pos.forms.DataLogicSystem");
    ttp = new TicketParser(app.getDeviceTicket(), dlsystem);
  }
Пример #4
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;
  }
Пример #5
0
  /**
   * Creates new form JTicketsBagTicket
   *
   * @param app
   * @param panelticket
   */
  public JTicketsBagTicket(AppView app, JPanelTicketEdits panelticket) {

    super(app, panelticket);
    m_panelticketedit = panelticket;
    m_dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem");
    m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");
    dlCustomers =
        (DataLogicCustomers) m_App.getBean("com.openbravo.pos.customers.DataLogicCustomers");

    // Inicializo la impresora...
    // JG July 2014 - Thank you Ron Isaacson        m_TP = new DeviceTicket();
    m_TP = new DeviceTicket(app.getProperties());

    // Inicializo el parser de documentos de ticket
    m_TTP = new TicketParser(m_TP, m_dlSystem); // para visualizar el ticket
    m_TTP2 = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); // para imprimir el ticket

    initComponents();

    m_TicketsBagTicketBag = new JTicketsBagTicketBag(this);

    m_jTicketEditor.addEditorKeys(m_jKeys);

    // Este deviceticket solo tiene una impresora, la de pantalla
    m_jPanelTicket.add(m_TP.getDevicePrinter("1").getPrinterComponent(), BorderLayout.CENTER);

    try {
      taxeslogic = new TaxesLogic(m_dlSales.getTaxList().list());
    } catch (BasicException ex) {
    }
  }
 @Override
 public void writeValueEOF() {
   m_sID = null;
   m_jdate.setText(null);
   m_ReasonModel.setSelectedKey(null);
   m_LocationsModel.setSelectedKey(m_App.getInventoryLocation());
   productid = null;
   productref = null;
   productcode = null;
   productname = null;
   m_jreference.setText(null);
   m_jcodebar.setText(null);
   jproduct.setText(null);
   attsetid = null;
   attsetinstid = null;
   attsetinstdesc = null;
   jattributes.setText(null);
   m_junits.setText(null);
   m_jprice.setText(null);
   m_jdate.setEnabled(false);
   m_jbtndate.setEnabled(false);
   m_jreason.setEnabled(false);
   m_jreference.setEnabled(false);
   m_jEnter1.setEnabled(false);
   m_jcodebar.setEnabled(false);
   m_jEnter.setEnabled(false);
   m_jLocation.setEnabled(false);
   jproduct.setEnabled(false);
   jEditProduct.setEnabled(false);
   jattributes.setEnabled(false);
   jEditAttributes.setEnabled(false);
   m_junits.setEnabled(false);
   m_jprice.setEnabled(false);
   m_cat.setComponentEnabled(false);
 }
  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
  /**
   * Creates new form JTicketsBagShared
   *
   * @param app
   * @param panelticket
   */
  public JTicketsBagSharedTicket(AppView app, TicketsEditor panelticket) {

    super(app, panelticket);

    dlReceipts = (DataLogicReceipts) app.getBean("com.openbravo.pos.sales.DataLogicReceipts");

    initComponents();
  }
Пример #9
0
  /** Creates new form StockDiaryEditor */
  public StockDiaryEditor(AppView app, DirtyManager dirty) {

    m_App = app;
    m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");

    // MSL
    m_dlSuppliers =
        (DataLogicSuppliers) m_App.getBean("com.openbravo.pos.suppliers.DataLogicSuppliers");

    initComponents();

    m_cat = new JCatalog(m_dlSales, true);
    m_cat.getComponent().setPreferredSize(new Dimension(0, 245));
    m_cat.addActionListener(new CatalogListener());
    add(m_cat.getComponent(), BorderLayout.SOUTH);

    // El modelo de locales
    m_sentlocations = m_dlSales.getLocationsList();
    m_LocationsModel = new ComboBoxValModel();

    m_ReasonModel = new ComboBoxValModel();
    m_ReasonModel.add(MovementReason.IN_PURCHASE);
    m_ReasonModel.add(MovementReason.IN_REFUND);
    m_ReasonModel.add(MovementReason.IN_MOVEMENT);
    m_ReasonModel.add(MovementReason.OUT_SALE);
    m_ReasonModel.add(MovementReason.OUT_REFUND);
    m_ReasonModel.add(MovementReason.OUT_BREAK);
    m_ReasonModel.add(MovementReason.OUT_MOVEMENT);
    m_jreason.setModel(m_ReasonModel);

    m_jdate.getDocument().addDocumentListener(dirty);
    m_jreason.addActionListener(dirty);
    m_jLocation.addActionListener(dirty);
    jproduct.getDocument().addDocumentListener(dirty);
    jattributes.getDocument().addDocumentListener(dirty);
    m_junits.getDocument().addDocumentListener(dirty);
    m_jprice.getDocument().addDocumentListener(dirty);

    writeValueEOF();
  }
  /**
   * Creates new form CustomersList
   *
   * @param dlCustomers
   * @param app
   * @param panelticket
   */
  public OrderCustomerList(DataLogicCustomers dlCustomers, AppView app, TicketsEditor panelticket) {
    this.application = app;
    this.panelticket = panelticket;
    this.dataLogicCustomers = dlCustomers;
    this.dataLogicReceipts =
        (DataLogicReceipts) application.getBean("com.openbravo.pos.sales.DataLogicReceipts");
    tnbbutton = new ThumbNailBuilder(90, 98);

    //        orderSynchroniseHelper = new OrdersSynchroniseHelper(application, dataLogicReceipts,
    // panelticket.getActiveTicket());

    initComponents();
  }
Пример #11
0
  /** @param app */
  @Override
  public void init(AppView app) {

    attsent =
        new StaticSentence(
            app.getSession(),
            "SELECT ID, NAME FROM ATTRIBUTE ORDER BY NAME",
            null,
            new SerializerRead() {
              @Override
              public Object readValues(DataRead dr) throws BasicException {
                return new AttributeInfo(dr.getString(1), dr.getString(2));
              }
            });
    attmodel = new ComboBoxValModel();
  }
Пример #12
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());
    }
  }
 /**
  * @return
  * @throws BasicException
  */
 @Override
 public Object createValue() throws BasicException {
   return new Object[] {
     m_sID,
     Formats.TIMESTAMP.parseValue(m_jdate.getText()),
     m_ReasonModel.getSelectedKey(),
     m_LocationsModel.getSelectedKey(),
     productid,
     attsetinstid,
     samesignum(
         (Double) Formats.DOUBLE.parseValue(m_junits.getText()),
         (Integer) m_ReasonModel.getSelectedKey()),
     Formats.CURRENCY.parseValue(m_jprice.getText()),
     m_App.getAppUserView().getUser().getName(),
     productref,
     productcode,
     productname,
     attsetid,
     attsetinstdesc
   };
 }
Пример #14
0
  public void writeValueInsert() {
    m_sID = UUID.randomUUID().toString();
    m_jdate.setText(Formats.TIMESTAMP.formatValue(DateUtils.getTodayMinutes()));
    m_ReasonModel.setSelectedItem(MovementReason.IN_PURCHASE);
    m_LocationsModel.setSelectedKey(m_App.getInventoryLocation());
    productid = null;
    productref = null;
    productcode = null;
    productname = null;
    m_jreference.setText(null);
    m_jcodebar.setText(null);
    jproduct.setText(null);
    attsetid = null;
    attsetinstid = null;
    attsetinstdesc = null;
    jattributes.setText(null);
    m_jcodebar.setText(null);
    m_junits.setText(null);
    m_jprice.setText(null);
    m_jdate.setEnabled(true);
    m_jbtndate.setEnabled(true);
    m_jreason.setEnabled(true);
    m_jreference.setEnabled(true);
    m_jEnter1.setEnabled(true);
    m_jcodebar.setEnabled(true);
    m_jEnter.setEnabled(true);
    m_jLocation.setEnabled(true);
    jproduct.setEnabled(true);
    jEditProduct.setEnabled(true);
    jattributes.setEnabled(true);
    jEditAttributes.setEnabled(true);
    m_junits.setEnabled(true);
    m_jprice.setEnabled(true);
    m_cat.setComponentEnabled(true);

    // MSL
    supplierid = null;
    m_jSupplierId.setText(null);
  }
  /**
   * Creates new form StockDiaryEditor
   *
   * @param app
   * @param dirty
   * @throws com.openbravo.basic.BasicException
   */
  public StockDiaryEditor(AppView app, DirtyManager dirty) throws BasicException {

    m_App = app;
    m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");

    initComponents();

    // El modelo de locales
    m_sentlocations = m_dlSales.getLocationsList();
    m_LocationsModel = new ComboBoxValModel();

    m_ReasonModel = new ComboBoxValModel();
    m_ReasonModel.add(MovementReason.IN_PURCHASE);
    m_ReasonModel.add(MovementReason.IN_REFUND);
    m_ReasonModel.add(MovementReason.IN_MOVEMENT);
    m_ReasonModel.add(MovementReason.OUT_SALE);
    m_ReasonModel.add(MovementReason.OUT_REFUND);
    m_ReasonModel.add(MovementReason.OUT_BREAK);
    m_ReasonModel.add(MovementReason.OUT_MOVEMENT);

    m_jreason.setModel(m_ReasonModel);

    m_cat = new JCatalog(m_dlSales);
    m_cat.addActionListener(new CatalogListener());

    catcontainer.add(m_cat.getComponent(), BorderLayout.CENTER);

    m_jdate.getDocument().addDocumentListener(dirty);
    m_jreason.addActionListener(dirty);
    m_jLocation.addActionListener(dirty);
    jproduct.getDocument().addDocumentListener(dirty);
    jattributes.getDocument().addDocumentListener(dirty);
    m_junits.getDocument().addDocumentListener(dirty);
    m_jprice.getDocument().addDocumentListener(dirty);

    writeValueEOF();
  }
  private void m_jCloseCashActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_m_jCloseCashActionPerformed
    // TODO add your handling code here:
    int res =
        JOptionPane.showConfirmDialog(
            this,
            AppLocal.getIntString("message.wannaclosecash"),
            AppLocal.getIntString("message.title"),
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    if (res == JOptionPane.YES_OPTION) {

      Date dNow = new Date();

      try {
        // Cerramos la caja si esta pendiente de cerrar.
        if (m_App.getActiveCashDateEnd() == null) {
          new StaticSentence(
                  m_App.getSession(),
                  "UPDATE CLOSEDCASH SET DATEEND = ? WHERE HOST = ? AND MONEY = ?",
                  new SerializerWriteBasic(
                      new Datas[] {Datas.TIMESTAMP, Datas.STRING, Datas.STRING}))
              .exec(
                  new Object[] {dNow, m_App.getProperties().getHost(), m_App.getActiveCashIndex()});
        }
      } catch (BasicException e) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e);
        msg.show(this);
      }

      try {
        // Creamos una nueva caja
        m_App.setActiveCash(
            UUID.randomUUID().toString(), m_App.getActiveCashSequence() + 1, dNow, null);

        // creamos la caja activa
        m_dlSystem.execInsertCash(
            new Object[] {
              m_App.getActiveCashIndex(),
              m_App.getProperties().getHost(),
              m_App.getActiveCashSequence(),
              m_App.getActiveCashDateStart(),
              m_App.getActiveCashDateEnd()
            });

        // ponemos la fecha de fin
        m_PaymentsToClose.setDateEnd(dNow);

        // print report
        printPayments("Printer.CloseCash");

        // Mostramos el mensaje
        JOptionPane.showMessageDialog(
            this,
            AppLocal.getIntString("message.closecashok"),
            AppLocal.getIntString("message.title"),
            JOptionPane.INFORMATION_MESSAGE);
      } catch (BasicException e) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e);
        msg.show(this);
      }

      try {
        loadData();
      } catch (BasicException e) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_NOTICE, AppLocal.getIntString("label.noticketstoclose"), e);
        msg.show(this);
      }
    }
  } // GEN-LAST:event_m_jCloseCashActionPerformed
Пример #17
0
  public static PaymentsModel loadInstance(AppView app) throws BasicException {

    PaymentsModel p = new PaymentsModel();

    // Propiedades globales
    p.m_sHost = app.getProperties().getHost();
    p.m_iSeq = app.getActiveCashSequence();
    p.m_dDateStart = app.getActiveCashDateStart();
    p.m_dDateEnd = null;

    // Pagos
    Object[] valtickets =
        (Object[])
            new StaticSentence(
                    app.getSession(),
                    "SELECT COUNT(*), SUM(PAYMENTS.TOTAL) "
                        + "FROM PAYMENTS, RECEIPTS "
                        + "WHERE PAYMENTS.RECEIPT = RECEIPTS.ID AND RECEIPTS.MONEY = ?",
                    SerializerWriteString.INSTANCE,
                    new SerializerReadBasic(new Datas[] {Datas.INT, Datas.DOUBLE}))
                .find(app.getActiveCashIndex());

    if (valtickets == null) {
      p.m_iPayments = new Integer(0);
      p.m_dPaymentsTotal = new Double(0.0);
    } else {
      p.m_iPayments = (Integer) valtickets[0];
      p.m_dPaymentsTotal = (Double) valtickets[1];
    }

    List l =
        new StaticSentence(
                app.getSession(),
                "SELECT PAYMENTS.PAYMENT, SUM(PAYMENTS.TOTAL) "
                    + "FROM PAYMENTS, RECEIPTS "
                    + "WHERE PAYMENTS.RECEIPT = RECEIPTS.ID AND RECEIPTS.MONEY = ? "
                    + "GROUP BY PAYMENTS.PAYMENT",
                SerializerWriteString.INSTANCE,
                new SerializerReadClass(
                    PaymentsModel.PaymentsLine
                        .class)) // new SerializerReadBasic(new Datas[] {Datas.STRING,
                                 // Datas.DOUBLE}))
            .list(app.getActiveCashIndex());

    if (l == null) {
      p.m_lpayments = new ArrayList();
    } else {
      p.m_lpayments = l;
    }

    // Sales
    Object[] recsales =
        (Object[])
            new StaticSentence(
                    app.getSession(),
                    "SELECT COUNT(DISTINCT RECEIPTS.ID), SUM(TICKETLINES.UNITS * TICKETLINES.PRICE) "
                        + "FROM RECEIPTS, TICKETLINES WHERE RECEIPTS.ID = TICKETLINES.TICKET AND RECEIPTS.MONEY = ?",
                    SerializerWriteString.INSTANCE,
                    new SerializerReadBasic(new Datas[] {Datas.INT, Datas.DOUBLE}))
                .find(app.getActiveCashIndex());
    if (recsales == null) {
      p.m_iSales = null;
      p.m_dSalesBase = null;
    } else {
      p.m_iSales = (Integer) recsales[0];
      p.m_dSalesBase = (Double) recsales[1];
    }

    // Taxes
    Object[] rectaxes =
        (Object[])
            new StaticSentence(
                    app.getSession(),
                    "SELECT SUM(TAXLINES.AMOUNT) "
                        + "FROM RECEIPTS, TAXLINES WHERE RECEIPTS.ID = TAXLINES.RECEIPT AND RECEIPTS.MONEY = ?",
                    SerializerWriteString.INSTANCE,
                    new SerializerReadBasic(new Datas[] {Datas.DOUBLE}))
                .find(app.getActiveCashIndex());
    if (rectaxes == null) {
      p.m_dSalesTaxes = null;
    } else {
      p.m_dSalesTaxes = (Double) rectaxes[0];
    }

    List<SalesLine> asales =
        new StaticSentence(
                app.getSession(),
                "SELECT TAXCATEGORIES.NAME, SUM(TAXLINES.AMOUNT) "
                    + "FROM RECEIPTS, TAXLINES, TAXES, TAXCATEGORIES WHERE RECEIPTS.ID = TAXLINES.RECEIPT AND TAXLINES.TAXID = TAXES.ID AND TAXES.CATEGORY = TAXCATEGORIES.ID "
                    + "AND RECEIPTS.MONEY = ?"
                    + "GROUP BY TAXCATEGORIES.NAME",
                SerializerWriteString.INSTANCE,
                new SerializerReadClass(PaymentsModel.SalesLine.class))
            .list(app.getActiveCashIndex());
    if (asales == null) {
      p.m_lsales = new ArrayList<SalesLine>();
    } else {
      p.m_lsales = asales;
    }

    return p;
  }
Пример #18
0
 /** Creates new form JTicketsBag */
 public JTicketsBag(AppView oApp, TicketsEditor panelticket) {
   m_App = oApp;
   m_panelticket = panelticket;
   m_dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");
 }
Пример #19
0
  private void btnPayActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnPayActionPerformed

    paymentdialog.setPrintSelected(true);
    // MSL : get total of selected tickets
    double tt = 0;
    for (Object tl : jList1.getSelectedValues()) {

      FindTicketsInfoCustomer sTicket = (FindTicketsInfoCustomer) tl;
      TicketInfo t = new TicketInfo();
      try {
        t = dlsales.loadTicket(0, sTicket.getTicketId());
        tt = tt + t.getTotal(); // - t.getTotalPaid();
      } catch (BasicException e) {

      }
    }
    // -------------

    // if (paymentdialog.showDialog(customerext.getCurdebt(), null)) {
    if (paymentdialog.showDialog(tt, null)) {

      // Save the ticket
      /*TicketInfo ticket = new TicketInfo();
      ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT);

      List<PaymentInfo> payments = paymentdialog.getSelectedPayments();

      double total = 0.0;
      for (PaymentInfo p : payments) {
          total += p.getTotal();
      }

      payments.add(new PaymentInfoTicket(-total, "debtpaid"));

      ticket.setPayments(payments);

      ticket.setUser(app.getAppUserView().getUser().getUserInfo());
      ticket.setActiveCash(app.getActiveCashIndex());
      ticket.setDate(new Date());
      ticket.setCustomer(customerext);

      try {
          dlsales.saveTicket(ticket, app.getInventoryLocation());
      } catch (BasicException eData) {
          MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData);
          msg.show(this);
      }
       *
       */

      // Save the ticket
      TicketInfo ticket = new TicketInfo();
      ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT);

      List<PaymentInfo> payments = paymentdialog.getSelectedPayments();

      double total = 0.0;
      for (PaymentInfo p : payments) {
        total += p.getTotal();
      }
      double reste = total;

      for (Object tl : jList1.getSelectedValues()) {
        FindTicketsInfoCustomer sTicket = (FindTicketsInfoCustomer) tl;
        TicketInfo t = new TicketInfo();

        if (reste > 0) {
          try {
            t = dlsales.loadTicket(0, sTicket.getTicketId());

            payments.add(new PaymentInfoTicket(-t.getTotal(), "debtpaid"));
            reste = total - t.getTotal();

            ticket.setPayments(payments);
            ticket.setUser(app.getAppUserView().getUser().getUserInfo());
            ticket.setActiveCash(app.getActiveCashIndex());
            ticket.setDate(new Date());
            ticket.setCustomer(customerext);
            dlsales.saveTicket(ticket, app.getInventoryLocation());
            new StaticSentence(
                    this.app.getSession(),
                    "UPDATE TICKETS Set STATUS=9 WHERE ID = ?",
                    SerializerWriteString.INSTANCE)
                .exec(t.getId());

            // MSL : break the system : set the receipt with original one
            // TODO : split the amount paid to the ticket values
            /*new StaticSentence(this.app.getSession()
                        , "UPDATE RECEIPTS Set ID=? WHERE ID = ?"
                        , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING}))
                        .exec(new Object[] {t.getId(), ticket.getId()});
            */
            new StaticSentence(
                    this.app.getSession(),
                    "UPDATE PAYMENTS Set TICKETID=? WHERE RECEIPT = ?",
                    new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING}))
                .exec(new Object[] {t.getId(), ticket.getId()});

          } catch (BasicException eData) {
            MessageInf msg =
                new MessageInf(
                    MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData);
            msg.show(this);
          }
        }
      }

      // MSL : no tickets selected
      if ((jList1.getSelectedValues() == null) || (reste > 0)) {

        payments.add(new PaymentInfoTicket(-reste, "debtpaid"));

        ticket.setPayments(payments);

        ticket.setUser(app.getAppUserView().getUser().getUserInfo());
        ticket.setActiveCash(app.getActiveCashIndex());
        ticket.setDate(new Date());
        ticket.setCustomer(customerext);

        try {
          dlsales.saveTicket(ticket, app.getInventoryLocation());
        } catch (BasicException eData) {
          MessageInf msg =
              new MessageInf(
                  MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData);
          msg.show(this);
        }
      }

      // reload customer
      CustomerInfoExt c;
      try {
        c = dlsales.loadCustomerExt(customerext.getId());
        if (c == null) {
          MessageInf msg =
              new MessageInf(
                  MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"));
          msg.show(this);
        } else {
          editCustomer(c);
        }
      } catch (BasicException ex) {
        c = null;
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex);
        msg.show(this);
      }

      printTicket(
          paymentdialog.isPrintSelected() ? "Printer.CustomerPaid" : "Printer.CustomerPaid2",
          ticket,
          c);
    }

    editorcard.reset();
    editorcard.activate();
  } // GEN-LAST:event_btnPayActionPerformed