Example #1
0
  private void processKey(char c) {

    if (c == '\n') {

      AppUser user = null;
      try {
        user = m_dlSystem.findPeopleByCard(inputtext.toString());
      } catch (BasicException e) {
        e.printStackTrace();
      }

      if (user == null) {
        // user not found
        MessageInf msg =
            new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.nocard"));
        msg.show(this);
      } else {
        openAppView(user);
      }

      inputtext = new StringBuffer();
    } else {
      inputtext.append(c);
    }
  }
  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
Example #3
0
  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
Example #4
0
 public void actionPerformed(ActionEvent evt) {
   // String sPassword = m_actionuser.getPassword();
   if (m_actionuser.authenticate()) {
     // p'adentro directo, no tiene password
     openAppView(m_actionuser);
   } else {
     // comprobemos la clave antes de entrar...
     String sPassword =
         JPasswordDialog.showEditPassword(
             JRootApp.this,
             AppLocal.getIntString("Label.Password"),
             m_actionuser.getName(),
             m_actionuser.getIcon());
     if (sPassword != null) {
       if (m_actionuser.authenticate(sPassword)) {
         openAppView(m_actionuser);
       } else {
         MessageInf msg =
             new MessageInf(
                 MessageInf.SGN_WARNING, AppLocal.getIntString("message.BadPassword"));
         msg.show(JRootApp.this);
       }
     }
   }
 }
  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();
  }
Example #6
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 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 assignProductByReference() {
   try {
     ProductInfoExt oProduct = m_dlSales.getProductInfoByReference(m_jreference.getText());
     if (oProduct == null) {
       assignProduct(null);
       Toolkit.getDefaultToolkit().beep();
     } else {
       // Se anade directamente una unidad con el precio y todo
       assignProduct(oProduct);
     }
   } catch (BasicException eData) {
     assignProduct(null);
     MessageInf msg = new MessageInf(eData);
     msg.show(this);
   }
 }
  public void deleteTicket() {

    if (m_ticketCopy != null) {
      // Para editar borramos el ticket anterior
      try {
        m_dlSales.deleteTicket(m_ticketCopy, m_App.getInventoryLocation());
      } catch (BasicException eData) {
        MessageInf msg =
            new MessageInf(
                MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData);
        msg.show(this);
      }
    }

    m_ticket = null;
    m_ticketCopy = null;
    resetToTicket();
  }
  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
Example #11
0
  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);
      }
    }
  }
Example #12
0
  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);
      }
    }
  }
  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);
      }
    }
  }
Example #14
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();
  }
Example #15
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
Example #16
0
  public boolean initApp(AppProperties props) {

    m_props = props;
    // setPreferredSize(new java.awt.Dimension(800, 600));

    // support for different component orientation languages.
    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    // Database start
    try {
      session = AppViewConnection.createSession(m_props);
    } catch (BasicException e) {
      JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, e.getMessage(), e));
      return false;
    }

    m_dlSystem = (DataLogicSystem) getBean("com.openbravo.pos.forms.DataLogicSystem");

    // Create or upgrade the database if database version is not the expected
    String sDBVersion = readDataBaseVersion();
    if (!AppLocal.APP_VERSION.equals(sDBVersion)) {

      // Create or upgrade database

      String sScript =
          sDBVersion == null
              ? m_dlSystem.getInitScript() + "-create.sql"
              : m_dlSystem.getInitScript() + "-upgrade-" + sDBVersion + ".sql";

      if (JRootApp.class.getResource(sScript) == null) {
        JMessageDialog.showMessage(
            this,
            new MessageInf(
                MessageInf.SGN_DANGER,
                sDBVersion == null
                    ? AppLocal.getIntString(
                        "message.databasenotsupported",
                        session.DB
                            .getName()) // Create script does not exists. Database not supported
                    : AppLocal.getIntString(
                        "message.noupdatescript"))); // Upgrade script does not exist.
        session.close();
        return false;
      } else {
        // Create or upgrade script exists.
        if (JOptionPane.showConfirmDialog(
                this,
                AppLocal.getIntString(
                    sDBVersion == null ? "message.createdatabase" : "message.updatedatabase"),
                AppLocal.getIntString("message.title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE)
            == JOptionPane.YES_OPTION) {

          try {
            BatchSentence bsentence = new BatchSentenceResource(session, sScript);
            bsentence.putParameter("APP_ID", Matcher.quoteReplacement(AppLocal.APP_ID));
            bsentence.putParameter("APP_NAME", Matcher.quoteReplacement(AppLocal.APP_NAME));
            bsentence.putParameter("APP_VERSION", Matcher.quoteReplacement(AppLocal.APP_VERSION));

            java.util.List l = bsentence.list();
            if (l.size() > 0) {
              JMessageDialog.showMessage(
                  this,
                  new MessageInf(
                      MessageInf.SGN_WARNING,
                      AppLocal.getIntString("Database.ScriptWarning"),
                      l.toArray(new Throwable[l.size()])));
            }
          } catch (BasicException e) {
            JMessageDialog.showMessage(
                this,
                new MessageInf(
                    MessageInf.SGN_DANGER, AppLocal.getIntString("Database.ScriptError"), e));
            session.close();
            return false;
          }
        } else {
          session.close();
          return false;
        }
      }
    }

    // Cargamos las propiedades de base de datos
    m_propsdb = m_dlSystem.getResourceAsProperties(m_props.getHost() + "/properties");

    // creamos la caja activa si esta no existe
    try {
      String sActiveCashIndex = m_propsdb.getProperty("activecash");
      Object[] valcash =
          sActiveCashIndex == null ? null : m_dlSystem.findActiveCash(sActiveCashIndex);
      if (valcash == null || !m_props.getHost().equals(valcash[0])) {
        // no la encuentro o no es de mi host por tanto creo una...
        setActiveCash(
            UUID.randomUUID().toString(),
            m_dlSystem.getSequenceCash(m_props.getHost()) + 1,
            new Date(),
            null);

        // creamos la caja activa
        m_dlSystem.execInsertCash(
            new Object[] {
              getActiveCashIndex(),
              m_props.getHost(),
              getActiveCashSequence(),
              getActiveCashDateStart(),
              getActiveCashDateEnd()
            });
      } else {
        setActiveCash(sActiveCashIndex, (Integer) valcash[1], (Date) valcash[2], (Date) valcash[3]);
      }
    } catch (BasicException e) {
      // Casco. Sin caja no hay pos
      MessageInf msg =
          new MessageInf(
              MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e);
      msg.show(this);
      session.close();
      return false;
    }

    // Leo la localizacion de la caja (Almacen).
    m_sInventoryLocation = m_propsdb.getProperty("location");
    if (m_sInventoryLocation == null) {
      m_sInventoryLocation = "0";
      m_propsdb.setProperty("location", m_sInventoryLocation);
      m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties", m_propsdb);
    }

    // Inicializo la impresora...
    m_TP = new DeviceTicket(this, m_props);

    // Inicializamos
    m_TTP = new TicketParser(getDeviceTicket(), m_dlSystem);
    printerStart();

    // Inicializamos la bascula
    m_Scale = new DeviceScale(this, m_props);

    // Inicializamos la scanpal
    m_Scanner = DeviceScannerFactory.createInstance(m_props);

    // Leemos los recursos basicos
    BufferedImage imgicon = m_dlSystem.getResourceAsImage("Window.Logo");
    m_jLblTitle.setIcon(imgicon == null ? null : new ImageIcon(imgicon));
    m_jLblTitle.setText(m_dlSystem.getResourceAsText("Window.Title"));

    String sWareHouse;
    try {
      sWareHouse = m_dlSystem.findLocationName(m_sInventoryLocation);
    } catch (BasicException e) {
      sWareHouse = null; // no he encontrado el almacen principal
    }

    // Show Hostname, Warehouse and URL in taskbar
    String url;
    try {
      url = session.getURL();
    } catch (SQLException e) {
      url = "";
    }
    m_jHost.setText("<html>" + m_props.getHost() + " - " + sWareHouse + "<br>" + url);

    showLogin();

    return true;
  }
  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