Package com.openbravo.pos.ticket

Examples of com.openbravo.pos.ticket.TicketInfo


   
    private void newTicket() {     
       
        saveCurrentTicket();

        TicketInfo ticket = new TicketInfo();   
        m_sCurrentTicket = UUID.randomUUID().toString(); // m_fmtid.format(ticket.getId());
        m_panelticket.setActiveTicket(ticket, null);     
    }
View Full Code Here


    }
     
    private void readTicket(int iTicketid, int iTickettype) {
       
        try {
            TicketInfo ticket = (iTicketid==-1)
                ? m_dlSales.loadTicket(iTickettype,  m_jTicketEditor.getValueInteger())
                : m_dlSales.loadTicket(iTickettype, iTicketid) ;

            if (ticket == null) {
                MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.notexiststicket"));
View Full Code Here

       
        m_ticketCopy = null;
        m_TicketsBagTicketBag.showRefund();
        m_panelticketedit.showRefundLines(aRefundLines);
       
        TicketInfo refundticket = new TicketInfo();
        refundticket.setTicketType(TicketInfo.RECEIPT_REFUND);
        refundticket.setCustomer(m_ticket.getCustomer());
        refundticket.setPayments(m_ticket.getPayments());
        m_panelticketedit.setActiveTicket(refundticket, null);     
       
    }//GEN-LAST:event_m_jRefundActionPerformed
View Full Code Here

               
                if (customer == null) {
                    // tables
               
                    // check if the sharedticket is the same
                    TicketInfo ticket = getTicketInfo(m_place);

                    // check
                    if (ticket == null && !m_place.hasPeople()) {
                        // Empty table and checked

                        // table occupied
                        ticket = new TicketInfo();
                        try {
                            dlReceipts.insertSharedTicket(m_place.getId(), ticket);
                        } catch (BasicException e) {
                            new MessageInf(e).show(JTicketsBagRestaurantMap.this); // Glup. But It was empty.
                        }                    
                        m_place.setPeople(true);
                        setActivePlace(m_place, ticket);

                    } else if (ticket == null  && m_place.hasPeople()) {
                        // The table is now empty
                        new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.tableempty")).show(JTicketsBagRestaurantMap.this);
                        m_place.setPeople(false); // fixed       

                    } else if (ticket != null && !m_place.hasPeople()) {
                        // The table is now full
                        new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.tablefull")).show(JTicketsBagRestaurantMap.this);      
                        m_place.setPeople(true);

                    } else { // both != null
                        // Full table               
                        // m_place.setPeople(true); // already true                          
                        setActivePlace(m_place, ticket);                  
                    }
                } else {
                    // receiving customer.
                   
                    // check if the sharedticket is the same
                    TicketInfo ticket = getTicketInfo(m_place);
                    if (ticket == null) {
                        // receive the customer
                        // table occupied
                        ticket = new TicketInfo();
                       
                        try {
                            ticket.setCustomer(customer.getId() == null
                                    ? null
                                    : dlSales.loadCustomerExt(customer.getId()));
                        } catch (BasicException e) {
                            MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), e);
                            msg.show(JTicketsBagRestaurantMap.this);           
                        }                    
                       
                        try {
                            dlReceipts.insertSharedTicket(m_place.getId(), ticket);
                        } catch (BasicException e) {
                            new MessageInf(e).show(JTicketsBagRestaurantMap.this); // Glup. But It was empty.
                        }                    
                        m_place.setPeople(true);
                       
                        m_PlaceClipboard = null;
                        customer = null;    
                       
                        setActivePlace(m_place, ticket);                       
                    } else {
                        // TODO: msg: The table is now full
                        new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.tablefull")).show(JTicketsBagRestaurantMap.this);      
                        m_place.setPeople(true);
                        m_place.getButton().setEnabled(false);
                    }
                }
            } else {
                // check if the sharedticket is the same
                TicketInfo ticketclip = getTicketInfo(m_PlaceClipboard);

                if (ticketclip == null) {
                    new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.tableempty")).show(JTicketsBagRestaurantMap.this);
                    m_PlaceClipboard.setPeople(false);
                    m_PlaceClipboard = null;
                    customer = null;
                    printState();
                } else {
                    // tenemos que copiar el ticket del clipboard
                    if (m_PlaceClipboard == m_place) {
                        // the same button. Canceling.
                        Place placeclip = m_PlaceClipboard;                      
                        m_PlaceClipboard = null;
                        customer = null;
                        printState();
                        setActivePlace(placeclip, ticketclip);
                    } else if (!m_place.hasPeople()) {
                        // Moving the receipt to an empty table
                        TicketInfo ticket = getTicketInfo(m_place);

                        if (ticket == null) {
                            try {
                                dlReceipts.insertSharedTicket(m_place.getId(), ticketclip);
                                m_place.setPeople(true);
                                dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId());
                                m_PlaceClipboard.setPeople(false);
                            } catch (BasicException e) {
                                new MessageInf(e).show(JTicketsBagRestaurantMap.this); // Glup. But It was empty.
                            }

                            m_PlaceClipboard = null;
                            customer = null;
                            printState();

                            // No hace falta preguntar si estaba bloqueado porque ya lo estaba antes
                            // activamos el ticket seleccionado
                            setActivePlace(m_place, ticketclip);
                        } else {
                            // Full table
                            new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.tablefull")).show(JTicketsBagRestaurantMap.this);
                            m_PlaceClipboard.setPeople(true);
                            printState();
                        }
                    } else {                         
                        // Merge the lines with the receipt of the table
                        TicketInfo ticket = getTicketInfo(m_place);

                        if (ticket == null) {
                            // The table is now empty
                            new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.tableempty")).show(JTicketsBagRestaurantMap.this);
                            m_place.setPeople(false); // fixed
                        } else {
                            //asks if you want to merge tables
                            if (JOptionPane.showConfirmDialog(JTicketsBagRestaurantMap.this, AppLocal.getIntString("message.mergetablequestion"), AppLocal.getIntString("message.mergetable"), JOptionPane.YES_NO_OPTION)
                                    == JOptionPane.YES_OPTION){                                
                                // merge lines ticket

                                try {
                                    dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId());
                                    m_PlaceClipboard.setPeople(false);
                                    if (ticket.getCustomer() == null) {
                                    ticket.setCustomer(ticketclip.getCustomer());
                                    }
                                    for(TicketLineInfo line : ticketclip.getLines()) {
                                        ticket.addLine(line);
                                    }
                                    dlReceipts.updateSharedTicket(m_place.getId(), ticket);
                                } catch (BasicException e) {
                                    new MessageInf(e).show(JTicketsBagRestaurantMap.this); // Glup. But It was empty.
                                }
View Full Code Here

        paymentdialog.setPrintSelected(true);
       
        if (paymentdialog.showDialog(customerext.getCurdebt(), 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);


            // MJARA 19/04/2011
            //Generar el código de ticket por el tipo de comprobante
            if (ticket.getCustomer() == null) {
                ticket.setDocType(0);
            }
            else {
                    ticket.setDocType(1);
            }
            // MJARA 19/04/2011

            try {
                dlsales.saveTicket(ticket, app.getInventoryLocation());
View Full Code Here

    private void btnSplitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSplitActionPerformed

        if (m_oTicket.getLinesCount() > 0) {
            ReceiptSplit splitdialog = ReceiptSplit.getDialog(this, dlSystem.getResourceAsXML("Ticket.Line"), dlSales, dlCustomers, taxeslogic);
           
            TicketInfo ticket1 = m_oTicket.copyTicket();
            TicketInfo ticket2 = new TicketInfo();
            ticket2.setCustomer(m_oTicket.getCustomer());
           
            if (splitdialog.showDialog(ticket1, ticket2, m_oTicketExt)) {
                if (closeTicket(ticket2, m_oTicketExt)) { // already checked  that number of lines > 0                           
                    setActiveTicket(ticket1, m_oTicketExt);// set result ticket
                }
View Full Code Here

                SerializerReadString.INSTANCE).find(id)
            != null;
    }

    public final TicketInfo loadTicket(final int tickettype, final int ticketid) throws BasicException {
        TicketInfo ticket = (TicketInfo) new PreparedSentence(s
                , "SELECT T.ID, T.TICKETTYPE, T.TICKETID, R.DATENEW, R.MONEY, R.ATTRIBUTES, P.ID, P.NAME, T.CUSTOMER FROM RECEIPTS R JOIN TICKETS T ON R.ID = T.ID LEFT OUTER JOIN PEOPLE P ON T.PERSON = P.ID WHERE T.TICKETTYPE = ? AND T.TICKETID = ?"
                , SerializerWriteParams.INSTANCE
                , new SerializerReadClass(TicketInfo.class))
                .find(new DataParams() { public void writeValues() throws BasicException {
                    setInt(1, tickettype);
                    setInt(2, ticketid);
                }});
        if (ticket != null) {

            String customerid = ticket.getCustomerId();
            ticket.setCustomer(customerid == null
                    ? null
                    : loadCustomerExt(customerid));

            ticket.setLines(new PreparedSentence(s
                , "SELECT L.TICKET, L.LINE, L.PRODUCT, L.ATTRIBUTESETINSTANCE_ID, L.UNITS, L.PRICE, T.ID, T.NAME, T.CATEGORY, T.VALIDFROM, T.CUSTCATEGORY, T.PARENTID, T.RATE, T.RATECASCADE, T.RATEORDER, L.ATTRIBUTES " +
                  "FROM TICKETLINES L, TAXES T WHERE L.TAXID = T.ID AND L.TICKET = ? ORDER BY L.LINE"
                , SerializerWriteString.INSTANCE
                , new SerializerReadClass(TicketLineInfo.class)).list(ticket.getId()));
            ticket.setPayments(new PreparedSentence(s
                , "SELECT PAYMENT, TOTAL, TRANSID FROM PAYMENTS WHERE RECEIPT = ?"
                , SerializerWriteString.INSTANCE
                , new SerializerReadClass(PaymentInfoTicket.class)).list(ticket.getId()));
        }
        return ticket;
    }
View Full Code Here

    private Order[] transformTickets(List<TicketInfo> ticketlist) {

        // Transformamos de tickets a ordenes
        Order[] orders = new Order[ticketlist.size()];
        for (int i = 0; i < ticketlist.size(); i++) {
            TicketInfo ticket = ticketlist.get(i);

            orders[i] = new Order();

            OrderIdentifier orderid = new OrderIdentifier();
            Calendar datenew = Calendar.getInstance();
            datenew.setTime(ticket.getDate());
            orderid.setDateNew(datenew);
            orderid.setDocumentNo(Integer.toString(ticket.getTicketId()));

            orders[i].setOrderId(orderid);
            orders[i].setState(800175);
           
            // set the business partner
            BPartner bp;
            if (ticket.getCustomerId() == null) {
                bp = null;
            } else {
                bp = new BPartner();
                bp.setId(ticket.getCustomer().getSearchkey());
                bp.setName(ticket.getCustomer().getName());
            }
            orders[i].setBusinessPartner(bp);

            //Saco las lineas del pedido
            OrderLine[] orderLine = new OrderLine[ticket.getLines().size()];
            for (int j = 0; j < ticket.getLines().size(); j++){
                TicketLineInfo line = ticket.getLines().get(j);

                orderLine[j] = new OrderLine();
                orderLine[j].setOrderLineId(String.valueOf(line.getTicketLine()));// o simplemente "j"
                if (line.getProductID() == null) {
                    orderLine[j].setProductId("0");
                } else {
                    orderLine[j].setProductId(line.getProductID()); // capturar error
                }
                orderLine[j].setUnits(line.getMultiply());
                orderLine[j].setPrice(line.getPrice());
                orderLine[j].setTaxId(line.getTaxInfo().getId());    
            }
            orders[i].setLines(orderLine);

            //Saco las lineas de pago
            Payment[] paymentLine = new Payment[ticket.getPayments().size()];
            for (int j = 0; j < ticket.getPayments().size(); j++){      
                PaymentInfo payment = ticket.getPayments().get(j);

                paymentLine[j] = new Payment();
                paymentLine[j].setAmount(payment.getTotal());
                if ("magcard".equals(payment.getName())) {
                    paymentLine[j].setPaymentType("K");
View Full Code Here

        product = new ProductDAO();
        category = new CategoryDAO();
        tax = new TaxDAO();
        taxesLogic = new TaxesLogic(tax.getTaxList());

        TicketInfo obj = ticket.getTicket(ticketId);
        ProductInfo productObj = product.findProductById(productId);
        TicketLineInfo line = new TicketLineInfo(productObj, productObj.getPriceSell(), taxesLogic.getTaxInfo(productObj.getTaxcat()));
        obj.addLine(line);
        ticket.updateTicket(ticketId, obj);
        refreshTax(obj);
    }
View Full Code Here

        if (!str.equals("")) {
            mode = Integer.valueOf(str);
        }
        List<TicketLineInfo> linesList = new ArrayList<TicketLineInfo>();
        List products = new ArrayList<ProductInfoExt>();
        TicketInfo ticket;
        switch (mode) {

            //removes products
            case 1:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                if (array != null) {
                    for (int i = 0; i < array.length; i++) {
                        if (linesList.get(Integer.valueOf(array[i])).getMultiply() > 1) {
                            linesList.get(Integer.valueOf(array[i])).setMultiply(linesList.get(Integer.valueOf(array[i])).getMultiply() - 1);
                        }

                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                request.setAttribute("product", products.get(0));
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("line", linesList.get(Integer.valueOf(array[0])));
                request.setAttribute("lineNo", array[0]);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(UPDATE);

            case 4:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                int var = Integer.parseInt(array[0]);
                linesList.remove(var);
                if (linesList.size() > var && manager.findProductById(linesList.get(var).getProductid()).isCom()) {
                    linesList.remove(var);
                    while (linesList.size() > var && manager.findProductById(linesList.get(var).getProductid()).isCom()) {
                        linesList.remove(var);
                        if (linesList.size() == var) {
                            break;
                        }
                    }
                }
                manager.updateLineFromTicket(place, ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                request.setAttribute("floorName", manager.findFloorById(manager.findPlaceById(place).getFloor()).getName());
                request.setAttribute("place", place);
                request.setAttribute("placeName", manager.findPlaceNameById(place));
                request.setAttribute("floorId", floorId);
                request.setAttribute("lines", linesList);
                request.setAttribute("products", products);
                request.setAttribute("total", manager.getTotalOfaTicket(place));

                return mapping.findForward(SUCCESS);

            //edits lines
            case 2:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                String[] index = floorForm.getParameters();
                //if null go to default and refresh products. that's why no break
                linesList.get(Integer.valueOf(index[0])).setMultiply(Double.valueOf(index[1]));

                manager.updateLineFromTicket(floorForm.getId(), ticket);
                for (Object line : linesList) {
                    TicketLineInfo li = (TicketLineInfo) line;
                    products.add(manager.findProductById(li.getProductid()));
                }

                break;

            //increment product
            case 3:
                ticket = manager.findTicket(place);
                linesList = ticket.getM_aLines();
                array = floorForm.getParameters();
                if (array != null) {
                    for (int i = 0; i < array.length; i++) {
                        linesList.get(Integer.valueOf(array[i])).setMultiply(linesList.get(Integer.valueOf(array[i])).getMultiply() + 1);    //strange
                    }
View Full Code Here

TOP

Related Classes of com.openbravo.pos.ticket.TicketInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.