Exemplo n.º 1
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;
  }
Exemplo n.º 2
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
   };
 }
Exemplo n.º 4
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