Package com.openbravo.pos.ticket

Examples of com.openbravo.pos.ticket.TicketInfo


    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


                    }
                }

                CreateOrderInput orders;
                for (int i = 0; i < ticketlist.size(); i++) {
                    TicketInfo ticket = ticketlist.get(i);

                    String userID = usersMap.get(ticket.getCustomerId());

                    orders = new CreateOrderInput();
                    orders.setPayment_method_id(externalsales.getWsPayID());
                    orders.setPrice_including_tax(String.valueOf(ticket.getTotal()));
                    orders.setProduct_currency("EUR");
                    orders.setShipping_carrier_name("0");
                    orders.setShipping_method("0");
                    orders.setShipping_price("0");
                    orders.setShipping_rate_id("0");
                    orders.setShipping_rate_name("0");
                    orders.setUser_id(userID);
                    orders.setVendor_id(externalsales.getWsPosid());

                    Product[] products = new Product[ticket.getLines().size()];

                    for (int j = 0; j < ticket.getLines().size(); j++) {
                        TicketLineInfo line = ticket.getLines().get(j);
                        // String pDesc = line.getProductName();
                        String pDesc = "";
                        products[j] = new Product();

                        System.out.println("> " + line.getProductName());

                        try {
                            if (line.getProductID().equals("0")) {
                                pDesc = line.getProductName();
                                products[j].setProduct_id(productsMap.get(line.getProductID()));
                                products[j].setQuantity(String.valueOf(line.getMultiply() * line.getPriceTax() * 100));
                                //pDesc += " " + String.valueOf(line.getMultiply()) + " > " + line.getPriceTax();
                            } else {
                                products[j].setProduct_id(productsMap.get(line.getProductID()));
                                products[j].setQuantity(String.valueOf(line.getMultiply()));
                            }
                        } catch (NullPointerException npe) {
                            pDesc = line.getProductName();
                            products[j].setProduct_id(productsMap.get("0"));
                            products[j].setQuantity(String.valueOf(line.getMultiply() * line.getPriceTax() * 100));

                        }
                        if (line.getProductAttSetInstDesc() != null && !line.getProductAttSetInstDesc().equals("")) {
                            if (pDesc.equalsIgnoreCase("")) {
                                pDesc += ", ";
                            }
                            pDesc += line.getProductAttSetInstDesc();
                        }
                        products[j].setDescription(pDesc);
                        //System.out.println(products[j].getProduct_id()+" "+products[j].getDescription());
                    }

                    orders.setCoupon_code("0");
                    orders.setProducts(products);

                    Double totalpaid = 0.0;
                    for (int j = 0; j < ticket.getPayments().size(); j++) {
                        PaymentInfo payment = ticket.getPayments().get(j);

                        if (("magcard".equals(payment.getName()))
                                || ("cheque".equals(payment.getName()))
                                || ("cash".equals(payment.getName()))) {
                            totalpaid += payment.getTotal();
                        }
                    }

                    totalpaid = (Math.round(totalpaid * 100.0)) / 1.0;
                    String note = ("TicketID=" + ticket.printId() + ",TotalPaid=" + (totalpaid / 100) + ",Vendeur=" + ticket.printUser());
                    //                           + ".Date." + ticket.printDate() + ".DateRetour." + ticket.printDateReturn() + ".DateRendu." + ticket.printDateRendu());

                    orders.setCustomer_note(note);

                    String orderID = externalsales.uploadOrders(orders);

                    if (!orderID.equals("")) {
                        cpt++;

                        // Set status as orderID from the website (correlation)
                        externalsales.updateStatus(orderID, ticket.getDate(), ticket.getDateReturn());


                        if (totalpaid >= Math.round((ticket.getTotal() * 100))) {
                            //Payment made set as paid on website
                            externalsales.setPaid(orderID, ticket.getDate());
                        }
                        if (ticket.getTicketType() == TicketInfo.RECEIPT_REFUND) {
                            //The ticket is a refund, Add return date locally and update website status
                            dlintegration.execUpdateTicketsRefundPayment(String.valueOf(ticket.getTicketType()), String.valueOf(ticket.getStatus()));
                            externalsales.setRendu(orderID);
                        } else if (ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL) // Normal ticket > Update status to website orderId
                        {
                            dlintegration.execUpdateTicket(String.valueOf(ticket.getTicketId()), orderID);
                        }
                    }
                }
            }
            //PAYMENTS
            List<Integer> orderids = dlintegration.getTicketsPayments();

            if (orderids.size() > 0) {

                for (Integer oid : orderids) {
                    // List<Double> dd = dlintegration.getDebt(oid);

                    double dd = Math.round(dlintegration.getDebt(String.valueOf(oid)) * 100) / 100;
                    double dp = Math.round(dlintegration.getPaid(String.valueOf(oid)) * 100) / 100;

                    if ((dd + dp) <= 0.0) {
                        //for each ticket of paid type set paid on website
                        externalsales.setPaid(String.valueOf(oid), null);
                        // then update the date return to know it was updated on the website
                        dlintegration.execUpdateTicketsRefundPayment(String.valueOf(TicketInfo.RECEIPT_PAYMENT), String.valueOf(oid));
                        dlintegration.execUpdateTicketsRefundPayment(String.valueOf(TicketInfo.RECEIPT_REFUND), String.valueOf(oid));
                    }
                }
            }

            //RETURNS
            List<TicketInfo> ticketlistr = dlintegration.getTicketsReturned();

            if (ticketlistr.size() > 0) {

                for (TicketInfo ticket : ticketlistr) {
                    //each returned tickets are updated as returned on the website
                    if (ticket.getTicketType() == 0 && externalsales.setRendu(String.valueOf(ticket.getStatus()))) {
                        if (WSInfo.isWsdeletert()) {
                            dlsales.deleteTicket(ticket, "0");
                        }
                    } else {
                        if (WSInfo.isWsdeletert()) {
View Full Code Here

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

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

        paymentdialogCredit.setPrintSelected(true);

        if (paymentdialogCredit.showDialog(0.0, customerext, null, null)) {

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

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

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

            payments.add(new PaymentInfoTicket(total, "creditpaid"));

            ticket.setPayments(payments);
            ticket.setUser(app.getAppUserView().getUser().getUserInfo());
            ticket.setActiveCash(app.getActiveCashIndex());
            ticket.setDate(new Date());
            ticket.setCustomer(customerext);
            ticket.setDateReturn(paymentdialogCredit.getrDate());

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

        initComponents();
    }
   
    public void activate() {
       
        m_panelticket.setActiveTicket(new TicketInfo(), null);
       
        // Authorization
        m_jDelTicket.setEnabled(m_App.getAppUserView().getUser().hasPermission("com.openbravo.pos.sales.JPanelTicketEdits"));

    }
View Full Code Here

        m_panelticket.setActiveTicket(null, null);     
        return true;
    }
   
    public void deleteTicket() {          
        m_panelticket.setActiveTicket(new TicketInfo(), null);
    }
View Full Code Here

    private void readTicket(int iTicketid, int iTickettype) {
        totalRefund = 0.0;

        // This logic should be in TicketInfo
        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());
        refundticket.setStatus(status);
        refundticket.setDateReturn(null);
        m_panelticketedit.setActiveTicket(refundticket, null);

    }//GEN-LAST:event_m_jRefundActionPerformed
View Full Code Here

        paymentdialog.init(m_App);
        paymentdialog.setPrintSelected(true);

        if (paymentdialog.showDialog(toPay, currentCustomer, null, null)) {

            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();
                m_ticket.getPayments().add(p);
            }

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

            ticket.setPayments(payments);
            ticket.setUser(m_App.getAppUserView().getUser().getUserInfo());
            ticket.setActiveCash(m_App.getActiveCashIndex());
            ticket.setDate(new Date());
            ticket.setCustomer(currentCustomer);
            ticket.setDateReturn(paymentdialog.getrDate());
            ticket.setStatus(m_ticket.getStatus());

            try {
                m_dlSales.saveTicket(ticket, m_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 = m_dlSales.loadCustomerExt(currentCustomer.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);
            }

            m_jRendu.setEnabled(m_ticket != null && (ticket.isPickable()));
            if (ticket != null) {
                try {
                    ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);
                    script.put("ticket", ticket);
                    script.put("customer", currentCustomer);
View Full Code Here

    if (paymentdialog.showDialog(currentCustomer.getCurdebt(), currentCustomer, null, null)) {

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

        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(m_App.getAppUserView().getUser().getUserInfo());
        ticket.setActiveCash(m_App.getActiveCashIndex());
        ticket.setDate(new Date());
        ticket.setCustomer(currentCustomer);
        ticket.setDateReturn(paymentdialog.getrDate());

        try {
            dlsales.saveTicket(ticket, m_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(currentCustomer.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);
        }

        hasDebt();

        m_jRendu.setEnabled(m_ticket != null && (ticket.isPickable()));
        if (ticket != null) {
            try {
                ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);
                script.put("ticket", ticket);
                script.put("customer", currentCustomer);
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.